Fastest time - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Fastest time (
/showthread.php?tid=295329)
Fastest time -
manchestera - 05.11.2011
Will this my be a long shot but does anyone know how i could record the fastest time that someone does a race at as i dont have a clue at all.
Many Thanks
Re: Fastest time -
park4bmx - 05.11.2011
You will have to save these time somewhere ima variable or into a save file I prefer ima save file
Then just start your timer when the race starts and stop it when the players finishes the race
Then whenever the player finishes the race compare the times with the other player by using
if >= to check who's time is bigger and smoller!
I can't show any example becouse I don't know when race starts but I can still show but would be tomorrow
Re: Fastest time -
manchestera - 05.11.2011
That would be great
This is the start of the race
Код:
if(listitem == 4)
{
if(!IsPlayerInAnyVehicle(playerid)) return GameTextForPlayer(playerid, "You have to be in a vehicle!", 4000, 6 );
SetPlayerRaceCheckpoint(playerid, 0, -1763.769287,123.470710,3.672383, -1763.483764,-33.125278,10.852465, 10);
Westrace[playerid] = 1; // This will change the variable, so we can use it later on with OnPlayerEnterCheckpoint
SetVehiclePos( GetPlayerVehicleID( playerid ), -1765.4993,174.8689,6.7540);
currentveh = GetPlayerVehicleID(playerid);
SetVehicleZAngle(currentveh, 182.1981);
SetCameraBehindPlayer( playerid );
SendClientMessage(playerid, 0xFFFFFFFF, "You Start The West Coast Street Race. Please follow the checkpoints");
SendClientMessage(playerid, 0xFF0000FF, "Boost has been deactivated!");
SendClientMessage(playerid, 0xFF0000FF, "VUP has been deactivated!");
Westracetimer = SetTimer("Westraceclock", 1000, true);
P_DATA[ playerid ][ P_OnStyle ] = true;
P_DATA[ playerid ][ P_CarGod ] = 1;
P_DATA[ playerid ][ P_Vup ] = 0;
P_DATA[ playerid ][ P_Boost ] = 0;
return 1;
This is the timer
Код:
forward Westraceclock(playerid); // Also make a new SetTimerEx function in which you just add the number 1 in the funciton name.
public Westraceclock(playerid) {
if(iWestraceclock == -1) {
iWestraceclock = 61;
}
new
szMessage[10];
iWestraceclock--; // v down there, I have put ~n~ because that makes a new row, you don't want the timers to be in the same row and get one over an other.
format(szMessage, sizeof(szMessage), "~r~%d",iWestraceclock); // Add more in if you wish.
GameTextForPlayer(playerid, szMessage, 950, 6);
if(iWestraceclock == 0) {
KillTimer(Westracetimer);
DisablePlayerRaceCheckpoint(playerid);
P_DATA[ playerid ][ P_OnStyle ] = false;
}
return 1;
}
Any help to get this working would be great.
Re: Fastest time -
MP2 - 06.11.2011
Use gettime.
On race start save the returned integer from gettime in a variable and when a player finishes the race use gettime()-variable.
Now that I think of it you'd be better using ticks; same method though.