Posts: 35
Threads: 18
Joined: Feb 2014
Reputation:
0
is there a way to check what is the time left when i use this function SetTimerEx ?
Posts: 1,648
Threads: 482
Joined: Jun 2010
Sure, very easy. Use a string.
pawn Код:
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
pawn Код:
WepTimer[playerid] = SetTimerEx();
also make it a global variable if you want to use it in other functions.
Posts: 35
Threads: 18
Joined: Feb 2014
Reputation:
0
doesnt it start the timer when i assign it ?so if im right it will start not where i want right ?
Posts: 1,648
Threads: 482
Joined: Jun 2010
You need to assign it where you set it.
Posts: 35
Threads: 18
Joined: Feb 2014
Reputation:
0
how do i make a variable global ?
Posts: 1,648
Threads: 482
Joined: Jun 2010
At the top of your script put something like this:
pawn Код:
new WepTime[MAX_PLAYERS];
Posts: 1,164
Threads: 20
Joined: Oct 2008
Reputation:
0
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.
Posts: 1,648
Threads: 482
Joined: Jun 2010
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!
Posts: 6,236
Threads: 310
Joined: Jan 2011
Reputation:
0
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().