Adde Posted August 17, 2013 Share Posted August 17, 2013 (edited) Hello, I have a question. I am making a savesystem to my timer or how i should say. Is this close if I want to save the timer "onQuit" and then launch the rest next time the player login if the timer still was running onquit? I may have understood wiki wrong bcs I can´t figure it out. There are a lot like missiontimer also, but I choose this. Thankfull for answears. I have a function here, included: theTimer = setTimer(setElementPosition, 240000,1,x,y,z) then theese functions: function onQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then if isTimer( theTimer ) then local timer = getTimerDetails( theTimer ) setAccountData ( playeraccount, "jailTimer", timer ) end end end addEventHandler ( "onPlayerQuit", root, onQuit ) function onLogin () if ( playeraccount ) then local Timer = getAccountData ( playeraccount, "jailTimer" ) if ( Timer ) then setTimer(setElementPosition,"timer",1,source,634.37,-567.09,16.33 ) end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onLogin) Edited August 18, 2013 by Guest Link to comment
.:HyPeX:. Posted August 17, 2013 Share Posted August 17, 2013 I started reading, but stopped on this: if isTimer( theTimer ) then You've said this: theTimer = setTimer(setElementPosition, 240000,1,x,y,z) So, how are you planing to make a timer to get the player time (Lets call it ontime) if you are checking that the timer is 240000? Link to comment
Adde Posted August 17, 2013 Author Share Posted August 17, 2013 Oh, my bad. Should have thought about that. Is it not just checking if there is any timer running atm? Or is it checking if the timer is on 240000? Is this possible right? function onQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local timer = getTimerDetails( theTimer ) setAccountData ( playeraccount, "jailTimer", timer ) end end addEventHandler ( "onPlayerQuit", root, onQuit ) function onLogin () if ( playeraccount ) then local Timer = getAccountData ( playeraccount, "jailTimer" ) if ( Timer ) then setTimer(setElementPosition,"Timer",1,source,634.37,-567.09,16.33 ) end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onLogin) Link to comment
.:HyPeX:. Posted August 28, 2013 Share Posted August 28, 2013 Still, you are setting a timer, you should start a timer, on play login (setTimer is a countdown) I'm not sure wich function does this, but you should start checking arround on the wiki, since Timer doesnt do it. (Not sure if GetElementData with GetTickCount could do it) A timer object refers to a timer set to execute a function a certain number of times with a specified delay.Note that after a timer has completed all its iterations, it is destroyed and any stored pointers to it become invalid. Also timers are not under the resource hierarchy, becouse they are not elements, for instance, if you create a timer, it will not be destroyed when the resource in which it was created is stopped, so in this case you should kill the timer manually. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now