[B]Init.lua[/B]
[CODE]function RespawnPoisonZombie(Index)
PoisonZombie[Index] = ents.Create("npc_poisonzombie")
PoisonZombie[Index]:SetPos(PoisonZombieSpawn[Index]:GetPos())
PoisonZombie[Index]:Spawn()
end
function RespawnFastZombie(Index)
FastZombie[Index] = ents.Create("npc_fastzombie")
FastZombie[Index]:SetPos(FastZombieSpawn[Index]:GetPos())
FastZombie[Index]:Spawn()
end
function RespawnZombie(Index)
Zombie[Index] = ents.Create("npc_zombie")
Zombie[Index]:SetPos(ZombieSpawn[Index]:GetPos())
Zombie[Index]:Spawn()
end
function NPCDied(Victim, Killer, Weapon)
if Victim:GetClass() == "npc_zombie" then
for a = 1, #Zombie, 1 do
if Zombie[a]:Health() <= 0 then
timer.Create("Wait1", 10, 1, RespawnZombie, a)
end
end
end
if Victim:GetClass() == "npc_fastzombie" then
for b = 1, #FastZombie, 1 do
if FastZombie[b]:Health() <= 0 then
timer.Create("Wait2", 10, 1, RespawnFastZombie, b)
end
end
end
if Victim:GetClass() == "npc_poisonzombie" then
for c = 1, #PoisonZombie, 1 do
if PoisonZombie[c]:Health() <= 0 then
timer.Create("Wait3", 10, 1, RespawnPoisonZombie, c)
end
end
end
end
hook.Add("OnNPCKilled", "Test", NPCDied)[/CODE]
[B]Error[/B]
[CODE]
[ERROR] gamemodes/solitude/gamemode/init.lua:69: table index is nil
1. unknown - gamemodes/solitude/gamemode/init.lua:69
Timer Failed! [Wait2][@gamemodes/solitude/gamemode/init.lua (line 93)][/CODE]
Trying to pass on the index to the function, but is nil.
You need to set them a table first before you can index the.
Please, PLEASE, stop declaring all of your functions and variables as global. Also since you're not showing us the whole code we have to make way too many assumptions here. I could assume you properly defined PoisonZombie, FastZombie and Zombie but I'll have to ask. Did you define them before you started indexing them?
edit : About the timers, you're calling them wrong. You can't pass arguments anymore.
Sorry, you need to Log In to post a reply to this thread.