Hello everyone, I have a problem with an addon and I try to solve the problem but I can not. It is actually a problem that comes from a timer (in a way it does not find value because the object has no physical but good) I would like to know if it is possible to m ’ help
This is error:
[ERROR] addons/dalek/lua/weapons/weapon_dalek_gun/shared.lua:95: attempt to call method ‘TakeDamageInfo’ (a nil value)
- unknown - addons/dalek/lua/weapons/weapon_dalek_gun/shared.lua:95
Timer Failed! [Simple][@addons/dalek/lua/weapons/weapon_dalek_gun/shared.lua (line 95)]*
Here is the Code file:
if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
end
if ( CLIENT ) then
SWEP.PrintName = "Dalek Ray Gun"
SWEP.Author = ""
SWEP.Slot = 0
SWEP.SlotPos = 1
SWEP.BounceWeaponIcon = false
SWEP.DrawWeaponInfoBox = false
killicon.Add("weapon_dalek_gun","HUD/killicons/dalek/dalek",Color ( 255, 80, 0, 255 ) )
end
SWEP.DrawAmmo = false;
SWEP.DrawCrosshair = true;
SWEP.Weight = 5;
SWEP.AutoSwitchTo = false;
SWEP.AutoSwitchFrom = false;
SWEP.UseHands = false
modeledit = Vector( 3, 0, -10)
SWEP.Category = “Dr. Who”
SWEP.Spawnable = true;
SWEP.AdminSpawnable = true;
SWEP.ViewModel = “models/weapons/v_dalekray.mdl”;
SWEP.WorldModel = “models/weapons/w_dalekray.mdl”;
SWEP.Primary.ClipSize = -1;
SWEP.Primary.DefaultClip = -1;
SWEP.Primary.Automatic = false;
SWEP.Primary.Ammo = “none”;
SWEP.Secondary.ClipSize = -1;
SWEP.Secondary.DefaultClip = -1;
SWEP.Secondary.Automatic = false;
SWEP.Secondary.Ammo = “none”;
SWEP.Secondary.Delay = 1
SWEP.BaseCrit = 28;
SWEP.CritChance = 28;
SWEP.SoundOn = true
SWEP.Delay=0.5
SWEP.Range=1000
SWEP.Damage=9999
SWEP.DefaultDamage = 50
SWEP.Charging = false;
function SWEP:Initialize()
self:SetWeaponHoldType(“pistol”)
end
function SWEP:PrimaryAttack()
self:SetNextPrimaryFire(CurTime() + self.Delay)
self.Owner:SetAnimation(PLAYER_ATTACK1)
local pos = self:GetBonePosition( self:LookupBone( "ValveBiped.Bip01_R_Hand") )
local tracedata = {}
tracedata.start = self.Owner:EyePos()
tracedata.endpos = self.Owner:EyePos()+(self.Owner:GetAimVector()*self.Range)
tracedata.filter = {self.Owner}
local trace = util.TraceLine(tracedata)
util.ParticleTracerEx( "weapon_combine_ion_cannon_beam", pos, trace.HitPos, self , 1, 0 )
self:EmitSound( "dalek/dalek_shoot.wav", 90, 100 )
if(trace.Hit)then
if trace.Entity:IsNPC() or trace.Entity:IsPlayer() then
local cadaverific = trace.Entity
if cadaverific:IsPlayer() then
local cadaverific = trace.Entity
end
local dmg = DamageInfo()
dmg:SetDamage(9999)
dmg:SetInflictor(self)
dmg:SetDamageType( 1024 )
dmg:SetDamagePosition(cadaverific:GetPos())
dmg:SetAttacker(self.Owner)
timer.Simple(0.5, function() cadaverific:TakeDamageInfo( dmg, self ) end )
end
self.Owner:ViewPunch( Angle( -5, -5, 0 ) )
end
end
function SWEP:SecondaryAttack()
self:EmitSound( "dalek/dalek.wav", 90, 100 )
end
function SWEP:AdjustMouseSensitivity()
if self.Owner:GetVelocity():Length() > 450 and self.Owner:OnGround() then
return 0.05
else
return 1
end
end
function SWEP:Deploy()
self:SendWeaponAnim(ACT_HL2MP_IDLE_FIST)
end
function SWEP:setReloadingFalse()
self:SetNetworkedBool( “reloading”, false)
end
Here is an image to better understand my problem.