Sign in to follow this  
slapztea

restart timer on serverside

Recommended Posts

function givemins (player)
local mins = getElementData(player,"mins")
local res = getElementData(player,"respects")
if mins == 60 then
setElementData(player,"mins", -1)
setElementData(player,"respects", (getElementData(player, "respects") or 0) +1)
end
setTimer(
function()
setElementData(player,"mins", (getElementData(player, "mins") or 0) +1)
givemins()
end,
1000,
1, root, source)
end
addCommandHandler ( "gg", givemins )
addEvent("givemins",true)
addEventHandler("givemins",root,givemins)

What am I doing wrong? and how to fix it? Need restart timer when the timer is over.

The timer works, but after restart an error occurs.(that is, it works once without restart)

tr6-Ug03amY.jpg

290 - local mins = getElementData(player,"mins")
291 - local res = getElementData(player,"respects")

298 - setElementData(player,"mins", (getElementData(player, "mins") or 0) +1)

 

Edited by slapztea

Share this post


Link to post

player variable not defined.

When you trigger it from client side, pass the player element in first argument.

triggerServerEvent("givemins", localPlayer, PLAYER_ELEMENT)

 

Edited by stPatrick
  • Like 1

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.