Halfmillz Posted May 24, 2013 Share Posted May 24, 2013 I use Zombie spawnpoint but all zombie spawn at the spawnpoint. how to spawn one zombie per spawnpoint until zombie dead and the new zombie spawn? this is spawnpoint script from zday zombie script function SpawnpointZombie () local pacecount = 0 while pacecount < 2 do --1 ZOMBIES AT A TIME TO PREVENT FPS DROP if (table.getn( everyZombie )+pacecount < newZombieLimit ) and (ZombieStreaming == 2) then local liveplayers = getAlivePlayers () if (table.getn( liveplayers ) > 0 ) then local lowestcount = 99999 local lowestguy = nil for PKey,thePlayer in ipairs(liveplayers) do --THIS PART GETS THE PLAYER WITH THE LEAST ZOMBIES ATTACKING if (getElementData (thePlayer, "dangercount")) and (getElementData(thePlayer, "zombieProof") ~= true) then if (getElementData (thePlayer, "dangercount") < lowestcount) then lowestguy = thePlayer lowestcount = getElementData (thePlayer, "dangercount") end end end if isElement(lowestguy) then local zombiespawns = { } local possiblezombies = getElementsByType ( "Zombie_spawn" ) local Px, Py, Pz = getElementPosition( lowestguy ) for ZombKey,theZomb in ipairs(possiblezombies) do local Zx, Zy, Zz = getElementPosition( theZomb ) local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )) if (distance < 10) or (isPedDead(theZomb) == false) then table.remove( possiblezombies, ZombKey) --IF SPAWN IS TOO CLOSE TO ANY PLAYER end end local Px, Py, Pz = getElementPosition( lowestguy ) for ZombKey2,theZomb2 in ipairs(possiblezombies) do local Zx, Zy, Zz = getElementPosition( theZomb2 ) local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )) if (distance < 65) then --AS LONG AS THE SPAWN IS CLOSE ENOUGH TO A PLAYER table.insert( zombiespawns, theZomb2 ) end end if (table.getn( zombiespawns ) >0 ) then--IF THE LOWEST PLAYER HAS ANY CLOSE SPAWNS,USE ONE local random = math.random ( 1, table.getn ( zombiespawns ) ) local posX = getElementData(zombiespawns[random], "posX") local posY = getElementData(zombiespawns[random], "posY") local posZ = getElementData(zombiespawns[random], "posZ") local rot = getElementData(zombiespawns[random], "rotZ") pacecount = pacecount+1 triggerEvent ( "onZombieSpawn",zombiespawns[random], posX, posY, posZ, rot ) else--IF THE LOWEST PLAYERS DOESNT HAVE ANY SPAWNS, THEN SEE IF ANYONE HAS ANY local zombiespawns = { } local possiblezombies = getElementsByType ( "Zombie_spawn" ) local allplayers = getAlivePlayers () for theKey,thePlayer in ipairs(allplayers) do local Px, Py, Pz = getElementPosition( thePlayer ) for ZombKey,theZomb in ipairs(possiblezombies) do local Zx, Zy, Zz = getElementPosition( theZomb ) local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )) if (distance < 10) or (isPedDead(theZomb) == false) then table.remove( possiblezombies, ZombKey) --IF SPAWN IS TOO CLOSE TO ANY PLAYER end end end for theKey,thePlayer in ipairs(allplayers) do local Px, Py, Pz = getElementPosition( thePlayer ) for ZombKey2,theZomb2 in ipairs(possiblezombies) do local Zx, Zy, Zz = getElementPosition( theZomb2 ) local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )) if (distance < 65) then --AS LONG AS THE SPAWN IS CLOSE ENOUGH TO A PLAYER table.insert( zombiespawns, theZomb2 ) end end end if (table.getn( zombiespawns ) >1 ) then local random = math.random ( 1, table.getn ( zombiespawns ) ) local posX = getElementData(zombiespawns[random], "posX") local posY = getElementData(zombiespawns[random], "posY") local posZ = getElementData(zombiespawns[random], "posZ") local rot = getElementData(zombiespawns[random], "rotZ") pacecount = pacecount+1 triggerEvent ( "onZombieSpawn",zombiespawns[random], posX, posY, posZ, rot ) else pacecount = pacecount+1 end end else pacecount = pacecount+1 end else pacecount = pacecount+1 end else pacecount = pacecount+1 end end end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now