settimerex check time left ?
#1

is there a way to check what is the time left when i use this function SetTimerEx ?
Reply
#2

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.
Reply
#3

doesnt it start the timer when i assign it ?so if im right it will start not where i want right ?
Reply
#4

You need to assign it where you set it.
Reply
#5

how do i make a variable global ?
Reply
#6

At the top of your script put something like this:

pawn Код:
new WepTime[MAX_PLAYERS];
Reply
#7

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.
Reply
#8

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!
Reply
#9

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().
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)