[B]Init.lua[/B]
[CODE]SpawnLocation = ents.FindByName("ZombieSpawn")
Zombie = {}
function SpawnZombie()
for I = 1, #SpawnLocation, 1 do
Zombie[I] = ents.Create("npc_zombie")
Zombie[I]:SetPos(SpawnLocation[I]:GetPos())
Zombie[I]:Spawn()
end
end
function GM:PlayerInitialSpawn( ply )
if ply:IsAdmin() or ply:IsSuperAdmin() then
ply:SetTeam(1)
else
ply:SetTeam(2)
end
SpawnZombie()
end[/CODE]
The "SpawnZombie()" function won't even start, could someone help me on this?
do a print just before the SpawnZombie() call, does it print?
Do a print just before the loop inside the SpawnZombie function, does it print?
Well it doesn't work, when i printed out how many zombie spawns there where, it said there where 0 zombie spawns, when indeed in fact there was 2. It could be that it doesn't have enough time to load, where would a good place to put this piece of code?
[QUOTE=RedXVIII;38603795]Well it doesn't work, when i printed out how many zombie spawns there where, it said there where 0 zombie spawns, when indeed in fact there was 2. It could be that it doesn't have enough time to load, where would a good place to put this piece of code?[/QUOTE]
You want to detect the zombie spawns in InitPostEntity.
[LUA]local ZombieSpawnLocations -- It's important to declare it out of the function's scope so we can access it everywhere in the file.
function GM:InitPostEntity()
ZombieSpawnLocations = ents.FindByName("ZombieSpawn")
end
local Zombies = {} -- Always use local in front of variables and functions that are not meant to be available outside of that file.
local function SpawnZombies()
for i = 1, #ZombieSpawnLocations, 1 do -- lowercase i is the convention.
Zombie[i] = ents.Create("npc_zombie")
Zombie[i]:SetPos(ZombieSpawnLocations[i]:GetPos())
Zombie[i]:SetAngles(ZombieSpawnLocations[i]:GetAngles()) -- You can have your zombies facing the same direction as the spawn.
Zombie[i]:Spawn()
end
end
function GM:PlayerInitialSpawn( ply )
if ply:IsAdmin() or ply:IsSuperAdmin() then
ply:SetTeam(1)
else
ply:SetTeam(2)
end
SpawnZombies() -- Are you sure you want to spawn zombies every time a player joins? This might belong in InitPostEntity or in a zombie spawning module.
end[/lua]
Sorry, you need to Log In to post a reply to this thread.