Jump to content

Why timer is inaccurate?


Recommended Posts

Ok.

client side:

addEventHandler("onClientPlayerWasted", localPlayer, function()
  setTimer(function(source)
  	triggerServerEvent("spawnWastedPlayer", resourceRoot, source)
  end, 60000, 1, source)
end)

server side

addEvent("spawnWastedPlayer", true)
addEventHandler("spawnWastedPlayer", resourceRoot, function(source)
    spawnPlayer(source, 0, 0, 0)
end)

why practically never waiting for a spawn takes 1 minute, but it's "randomly", but never longer than that 1 minute?

Link to comment
  • Moderators
40 minutes ago, NoviceWithManyProblems said:

why practically never waiting for a spawn takes 1 minute, but it's "randomly", but never longer than that 1 minute?

Because the moment of execution is aligned with your fps. (Or internal clock)

I assume this decision is made in order to reduce constantly activity of the CPU and not blocking processes of other applications.

 

 

Edited by IIYAMA
Link to comment
21 hours ago, xMKHx said:

addEventHandler("onClientPlayerWasted", localPlayer, function()
  setTimer(function ()
  	triggerServerEvent("spawnWastedPlayer", resourceRoot)
  end, 60000, 1)
end)

addEvent("spawnWastedPlayer", true)
addEventHandler("spawnWastedPlayer", resourceRoot, function ()
    spawnPlayer(source, 0, 0, 0)
end)

Non tested

source of your server-side event is a resource, not a player.

Link to comment
2 hours ago, KronoS Lettify said:

source of your server-side event is a resource, not a player.

Try this

addEventHandler("onClientPlayerWasted", localPlayer, function()
  local name = getPlayerName(localPlayer)
  setTimer(function ()
  	triggerServerEvent("spawnWastedPlayer", resourceRoot, name)
  end, 60000, 1)
end)
addEvent("spawnWastedPlayer", true)
addEventHandler("spawnWastedPlayer", resourceRoot, function (name)
    spawnPlayer(getPlayerFromName(name), 0, 0, 0)
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...