Jump to content

ERROR Infinite/too long executio


WASSIm.

Recommended Posts

 

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)

 

  • Like 1
Link to comment
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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...