Lighter

I been trying to get this lighter to work for ever but I cant get it to work!

here is the error

[ERROR] addons/hobolighter/lua/weapons/lighter.lua:45: attempt to call method ‘Ignite’ (a nil value)

  1. unknown - addons/hobolighter/lua/weapons/lighter.lua:45


if CLIENT then
	SWEP.PrintName = "Lighter"
	SWEP.Slot = 2
	SWEP.SlotPos = 2
	SWEP.DrawAmmo = false
	SWEP.DrawCrosshair = true
end

SWEP.Author = ""
SWEP.Instructions = "Left click to attempt to ignite somthing."
SWEP.Contact = ""
SWEP.Purpose = ""

SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.ViewModel = Model("models/weapons/c_crowbar.mdl")
SWEP.WorldModel = Model("models/weapons/w_crowbar.mdl")

SWEP.UseHands = true

SWEP.Spawnable = true
SWEP.AdminSpawnable = true

SWEP.Sound = Sound("physics/wood/wood_box_impact_hard3.wav")

SWEP.Primary.ClipSize = -1      -- Size of a clip
SWEP.Primary.DefaultClip = 0        -- Default number of bullets in a clip
SWEP.Primary.Automatic = false      -- Automatic/Semi Auto
SWEP.Primary.Ammo = ""

SWEP.Secondary.ClipSize = -1        -- Size of a clip
SWEP.Secondary.DefaultClip = -1     -- Default number of bullets in a clip
SWEP.Secondary.Automatic = false        -- Automatic/Semi Auto
SWEP.Secondary.Ammo = ""

function SWEP:PrimaryAttack()
	self.Weapon:SetNextPrimaryFire(CurTime() + 1)
	rand = math.random(1, 7)
	local trace = self.Owner:GetEyeTrace()
	local e = trace.Entity
	if trace.HitPos:Distance(self.Owner:GetShootPos()) < 100 then
		local snd = {1,3,4}
		self:EmitSound("ambient/energy/spark".. tostring(snd[math.random(1, #snd)]) ..".wav", 50, 100)
		if IsValid(e) and rand == 1 and !e:IsVehicle() then
			e:Ignite(30,1) -- what I understand this is to light cars on fire...
		end
	end
end


Put spaces in the parenthesis of “e:Ignite(30,1)” so it would be like “e:Ignite( 30, 1 )”
If not that, mess around with the spaces in the parenthesis until it works.

Ignite is only defined on the server. Change it to:


if SERVER and IsValid( e )  ... 

change this



if IsValid(e) and rand == 1 and !e:IsVehicle() then
    e:Ignite(30,1) -- what I understand this is to light cars on fire...
end


to this



if IsValid(e) and SERVER and rand == 1 and !e:IsVehicle() and e.Ignite then
    e:Ignite(30,1) -- what I understand this is to light cars on fire...
end


  • snip - Ignite is defined on the server

alright, Were would I go to make Ignite Defined for vehicles?

  • edit It works thanks alot man haha I learned something new. Thank you so much!

It isn’t a matter of vehicle versus other entity - you are calling Entity:Ignite on the client, which only exists on the server.