WASSIm. Posted January 31, 2017 Share Posted January 31, 2017 Hi guys, when i start script makes server high ping +2000 and keep show this in console [18:36:28] ERROR: Infinite/too long execution (ZA-zombies) [18:36:28] ERROR: ZA-zombies/server.lua:25: Aborting; infinite running script in ZA-zombies --RESOURCE START/INITIAL SETUP addEventHandler("onResourceStart", resourceRoot, function ( ) for _,thePlayer in ipairs(getElementsByType("player")) do bindKey(thePlayer, "fire", "down", function(source) local target = getPedTarget(source) if (target) and (getElementType(target) == "player") then setZombieBitten(source, target) end end) end setTimer(setangle, ZombieSpeedCheck, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION setTimer(triggerEvent, 2000, 0, "onCheckZombie", root) --Clear far zombies & Spawns zombies in random locations end) 1 Link to comment
Amine#TN Posted January 31, 2017 Share Posted January 31, 2017 (edited) bad argument in consol or not 7 minutes ago, A.mine said: bad argument Edited January 31, 2017 by Amine#TN Link to comment
Captain Cody Posted January 31, 2017 Share Posted January 31, 2017 25 : | Which line in the code you posted here represents line 25? Link to comment
WASSIm. Posted February 1, 2017 Author Share Posted February 1, 2017 17 hours ago, CodyJ(L) said: 25 : | Which line in the code you posted here represents line 25? Line 14 Link to comment
pa3ck Posted February 1, 2017 Share Posted February 1, 2017 I don't see any reason why would it be an infinite loop, would you be able to post "onCheckZombie" event handler function? Link to comment
Captain Cody Posted February 2, 2017 Share Posted February 2, 2017 It is indeed likely the onCheckZombie function, nothing here looks to be causing that. Link to comment
WASSIm. Posted February 2, 2017 Author Share Posted February 2, 2017 19 hours ago, CodyJ(L) said: It is indeed likely the onCheckZombie function, nothing here looks to be causing that. Problem from setTimer Link to comment
marty000123 Posted February 4, 2017 Share Posted February 4, 2017 Maybe you should put a zombie limit. Link to comment
Captain Cody Posted February 4, 2017 Share Posted February 4, 2017 Post the event onCheckZombie Link to comment
WASSIm. Posted February 4, 2017 Author Share Posted February 4, 2017 5 hours ago, CodyJ(L) said: Post the event onCheckZombie addEvent("onCheckZombie", true ) addEventHandler("onCheckZombie", root, function () -- Create zombies closed randomly players local pacecount = 0 while pacecount < 5*2 do --4 ZOMBIES AT A TIME TO PREVENT FPS DROP local tzombiecount = #everyZombie+pacecount if (tzombiecount < ZombieLimit) then local thePlayer = getRandomPlayer() if (thePlayer) and (exports["ZA-system"]:isPlayerLogin(thePlayer)) and not (getElementData(thePlayer, "zombieProof")) and not (isPedDead(thePlayer)) then local disc, angle = math.random(15, 50), math.random(360) local gx, gy = getDistanceRotation(0, 0, disc, angle) if not (hasPositionZombieProof(gx, gy)) then triggerClientEvent(thePlayer, "onClientPreZombieSpawn", thePlayer, gx, gy) pacecount = pacecount+1 end end end end -- Delete far away zombies local allplayers, listCloseZ = getElementsByType("player"), {} for ZombKey,theZomb in ipairs(everyZombie) do if (isZombie(theZomb)) and not (getElementData(theZomb, "forcedtoexist")) then local Zx, Zy, Zz = getElementPosition(theZomb) for _,thePlayer in ipairs(allplayers) do if (exports["ZA-system"]:isElementInRange(thePlayer, Zx, Zy, Zz, 75)) and not (listCloseZ[theZomb]) then listCloseZ[theZomb] = true end end if not (listCloseZ[theZomb]) then destroyElement(theZomb) end end end end) Link to comment
pa3ck Posted February 4, 2017 Share Posted February 4, 2017 Well I can see a "possible" infinite loop. See the way you have this line: if (tzombiecount < ZombieLimit) then If that evaluates to false, you will never actually increment "pacecount" (will always stay 0) leaving it always less than 5*2. Link to comment
Captain Cody Posted February 4, 2017 Share Posted February 4, 2017 Try this and see if it ever stops outputting. local pacecount = 0 while pacecount < 5*2 do --4 ZOMBIES AT A TIME TO PREVENT FPS DROP print(pacecount) local tzombiecount = #everyZombie+pacecount if (tzombiecount < ZombieLimit) then print(1) local thePlayer = getRandomPlayer() if (thePlayer) and (exports["ZA-system"]:isPlayerLogin(thePlayer)) and not (getElementData(thePlayer, "zombieProof")) and not (isPedDead(thePlayer)) then local disc, angle = math.random(15, 50), math.random(360) local gx, gy = getDistanceRotation(0, 0, disc, angle) print(2) if not (hasPositionZombieProof(gx, gy)) then print(3) triggerClientEvent(thePlayer, "onClientPreZombieSpawn", thePlayer, gx, gy) pacecount = pacecount+1 end end end end If not then there's your issue. Link to comment
WASSIm. Posted February 5, 2017 Author Share Posted February 5, 2017 Now is it and server freezed [2017-02-05 22:06:55] ADMIN: Resource 'ZA-zombies' started by ZA|WASSIm.(wassmas) [2017-02-05 22:06:56] INFO: :ZA-zombies/server.lua: Successfully compiled [2017-02-05 22:07:00] INFO: 0 [2017-02-05 22:07:00] INFO: 1 [2017-02-05 22:07:05] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:06] INFO: 0 [DUP x8187] [2017-02-05 22:07:06] INFO: 1 [DUP x8187] [2017-02-05 22:07:06] INFO: 0 [2017-02-05 22:07:06] INFO: 1 [2017-02-05 22:07:10] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:12] INFO: 0 [DUP x9581] [2017-02-05 22:07:12] INFO: 1 [DUP x9581] [2017-02-05 22:07:12] INFO: 0 [2017-02-05 22:07:12] INFO: 1 [2017-02-05 22:07:12] INFO: 0 [2017-02-05 22:07:15] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:18] INFO: 1 [DUP x9524] [2017-02-05 22:07:18] INFO: 0 [DUP x9524] [2017-02-05 22:07:18] INFO: 1 [2017-02-05 22:07:18] INFO: 0 [2017-02-05 22:07:18] INFO: 1 [2017-02-05 22:07:20] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:24] INFO: 0 [DUP x9612] [2017-02-05 22:07:24] INFO: 1 [DUP x9612] [2017-02-05 22:07:24] INFO: 0 [2017-02-05 22:07:24] INFO: 1 [2017-02-05 22:07:24] INFO: 0 [2017-02-05 22:07:25] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:30] INFO: 1 [DUP x9586] [2017-02-05 22:07:30] INFO: 0 [DUP x9586] [2017-02-05 22:07:30] INFO: 1 [2017-02-05 22:07:30] INFO: 0 [2017-02-05 22:07:30] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:35] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:36] INFO: 1 [DUP x9705] [2017-02-05 22:07:36] INFO: 0 [DUP x9705] [2017-02-05 22:07:36] INFO: 1 [2017-02-05 22:07:36] INFO: 0 [2017-02-05 22:07:36] INFO: 1 [2017-02-05 22:07:40] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:42] INFO: 0 [DUP x9625] [2017-02-05 22:07:42] INFO: 1 [DUP x9625] [2017-02-05 22:07:42] INFO: 0 [2017-02-05 22:07:42] INFO: 1 [2017-02-05 22:07:42] INFO: 0 [2017-02-05 22:07:45] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:48] INFO: 1 [DUP x9708] [2017-02-05 22:07:48] INFO: 0 [DUP x9708] [2017-02-05 22:07:48] INFO: 1 [2017-02-05 22:07:48] INFO: 0 [2017-02-05 22:07:48] INFO: 1 [2017-02-05 22:07:50] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:54] INFO: 0 [DUP x9644] [2017-02-05 22:07:54] INFO: 1 [DUP x9644] [2017-02-05 22:07:54] INFO: 0 [2017-02-05 22:07:54] INFO: 1 [2017-02-05 22:07:54] WARNING: Long execution (ZA-zombies) [2017-02-05 22:07:59] WARNING: Long execution (ZA-zombies) [2017-02-05 22:08:00] INFO: 0 [DUP x9702] [2017-02-05 22:08:00] INFO: 1 [DUP x9702] [2017-02-05 22:08:00] INFO: 0 [2017-02-05 22:08:00] INFO: 1 [2017-02-05 22:08:00] INFO: 0 [2017-02-05 22:08:04] WARNING: Long execution (ZA-zombies) [2017-02-05 22:08:06] INFO: 1 [DUP x9605] [2017-02-05 22:08:06] INFO: 0 [DUP x9605] [2017-02-05 22:08:06] INFO: 1 [2017-02-05 22:08:06] INFO: 0 [2017-02-05 22:08:06] INFO: 1 [2017-02-05 22:08:09] WARNING: Long execution (ZA-zombies) [2017-02-05 22:08:12] INFO: 0 [DUP x9606] [2017-02-05 22:08:12] INFO: 1 [DUP x9606] [2017-02-05 22:08:12] INFO: 0 [2017-02-05 22:08:12] INFO: 1 [2017-02-05 22:08:12] INFO: 0 [2017-02-05 22:08:14] WARNING: Long execution (ZA-zombies) [2017-02-05 22:08:18] INFO: 1 [DUP x9527] [2017-02-05 22:08:18] INFO: 0 [DUP x9527] [2017-02-05 22:08:18] INFO: 1 [2017-02-05 22:08:18] INFO: 0 [2017-02-05 22:08:18] WARNING: Long execution (ZA-zombies) [2017-02-05 22:08:23] WARNING: Long execution (ZA-zombies) [2017-02-05 22:08:24] INFO: 1 [DUP x9555] [2017-02-05 22:08:24] INFO: 0 [DUP x9555] [2017-02-05 22:08:24] INFO: 1 [2017-02-05 22:08:24] INFO: 0 Link to comment
pa3ck Posted February 5, 2017 Share Posted February 5, 2017 Then this is the problem: if (thePlayer) and (exports["ZA-system"]:isPlayerLogin(thePlayer)) and not (getElementData(thePlayer, "zombieProof")) and not (isPedDead(thePlayer)) then Anything is after this line will be skipped. So think about this... 1st cycle = while 0 < 5*2 -> true 2nd cycle = while 0 < 5*2 -> true 3rd cycle = while 0 < 5*2 -> true 9999999999999th cycle = while 0 < 5*2 -> true "pacecount" is not changing, so it's an infinite loop. Link to comment
WASSIm. Posted February 5, 2017 Author Share Posted February 5, 2017 So i need do this ?? -- Create zombies closed randomly players local pacecount = 0 while pacecount < 5 do --4 ZOMBIES AT A TIME TO PREVENT FPS DROP local tzombiecount = #everyZombie+pacecount if (tzombiecount < ZombieLimit) then local thePlayer = getRandomPlayer() if (thePlayer) and (exports["ZA-system"]:isPlayerLogin(thePlayer)) and not (getElementData(thePlayer, "zombieProof")) and not (isPedDead(thePlayer)) then local disc, angle = math.random(15, 50), math.random(360) local gx, gy = getDistanceRotation(0, 0, disc, angle) if not (hasPositionZombieProof(gx, gy)) then triggerClientEvent(thePlayer, "onClientPreZombieSpawn", thePlayer, gx, gy) pacecount = pacecount+1 end end end pacecount = pacecount+1 end Link to comment
pa3ck Posted February 5, 2017 Share Posted February 5, 2017 That should work, yea. But you might want to remove the first pacecount = pacecount +1 otherwise sometimes it will run twice and add 2 instead of 1. Link to comment
WASSIm. Posted February 5, 2017 Author Share Posted February 5, 2017 Thank you and thank you all guys 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