About timers
#1

is there anyway to know on which second of timer we are on ?
i want to make clientmessage that shows how many seconds player took to complete reaction test and bla bla...

please help me...
how to do that??
Reply
#2

https://sampwiki.blast.hk/wiki/GetTickCount

Example:
pawn Код:
new ReactionStart; //At the top of your script

//When reaction test starts...
ReactionStart = GetTickCount(); //Gets the current time in milliseconds of the server uptime

//When a player gets the correct answer...
new string[100], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name)); //Store the player's name
format(string, sizeof(string), "%s(%d) guessed the answer to the reaction test in %d milliseconds.", name, playerid, (GetTickCount() - ReactionStart));
//GetTickCount() - ReactionStart will get the difference between the start of the reaction test, and the answer being guessed.
SendClientMessageToAll(-1, string);
Otherwise, you can use unix timestamps which are probably better in this situation, as GetTickCount can cause issues if the server is up for longer than 24 hours. To use unix timestamps, just replace 'GetTickCount()' with 'gettime()'.

https://sampwiki.blast.hk/wiki/Gettime
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)