Support (Read Only) > Help

Lua error on poltergeist.

(1/1)

MIKE2050:
I get this error and then get kicked, whenever someone fires a shot.


--- Code: ---[ERROR] gamemodes/poltergeist/entities/entities/prop_spawner/init.lua:37: bad argument #1 to 'AddAngleVelocity' (Vector expected, got userdata)
  1. AddAngleVelocity - [C]:-1
   2. SpawnProp - gamemodes/poltergeist/entities/entities/prop_spawner/init.lua:37
    3. unknown - gamemodes/poltergeist/entities/entities/prop_spawner/init.lua:23
--- End code ---

Here's the .lua:

--- Code: ---AddCSLuaFile( "shared.lua" )
include( "shared.lua" )

ENT.RespawnTime = 3

function ENT:Initialize()

end

function ENT:KeyValue( key, value )

if key == "frequency" then
self.RespawnTime = math.Clamp( tonumber( value ), 1, 60 )
end

end

function ENT:Think()

if ( self.Timer or 0 ) < CurTime() then
self.Timer = CurTime() + self.RespawnTime
self:SpawnProp()
end

end

function ENT:SpawnProp()

if table.Count( ents.FindByClass("prop_phys*") ) > 100 then return end

local prop = self.Entity:CreateProp( self:GetPos(), self:GetAngles(), table.Random( GAMEMODE.PropModels ) )

local phys = prop:GetPhysicsObject()

if phys and phys:IsValid() then
phys:AddAngleVelocity( ( VectorRand() * 200 ):Angle() )
end

end

function ENT:CreateProp( pos, ang, model )

local prop = ents.Create( "prop_physics" )
prop:SetPos( pos )
prop:SetAngles( ang )
prop:SetModel( model )
prop:Spawn()

return prop

end

function ENT:GetFrequency()
return self.RespawnTime
end
--- End code ---

Thank you in advance and merry christmas.

coolzeldad:
Garry's Mod 13 is more strict with types and some vector and angle functions have also been changed.

http://wiki.garrysmod.com/page/PhysObj/AddAngleVelocity

That function requires a vector as the argument, and it's being passed a vector:Angle(), so try passing just the vector.

Also, to prevent being kicked while debugging lua errors activate this command in your console or in listenserver.cfg/server.cfg/etc: sv_kickerrornum 0

I plan to make a thread sometime later where it will go into detail with Garry's Mod lua, converting gamemodes, etc. but for now I hope this helps.

MIKE2050:
Yes!! thanks you! that was so helpful.

I'm getting some other errors here and there, but i don't want to bug you anymore, that link you left is more than enough for me to fix them myself.

again, thanks a lot!

Navigation

[0] Message Index

Go to full version