Jump to content

[Help]How to stop setTimer from restarting ?


Perfect

Recommended Posts

Hi, I made simple payday script, which pays player every 24 hours.

But the problem is, 'setTimer' is resetting everytime the resource restart.

Is there anyway to stop resetting of 'setTimer' ?

Here is the script:-

  
function payMoney() 
    givePlayerMoney(source,10000) 
end 
  
function payMoneyTimer() 
    setTimer(payMoney,86400000,0) 
end 

Can you guys please help me ?

Link to comment

look like you get wrong idea, your script will never work.

first,

the timer will start when you call the function payMoneyTimer(), if you dont call the function, no timer.

second

in the function payMoney(), who is the source, you did not declare that.

third

if this is a client script. givePlayerMoney() does not change the money on serverside

I am going show you a quick example, hope that is helpful

for server, you need create a script to handle a event for adding money to player

function onPlayerWant24Money () 
        givePlayerMoney(source,10000) 
end 
addEvent( "onPlayerWant24Money", true ) 
addEventHandler( "onPlayerWant24Money", root, onPlayerWant24Money) 
  

for client, you need create a script to set a timer for player to call a server event to add money for him every 24 hours

function require24Money () 
    triggerServerEvent ( "onPlayerWant24Money", localPlayer) 
end 
setTimer( require24Money,86400000,0) 
  

the timer will be set on clinet after player join in, and disappeared after player quit or disconnected

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...