Author Topic: Lua error on poltergeist.  (Read 91 times)

0 Members and 1 Guest are viewing this topic.

Offline MIKE2050

  • *
  • Posts: 8
  • Respect: +3
Lua error on poltergeist.
« on: December 25, 2013, 06:02:09 AM »
0
I get this error and then get kicked, whenever someone fires a shot.

Code: [Select]
[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

Here's the .lua:
Code: [Select]
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

Thank you in advance and merry christmas.

Offline coolzeldad

  • ******
  • OwnerDonatorOld Forum MemberrNd DeveloperLinux UserWindows UserDog LoverLeague PlayerDWO Player
    View More Badges!

  • Posts: 3333
  • I eat ddos for breakfast OMNOMONOM
  • Respect: +2711
    • .:`=-~rANdOm~`-=:. Game Servers
Re: Lua error on poltergeist.
« Reply #1 on: December 26, 2013, 09:02:47 PM »
0
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.
 ▲
▲▲Big thanks to Marie for this awesome sprite! :3

Spoiler: Moar Imagez (click to show/hide)
pingaz
Thanks Cryptokid!

Thanks gamefreak!


-- My youtube: http://www.youtube.com/coolzeldad
-- My deviantart: http://coolzeldad.deviantart.com
-- My soundcloud: http://www.soundcloud.com/coolzeldad
-- My ustream: http://www.ustream.tv/channel/coolzeldapingaz
-- My twitchtv: http://www.twitch.tv/coolzeldad

-- rNd Wiki: http://wiki.randomgs.com
-- rNd Youtube: http://www.youtube.com/RandomgsProductions
-- rNd Steam Group: http://steamcommunity.com/groups/r_A_N_d_O_m

Spoiler: rNd Typography (click to show/hide)





Every time you download Garry's Mod illegally, Garry makes a bug.

When people ask me "Plz" because its shorter than "Please" I feel perfectly justified to answer "No" because its shorter than "Yes".

derp herp lerp perp kerp serp zerp - say faiv timez fazt


Offline MIKE2050

  • *
  • Posts: 8
  • Respect: +3
Re: Lua error on poltergeist.
« Reply #2 on: January 01, 2014, 09:57:50 PM »
+1
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!