[Help]Printing/Getting lap time.
#2

There is one, but it's only accurate to the second.
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;
}
NOTE: NOT TESTED!!
Reply


Messages In This Thread
[Help]Printing/Getting lap time. - by Ronaldo_raul™ - 12.07.2012, 12:45
Re: [Help]Printing/Getting lap time. - by clarencecuzz - 12.07.2012, 12:57
Re: [Help]Printing/Getting lap time. - by Ronaldo_raul™ - 13.07.2012, 16:41
Re: [Help]Printing/Getting lap time. - by Roko_foko - 13.07.2012, 16:44
Re: [Help]Printing/Getting lap time. - by Ronaldo_raul™ - 13.07.2012, 17:15
Re: [Help]Printing/Getting lap time. - by Ronaldo_raul™ - 14.07.2012, 17:18
Re: [Help]Printing/Getting lap time. - by leonardo1434 - 14.07.2012, 18:24
Re: [Help]Printing/Getting lap time. - by Ronaldo_raul™ - 15.07.2012, 07:51
Re: [Help]Printing/Getting lap time. - by Niko_boy - 15.07.2012, 08:00
Re: [Help]Printing/Getting lap time. - by Ronaldo_raul™ - 15.07.2012, 09:35

Forum Jump:


Users browsing this thread: 1 Guest(s)