PDA

View Full Version : settimerex check time left ?


karolis11234
17/03/2014, 04:21 PM
is there a way to check what is the time left when i use this function SetTimerEx ?

Dokins
17/03/2014, 04:59 PM
Sure, very easy. Use a string.


format(string, sizeof(string), "You still have %d minute(s) before you can collect your weapon.", WepTime[playerid]);


Do something like that.

Make sure you assign your timer to a variable i.e

WepTimer[playerid] = SetTimerEx();

also make it a global variable if you want to use it in other functions.

karolis11234
17/03/2014, 05:05 PM
doesnt it start the timer when i assign it ?so if im right it will start not where i want right ?

Dokins
17/03/2014, 05:12 PM
You need to assign it where you set it.

karolis11234
17/03/2014, 05:16 PM
how do i make a variable global ?

Dokins
17/03/2014, 05:18 PM
At the top of your script put something like this:


new WepTime[MAX_PLAYERS];

CuervO
17/03/2014, 05:45 PM
Timers do not return the time left when assigning a variable into them.

SetTimerEx especifically returns:
The ID of the timer that was started. Timer IDs start at 0. Timer IDs are never re-used.

I believe Y_Timers haves a function to check the current running time of a timer, otherwise you need to make it a repeating timer that acts sort of like a countdown, or create a new variable that saves the time when the timer was started, then with that you can check later how much time has passed since that.

Dokins
17/03/2014, 05:52 PM
Oh crap, yeah sorry. Cuerv0 is right, I made a mistake!

What I did was this:

Under a One Minute Timer, I set the WepTime[playerid] to decay 1 every minute, I've recently came back to scripting. I sincerely apologise for giving you wrong information!

MP2
17/03/2014, 06:37 PM
By default timers aren't very active, but if you use y_timers or fixes2 or Slice's TimerFix then you can just use GetTickCount().