wait while using threads

fsociety_

Известный
Автор темы
56
6
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

Известный
371
306
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/
 
  • Нравится
Реакции: fsociety_

fsociety_

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