12.07.2012, 12:57
There is one, but it's only accurate to the second.
NOTE: NOT TESTED!!
pawn Код:
#include <a_samp> //Main include for all SAMP functions
new Time[MAX_PLAYERS]; //We will use this to save our time
new Count[MAX_PLAYERS]; //Use this so we can kill the timer when we want.
public OnPlayerConnect(playerid)
{
Time[playerid] = 0; //Makes sure the player joins with 0 seconds to their name.
return 1;
}
//Put your "PLAYER STARTS RACE" code here
{
Count[playerid] = SetTimerEx("Timer", 200, true, "i", playerid); //Start the timer (Script starts counting time)
}
forward Timer(playerid); //Make sure you introduce the timer
public Timer(playerid) //Start defining what the timer will do.
{
Time[playerid] + 0.2 //Will add 0.2 seconds to the timer every 20 milliseconds.
return 1; //Stop the code from continuing.
}
//Put your "PLAYER FINISHES RACE" here
{
KillTimer(Count[playerid]);
new string[256];
new PlayersName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayersName, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s has finished the lap in %.2f seconds!", PlayersName, Time[playerid]); //%.2f shows a number to 2 decimal places.
SendClientMessageToAll(0x00FF00AA, string);
return 1;
}