• Use a table to decide the spawns(theres a catch)
    1 replies, posted
Pretty basic. I'm using a table but, I'm not sure if I using it correctly. I know its wrong because we I use ls_spawn gives me an error about set angles trying to use a table. [code] LastStand\gamemode\server/sv_zombies.lua:34: bad argument #1 to 'SetAngles' (Angle expected, got table) [/code] [lua] local Zombies = { { pos = Vector(362, 162, -622), ang = Angle(0.000, 180.000, 0.000)}, { pos = Vector(363, 302, -623), ang = Angle(0.000, 180.000, 0.000)}, } local ZombieSpawns = { } function AddZombieSpawn(pl, cmd, args) if( !pl:IsSuperAdmin() ) then return pl:ChatPrint( "Unable." ) end local tr = pl:GetEyeTrace() local tren = tr.Entity; local pos = tren:GetPos() local Spawn = {} Spawn["x"] = math.ceil(pos.x); Spawn["y"] = math.ceil(pos.y); Spawn["z"] = math.ceil(pos.z); pl:ChatPrint( "Zombie Spawn Added" ) table.insert(ZombieSpawns, Spawn); local keys = util.TableToKeyValues(ZombieSpawns); file.Write("LastStand/MapData/" .. game.GetMap() .. ".txt", keys); end concommand.Add("i_zombie_add", AddZombieSpawn) function LoadZombieSpawn() if(file.Exists("LastStand/MapData/" .. game.GetMap() .. ".txt")) then local rawdata = file.Read("LastStand/MapData/" .. game.GetMap() .. ".txt"); local tabledata = util.KeyValuesToTable(rawdata); ZombieSpawns = tabledata; end end function SpawnZombie( ) for k, v in pairs( Zombies ) do Zombie = ents.Create( "npc_zombie" ) Zombie:SetAngles(ZombieSpawns) Zombie:SetPos(0.000, 180.000, 0.000) Zombie:SetCollisionGroup( COLLISION_GROUP_WEAPON ) timer.Simple( 10, function() if Zombie:IsValid() then Zombie:SetCollisionGroup( COLLISION_GROUP_NONE ) end end ) Zombie:SetModel("models/player/zombiefast.mdl") Zombie:Spawn() Zombie:Activate() Zombie:DropToFloor() end end concommand.Add("ls_spawn", SpawnZombie) [/lua]
[code] local zombieangle = table.Random(ZombieSpawns) Zombie:SetAngles(Angle(zombieangle.x, zombieangle.y, zombieangle.z)) [/code]
Sorry, you need to Log In to post a reply to this thread.