I keep getting this error.
[ERROR] bad argument #1 to '?' (PhysObj expected, got no value)
1. unknown - [C]:-1
Timer Failed! [Simple][@lua/weapons/weapon_real_spas/shared.lua (line 450)]
i first used this code: timer.Simple(0.01, ent.SetVelocity, ent, push)
but then someone corrected me and told me to use this: timer.Simple(0.01, function() if ent and push then ent:SetVelocity(push) end end)
but i keep getting the above error. What is wrong?
It says it wants a Physics Object, try:
[code]
timer.Simple(0.01, function() if ent and push then ent:GetPhysicsObject():SetVelocity(push) end end)
[/code]
[QUOTE=Leystryku;38435691]It says it wants a Physics Object, try:
[code]
timer.Simple(0.01, function() if ent and push then ent:GetPhysicsObject():SetVelocity(push) end end)
[/code][/QUOTE]
same error
[ERROR] bad argument #1 to '?' (PhysObj expected, got no value)
1. unknown - [C]:-1
Timer Failed! [Simple][@lua/weapons/weapon_real_spas/shared.lua (line 450)]
Here is most of the script:
/*---------------------------------------------------------
ShootBullet
---------------------------------------------------------*/
function SWEP:CSShootBullet(dmg, recoil, numbul, cone)
numbul = numbul or 1
cone = cone or 0.01
local bullet = {}
bullet.Num = numbul
bullet.Src = self.Owner:GetShootPos() -- Source
bullet.Dir = self.Owner:GetAimVector() -- Dir of bullet
bullet.Spread = Vector(cone, cone, 0) -- Aim Cone
bullet.Tracer = 1 -- Show a tracer on every x bullets
bullet.Force = 2000 -- Amount of force to give to phys objects
bullet.Damage = 20 -- Amount of damage to give to the bullets
bullet.Callback = HitImpact
-- bullet.Callback = function ( a, b, c ) BulletPenetration( 0, a, b, c ) end -- CALL THE FUNCTION BULLETPENETRATION
self.Owner:FireBullets(bullet) -- Fire the bullets
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) -- View model animation
self.Owner:MuzzleFlash() -- Crappy muzzle light
self.Owner:SetAnimation(PLAYER_ATTACK1) -- 3rd Person Animation
local fx = EffectData()
fx:SetEntity(self.Weapon)
fx:SetOrigin(self.Owner:GetShootPos())
fx:SetNormal(self.Owner:GetAimVector())
fx:SetAttachment(self.MuzzleAttachment)
util.Effect(self.MuzzleEffect,fx) -- Additional muzzle effects
timer.Simple( self.EjectDelay, function()
if not IsFirstTimePredicted() then
return
end
local fx = EffectData()
fx:SetEntity(self.Weapon)
fx:SetNormal(self.Owner:GetAimVector())
fx:SetAttachment(self.ShellEjectAttachment)
util.Effect(self.ShellEffect,fx) -- Shell ejection
end)
if ((game.SinglePlayer() and SERVER) or (not game.SinglePlayer() and CLIENT)) then
local eyeang = self.Owner:EyeAngles()
eyeang.pitch = eyeang.pitch - recoil
self.Owner:SetEyeAngles(eyeang)
end
local trace = self.Owner:GetEyeTrace();
if trace.HitPos:Distance(self.Owner:GetShootPos()) > 250 or self.DestroyDoor == 0 then return end
if trace.Entity:GetClass() == "prop_door_rotating" and self.mode == "burst" and (SERVER) then
trace.Entity:Fire("open", "", 0.001)
trace.Entity:Fire("unlock", "", 0.001)
local pos = trace.Entity:GetPos()
local ang = trace.Entity:GetAngles()
local model = trace.Entity:GetModel()
local skin = trace.Entity:GetSkin()
local smoke = EffectData()
smoke:SetOrigin(pos)
util.Effect("effect_smokedoor", smoke)
trace.Entity:SetNotSolid(true)
trace.Entity:SetNoDraw(true)
local function ResetDoor(door, fakedoor)
door:SetNotSolid(false)
door:SetNoDraw(false)
fakedoor:Remove()
end
local norm = (pos - self.Owner:GetPos())
norm:Normalize()
local push = 10000 * norm
local ent = ents.Create("prop_physics")
ent:SetPos(pos)
ent:SetAngles(ang)
ent:SetModel(model)
if(skin) then
ent:SetSkin(skin)
end
ent:Spawn()
timer.Simple(0.01, function() if ent and push then ent:GetPhysicsObject():SetVelocity(push) end end)
timer.Simple(0.01, ent:GetPhysicsObject().ApplyForceCenter, ent:GetPhysicsObject(), push)
timer.Simple(25, ResetDoor, trace.Entity, ent)
end
end
But before the door, would just stay in its position when i shot it, now it goes flying off!
[QUOTE=buu342;38436075]same error
[ERROR] bad argument #1 to '?' (PhysObj expected, got no value)
1. unknown - [C]:-1
Timer Failed! [Simple][@lua/weapons/weapon_real_spas/shared.lua (line 450)]
Here is most of the script:
/*---------------------------------------------------------
ShootBullet
---------------------------------------------------------*/
function SWEP:CSShootBullet(dmg, recoil, numbul, cone)
numbul = numbul or 1
cone = cone or 0.01
local bullet = {}
bullet.Num = numbul
bullet.Src = self.Owner:GetShootPos() -- Source
bullet.Dir = self.Owner:GetAimVector() -- Dir of bullet
bullet.Spread = Vector(cone, cone, 0) -- Aim Cone
bullet.Tracer = 1 -- Show a tracer on every x bullets
bullet.Force = 2000 -- Amount of force to give to phys objects
bullet.Damage = 20 -- Amount of damage to give to the bullets
bullet.Callback = HitImpact
-- bullet.Callback = function ( a, b, c ) BulletPenetration( 0, a, b, c ) end -- CALL THE FUNCTION BULLETPENETRATION
self.Owner:FireBullets(bullet) -- Fire the bullets
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) -- View model animation
self.Owner:MuzzleFlash() -- Crappy muzzle light
self.Owner:SetAnimation(PLAYER_ATTACK1) -- 3rd Person Animation
local fx = EffectData()
fx:SetEntity(self.Weapon)
fx:SetOrigin(self.Owner:GetShootPos())
fx:SetNormal(self.Owner:GetAimVector())
fx:SetAttachment(self.MuzzleAttachment)
util.Effect(self.MuzzleEffect,fx) -- Additional muzzle effects
timer.Simple( self.EjectDelay, function()
if not IsFirstTimePredicted() then
return
end
local fx = EffectData()
fx:SetEntity(self.Weapon)
fx:SetNormal(self.Owner:GetAimVector())
fx:SetAttachment(self.ShellEjectAttachment)
util.Effect(self.ShellEffect,fx) -- Shell ejection
end)
if ((game.SinglePlayer() and SERVER) or (not game.SinglePlayer() and CLIENT)) then
local eyeang = self.Owner:EyeAngles()
eyeang.pitch = eyeang.pitch - recoil
self.Owner:SetEyeAngles(eyeang)
end
local trace = self.Owner:GetEyeTrace();
if trace.HitPos:Distance(self.Owner:GetShootPos()) > 250 or self.DestroyDoor == 0 then return end
if trace.Entity:GetClass() == "prop_door_rotating" and self.mode == "burst" and (SERVER) then
trace.Entity:Fire("open", "", 0.001)
trace.Entity:Fire("unlock", "", 0.001)
local pos = trace.Entity:GetPos()
local ang = trace.Entity:GetAngles()
local model = trace.Entity:GetModel()
local skin = trace.Entity:GetSkin()
local smoke = EffectData()
smoke:SetOrigin(pos)
util.Effect("effect_smokedoor", smoke)
trace.Entity:SetNotSolid(true)
trace.Entity:SetNoDraw(true)
local function ResetDoor(door, fakedoor)
door:SetNotSolid(false)
door:SetNoDraw(false)
fakedoor:Remove()
end
local norm = (pos - self.Owner:GetPos())
norm:Normalize()
local push = 10000 * norm
local ent = ents.Create("prop_physics")
ent:SetPos(pos)
ent:SetAngles(ang)
ent:SetModel(model)
if(skin) then
ent:SetSkin(skin)
end
ent:Spawn()
timer.Simple(0.01, function() if ent and push then ent:GetPhysicsObject():SetVelocity(push) end end)
timer.Simple(0.01, ent:GetPhysicsObject().ApplyForceCenter, ent:GetPhysicsObject(), push)
timer.Simple(25, ResetDoor, trace.Entity, ent)
end
end
But before the door, would just stay in its position when i shot it, now it goes flying off![/QUOTE]
I told you you have to apply the same fix as I did for the other timers...
[QUOTE=Leystryku;38436121]I told you you have to apply the same fix as I did for the other timers...[/QUOTE]
Oh ok...
Sorry, you need to Log In to post a reply to this thread.