MOON: How to call a Function inside the loop and not pause it

Asked

Viewed 85 times

1

I am facing a problem in a code that I am doing and the fact that I have learned for myself and in the bush I can’t deal with this problem.

Everything happens because I want to call a function and continue the mainloop, but so I call the Function inDeath() the mainloop for and awaits a break/Return from Function that has been called.

So my question is: there is how to call a Function and continue the loop(that called it) without waiting for a Return/break?

local isworking = false

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(100)
        print("RUNNING") -- tá rodando? Está
        if not isworking then
        isworking = true
        local ped = PlayerPedId() -- Entidade
           if GetEntityHealth(ped) <= 101 then -- Vida da entidade
              inDeath() -- função a ser chamada
           end
        end
        --[[RESTANTE DO CÓDIGO]]
    end
end)

function inDeath()
    local ped = PlayerPedId() -- Entidade
    while true do
        Citizen.Wait(1)
        if GetEntityHealth(ped) > 399 then -- Vida da entidade
            isworking = false
            break --stop function
        end
          --[[RESTANTE DO CÓDIGO/FUNCTION]]
    end
end
  • 1

    Learn about choirs in Lua

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.