wait while using threads

AgentM

Известный
Автор темы
56
5
So i got something like this:

Lua:
function event.onPlayerSync(playerId, data)
    lua_thread.create(function()
        if data.weapon == 0 then
        -- do something
        wait(10000)
        end
    end)
end

The problem is that it won't wait 10 seconds because of the thread create.
 

stool

Известный
273
181
Use os.clock
Set the global variable outside the hook and check if its greater than os.clock() + 10. If its not then set it to new os clock value, otherwise don't execute the rest of the hooks function.

Also please use specialised forum: https://www.blast.hk/forums/116/
 
  • Нравится
Реакции: AgentM

AgentM

Известный
Автор темы
56
5
  • Нравится
Реакции: stool