What i'm trying to do is get a zombie, and also get its spawn at the same time, and to create a new zombie after that, I didn't want to make a script for each one, which could cause problems later on.
[B]Init.lua[/B]
[CODE]42: SpawnLocation = ents.FindByName("ZombieSpawn")
43: Zombie = {}
44:
45: function SpawnZ()
46: for I = 1, #SpawnLocation, 1 do
47: Zombie[I] = ents.Create("npc_zombie")
48: Zombie[I]:SetPos(SpawnLocation[I]:GetPos())
49: Zombie[I]:Spawn()
50: end
51: end
52:
53: function NPCDied(Victim, Killer, Weapon)
54: if Victim:GetClass() == "npc_zombie" then
55: for i = 1, #Zombie, 1 do
56: if Zombie[i]:Health() == 0 then
57: Msg("Zombie Died, Making Another!\n")
58: Zombie[i]
59: Zombie[i]:SetPos(SpawnLocation[i]:GetPos())
60: Zombie[i]:Spawn()
61: end
62: end
63: end
64: end[/CODE]
[B]Output Error[/B]
[CODE][ERROR] gamemodes/solitude/gamemode/init.lua:59: '=' expected near 'Zombie'
1. unknown - gamemodes/solitude/gamemode/init.lua:0
Couldn't Load Init Script: 'solitude/gamemode/init.lua'
[[/CODE]
[editline]25th November 2012[/editline]
Does really no one know?
You just put a random "Zombie[i]" in the middle of your script. I'm going to take a guess and say that's the issue.
Zombie[i] Equals "ents.Create("npc_zombie")"
The purpose to that was to create another zombie, but on the same value. I could try to initialize the value to the same thing, it wouldn't matter.
[editline]25th November 2012[/editline]
That problem was fixed, but now some other issues.
[B]Output Error[/B]
[CODE]
[ERROR] gamemodes/solitude/gamemode/init.lua:53: attempt to get length of global 'Zombie' (a userdata value)
1. v - gamemodes/solitude/gamemode/init.lua:53
2. unknown - lua/includes/modules/hook.lua:75
[/CODE]
[B]Init.lua[/B]
[CODE]42: SpawnLocation = ents.FindByName("ZombieSpawn")
43: Zombie = {}
44:
45: for I = 1, #SpawnLocation, 1 do
46: Zombie[I] = ents.Create("npc_zombie")
47: Zombie[I]:SetPos(SpawnLocation[I]:GetPos())
48: Zombie[I]:Spawn()
49: end
50:
51: function NPCDied(Victim, Killer, Weapon)
52: if Victim:GetClass() == "npc_zombie" then
53: for i = 1, #Zombie, 1 do
54: if Zombie[i]:Health() == 0 then
55: Msg("Zombie Died, Making Another!\n")
56: Zombie[i] = ents.Create("npc_zombie")
57: Zombie[i]:SetPos(SpawnLocation[i]:GetPos())
58: Zombie[i]:Spawn()
59: end
60: end
61: end
62: end[/CODE]
I know that on Line 53, that it says nil, it's because the zombies arn't spawning.
[editline]25th November 2012[/editline]
Found the problem, the values apperently need to be inside the function.
Sorry, you need to Log In to post a reply to this thread.