SA-MP Forums Archive
How do i check if the player finished first? - 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: How do i check if the player finished first? (/showthread.php?tid=557631)



How do i check if the player finished first? - dan40o - 14.01.2015

How do i check if the player finished first the race?


Re: How do i check if the player finished first? - erminpr0 - 14.01.2015

pawn Код:
new RaceFirstPosition = INVALID_PLAYER_ID;

// When player enters final checkpoint
if(RaceFirstPosition == INVALID_PLAYER_ID)
{
    RaceFirstPosition = playerid;
    SendClientMessage(playerid, color, "RACE | You are the 1st.");
    ...
}
And later you reset, when player gets award or when you start new race.
pawn Код:
RaceFirstPosition = INVALID_PLAYER_ID;



Re: How do i check if the player finished first? - dan40o - 14.01.2015

Quote:
Originally Posted by erminpr0
Посмотреть сообщение
pawn Код:
new RaceFirstPosition = INVALID_PLAYER_ID;

// When player enters final checkpoint
if(RaceFirstPosition == INVALID_PLAYER_ID)
{
    RaceFirstPosition = playerid;
    SendClientMessage(playerid, color, "RACE | You are the 1st.");
    ...
}
And later you reset, when player gets award or when you start new race.
pawn Код:
RaceFirstPosition = INVALID_PLAYER_ID;
Can you explain a bit? How to make it under checkpoint?
Код:
else if(nascarcheckpoints[playerid] == 13)
	{
	    nascarcheckpoints[playerid] = 0;
	    new cash= random(250000);
	    new fe[128];
	    format(fe, sizeof(fe), "+%d$", cash);
            SendClientMessage(playerid, YELLOW, fe);
	}



Re: How do i check if the player finished first? - erminpr0 - 15.01.2015

pawn Код:
new nascarwinner; // outside any callback

OnGameModeInit
{
    nascarwinner = INVALID_PLAYER_ID;
}

else if(nascarcheckpoints[playerid] == 13)
{
    if(nascarwinner == INVALID_PLAYER_ID) // 1st
    {
        nascarwinner = playerid;
        nascarcheckpoints[playerid] = 0;
        new cash= random(250000);
        new fe[128];
        format(fe, sizeof(fe), "+%d$", cash);
        SendClientMessage(playerid, YELLOW, fe);
        new string[MAX_PLAYER_NAME+32], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string, sizeof string, "1st. | %s" name);
        for(new idx; idx != MAX_PLAYERS; idx++) if(!IsPlayerConnected(idx) || !nascarcheckpoints[idx]) continue;
        { SendClientMessage(idx, YELLOW, string); }
    }
}

//Next time race starts make sure you set race has no winner yet..
nascarwinner = INVALID_PLAYER_ID;



Re: How do i check if the player finished first? - erminpr0 - 15.01.2015

accidentally posted


Re: How do i check if the player finished first? - dan40o - 15.01.2015

How do i check if player is second and third? Because when second player enter in the checkpoint, nothing happens.