Criley54 Posted October 11, 2017 Share Posted October 11, 2017 I have the old version of DayZ uncompiled as I like it, I need to create more zombies than just three spawning or two, how would I do it? This is my createZombie function function createZombieTable(player) setElementData(player, "playerZombies", { "no", "no", "no", "no", "no", "no", "no", "no", "no" }) setElementData(player, "spawnedzombies", 0) end function createZomieForPlayer(x, y, z) x, y, z = getElementPosition(source) counter = 0 if getElementData(source, "lastzombiespawnposition") then local xL, yL, zL = getElementData(source, "lastzombiespawnposition")[3] or getElementData(source, "lastzombiespawnposition")[1] or false, getElementData(source, "lastzombiespawnposition")[2] or false, false if xL and getDistanceBetweenPoints3D(x, y, z, xL, yL, zL) < 50 then return end end if getElementData(source, "spawnedzombies") + 3 <= 9 then for i = 1, 3 do counter = counter + 1 local number1 = math.random(-50, 50) local number2 = math.random(-50, 50) if number1 < 18 and number1 > -18 then number1 = 20 end if number2 < 18 and number2 > -18 then number2 = -20 end randomZskin = math.random(1, table.getn(ZombiePedSkins)) zombie = call(getResourceFromName("slothbot"), "spawnBot", x + number1, y + number2, z, math.random(0, 360), ZombiePedSkins[randomZskin], 0, 0, getTeamFromName("Zombies")) setElementData(zombie, "zombie", true) setElementData(zombie, "blood", 4500) setElementData(zombie, "owner", source) call(getResourceFromName("slothbot"), "setBotGuard", zombie, x + number1, y + number2, z, false) end setElementData(source, "lastzombiespawnposition", { x, y, z }) setElementData(source, "spawnedzombies", getElementData(source, "spawnedzombies") + 3) end end addEvent("createZomieForPlayer", true) addEventHandler("createZomieForPlayer", getRootElement(), createZomieForPlayer) Link to comment
Criley54 Posted October 11, 2017 Author Share Posted October 11, 2017 I keep getting https://i.gyazo.com/6d66e3b363ce480f983e7476899edf9f.png Link to comment
AE. Posted October 11, 2017 Share Posted October 11, 2017 10 minutes ago, Criley54 said: I keep getting https://i.gyazo.com/6d66e3b363ce480f983e7476899edf9f.png did you change something? then this appeared if you did post what you changed Link to comment
Criley54 Posted October 11, 2017 Author Share Posted October 11, 2017 (edited) I changed the for i = 1, 3 do to for i = 1, 20 do and they're not respawning? just spawning, I kill them and not coming back? Edited October 11, 2017 by Criley54 Link to comment
AE. Posted October 11, 2017 Share Posted October 11, 2017 1 minute ago, Criley54 said: I changed the for i = 1, 3 do to for i = 1, 20 do and they're not respawning? just spawning, I kill them and not coming back? if getElementData(source, "spawnedzombies") + 3 <= 21 then Link to comment
Criley54 Posted October 11, 2017 Author Share Posted October 11, 2017 Well this is my current code and they aren't respawning function createZombieTable(player) setElementData(player, "playerZombies", { "no", "no", "no", "no", "no", "no", "no", "no", "no" }) setElementData(player, "spawnedzombies", 0) end function createZomieForPlayer(x, y, z) x, y, z = getElementPosition(source) counter = 0 if getElementData(source, "lastzombiespawnposition") then local xL, yL, zL = getElementData(source, "lastzombiespawnposition")[3] or getElementData(source, "lastzombiespawnposition")[1] or false, getElementData(source, "lastzombiespawnposition")[2] or false, false if xL and getDistanceBetweenPoints3D(x, y, z, xL, yL, zL) < 50 then return end end if getElementData(source, "spawnedzombies") + 3 <= 275 then for i = 1, 276 do counter = counter + 1 local number1 = math.random(-50, 50) local number2 = math.random(-50, 50) if number1 < 18 and number1 > -18 then number1 = 20 end if number2 < 18 and number2 > -18 then number2 = -20 end randomZskin = math.random(1, table.getn(ZombiePedSkins)) zombie = call(getResourceFromName("slothbot"), "spawnBot", x + number1, y + number2, z, math.random(0, 360), ZombiePedSkins[randomZskin], 0, 0, getTeamFromName("Zombies")) setElementData(zombie, "zombie", true) setElementData(zombie, "blood", 4500) setElementData(zombie, "owner", source) call(getResourceFromName("slothbot"), "setBotGuard", zombie, x + number1, y + number2, z, false) end setElementData(source, "lastzombiespawnposition", { x, y, z }) setElementData(source, "spawnedzombies", getElementData(source, "spawnedzombies") + 275) end end addEvent("createZomieForPlayer", true) addEventHandler("createZomieForPlayer", getRootElement(), createZomieForPlayer) function zombieCheck1() for i, ped in ipairs(getElementsByType("ped")) do if getElementData(ped, "zombie") then goReturn = false local zombieCreator = getElementData(ped, "owner") if not isElement(zombieCreator) then outputDebugString("test") setElementData(ped, "status", "dead") setElementData(ped, "target", nil) setElementData(ped, "leader", nil) destroyElement(ped) goReturn = true end if not goReturn then local xZ, yZ, zZ = getElementPosition(getElementData(ped, "owner")) local x, y, z = getElementPosition(ped) if getDistanceBetweenPoints3D(x, y, z, xZ, yZ, zZ) > 60 then if getElementData(zombieCreator, "spawnedzombies") - 1 >= 0 then setElementData(zombieCreator, "spawnedzombies", getElementData(zombieCreator, "spawnedzombies") - 1) end setElementData(ped, "status", "dead") setElementData(ped, "target", nil) setElementData(ped, "leader", nil) destroyElement(ped) end end end end end setTimer(zombieCheck1, 5000, 0) Link to comment
AE. Posted October 11, 2017 Share Posted October 11, 2017 if getElementData(source, "spawnedzombies") + 150 <= 320 then this is too much btw Link to comment
Criley54 Posted October 11, 2017 Author Share Posted October 11, 2017 How would I shorten it all to 10 zombies per player and they respawn? because they are currently not respawning still Link to comment
AE. Posted October 11, 2017 Share Posted October 11, 2017 The first code spawns 9 zombies :3 Link to comment
Criley54 Posted October 11, 2017 Author Share Posted October 11, 2017 It didn't really though it was spawning 3 and they wasn't respawning Link to comment
Criley54 Posted October 12, 2017 Author Share Posted October 12, 2017 (edited) I keep getting https://i.gyazo.com/241f5d229f4de63018ce02a1dc5a7a5c.png and my points are : function createZomieForPlayer(x, y, z) x, y, z = getElementPosition(source) counter = 0 if getElementData(source, "lastzombiespawnposition") then local xL, yL, zL = getElementData(source, "lastzombiespawnposition")[3] or getElementData(source, "lastzombiespawnposition")[1] or false, getElementData(source, "lastzombiespawnposition")[2] or false, false if xL and getDistanceBetweenPoints3D(x, y, z, xL, yL, zL) < 60 then ---- RIGHT HERE return end end if getElementData(source, "spawnedzombies") + 3 <= 21 then for i = 1, 20 do counter = counter + 1 local number1 = math.random(-50, 50) local number2 = math.random(-50, 50) if number1 < 18 and number1 > -18 then number1 = 20 end if number2 < 18 and number2 > -18 then number2 = -20 end randomZskin = math.random(1, table.getn(ZombiePedSkins)) zombie = call(getResourceFromName("slothbot"), "spawnBot", x + number1, y + number2, z, math.random(0, 360), ZombiePedSkins[randomZskin], 0, 0, getTeamFromName("Zombies")) setElementData(zombie, "zombie", true) setElementData(zombie, "blood", 4500) setElementData(zombie, "owner", source) call(getResourceFromName("slothbot"), "setBotGuard", zombie, x + number1, y + number2, z, false) end setElementData(source, "lastzombiespawnposition", { x, y, z }) setElementData(source, "spawnedzombies", getElementData(source, "spawnedzombies") + 3) end end addEvent("createZomieForPlayer", true) addEventHandler("createZomieForPlayer", getRootElement(), createZomieForPlayer) addEventHandler("createZomieForPlayer", getRootElement(), createZomieForPlayer) function zombieCheck1() for i, ped in ipairs(getElementsByType("ped")) do if getElementData(ped, "zombie") then goReturn = false local zombieCreator = getElementData(ped, "owner") if not isElement(zombieCreator) then outputDebugString("test") setElementData(ped, "status", "dead") setElementData(ped, "target", nil) setElementData(ped, "leader", nil) destroyElement(ped) goReturn = true end if not goReturn then local xZ, yZ, zZ = getElementPosition(getElementData(ped, "owner")) local x, y, z = getElementPosition(ped) if getDistanceBetweenPoints3D(x, y, z, xZ, yZ, zZ) > 50 then --- RIGHT HERE if getElementData(zombieCreator, "spawnedzombies") - 1 >= 0 then setElementData(zombieCreator, "spawnedzombies", getElementData(zombieCreator, "spawnedzombies") - 1) end setElementData(ped, "status", "dead") setElementData(ped, "target", nil) setElementData(ped, "leader", nil) destroyElement(ped) end end end end end setTimer(zombieCheck1, 5000, 0) They are if xL and getDistanceBetweenPoints3D(x, y, z, xL, yL, zL) < 60 then if getDistanceBetweenPoints3D(x, y, z, xZ, yZ, zZ) > 50 then Edited October 12, 2017 by Criley54 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