Jump to content

Finish Race Checkpoint


JohnGTPS

Recommended Posts

7 minutes ago, Sancky said:

you have OnPlayerEnterRaceCheckpoint callback, check somehow in that callback if its in the last race checkpoint, use DisablePlayerRaceCheckpoint and give the reward to player

Quote
this is my OnPlayerEnterRaceCheckpoint where i put the DisablePlayerRaceCheckpoint?

 

public OnPlayerEnterRaceCheckpoint( playerid ) {

    if(IsPlayerInRace[playerid]) {

        playerCheckpoint[playerid] ++;
        new checkPoint = playerCheckpoint[playerid], nextPoint = playerCheckpoint[playerid] + 1;

        if( checkPoint < MAX_RACE_CHECKPOINTS - 1) SetPlayerRaceCheckpoint(playerid, 0, raceCheckpoints[checkPoint][0], raceCheckpoints[checkPoint][1], raceCheckpoints[checkPoint][2], raceCheckpoints[nextPoint][3], raceCheckpoints[nextPoint][4], raceCheckpoints[nextPoint][5], 7.0 );
        else SetPlayerRaceCheckpoint(playerid, 1, raceCheckpoints[checkPoint ][0], raceCheckpoints[checkPoint][1], raceCheckpoints[checkPoint][2], 0.0, 0.0, 0.0, 7.0 );

            SendClientMessage( playerid, -1, "Keep going!." );

    }

    return 1;
}

 

 

Link to comment
Share on other sites

public OnPlayerEnterRaceCheckpoint( playerid ) {

    if(IsPlayerInRace[playerid]) {

        playerCheckpoint[playerid] ++;
        new checkPoint = playerCheckpoint[playerid], nextPoint = playerCheckpoint[playerid] + 1;

        if(checkPoint == MAX_RACE_CHECKPOINTS) {
            DisablePlayerRaceCheckpoint(playerid);
            // give player reward
            return 1;
        }

        if( checkPoint < MAX_RACE_CHECKPOINTS - 1) SetPlayerRaceCheckpoint(playerid, 0, raceCheckpoints[checkPoint][0], raceCheckpoints[checkPoint][1], raceCheckpoints[checkPoint][2], raceCheckpoints[nextPoint][3], raceCheckpoints[nextPoint][4], raceCheckpoints[nextPoint][5], 7.0 );
        else SetPlayerRaceCheckpoint(playerid, 1, raceCheckpoints[checkPoint ][0], raceCheckpoints[checkPoint][1], raceCheckpoints[checkPoint][2], 0.0, 0.0, 0.0, 7.0 );

            SendClientMessage( playerid, -1, "Keep going!." );

    }

    return 1;
}
Edited by Sancky
  • Like 1
Link to comment
Share on other sites

can you check this my code? when you're at the first checkpoint, the next checkpoint doesn't show, then the first checkpoint hasn't disappeared yet

CMD:race(playerid, params[])
{
	new targetid;
	if(sscanf(params, "u", targetid))
	{
	    return SCM(playerid, COLOR_SYNTAX, "Usage: /race [playerid]");
	}
	if(PlayerInfo[playerid][pRace])
	{
	   return SCM(playerid, COLOR_SYNTAX, "You are currently in the race, type /quitrace to quit the currently race event.");
	}
    if(!IsPlayerConnected(targetid))
	{
	    return SendClientMessage(playerid, COLOR_GREY, "The player specified is disconnected.");
	}
	if(targetid == playerid)
	{
	    return SCM(playerid, COLOR_SYNTAX, "You can't use this command on yourself.");
	}
	PlayerInfo[playerid][pRace] = 1;
	//Player1 = IsPlayerInRace[playerid];
	//SetPlayerRaceCheckpoint( playerid, 0, raceCheckpoints[ 0 ][ 0 ], raceCheckpoints[ 0 ][ 1 ], raceCheckpoints[ 0 ][ 2 ], raceCheckpoints[ 1 ][ 3 ], raceCheckpoints[ 1 ][ 4 ], raceCheckpoints[ 1 ][ 5 ], 7.0 );
	ShowPlayerDialog(playerid, DIALOG_RACE, DIALOG_STYLE_LIST, "Select Vehicle", "Infernus\nTurismo\nNRG-500\nSuperGT\nBullet", "Select", "Cancel");
	return 1;
}

// for dialog
case DIALOG_RACE:
	    {
	        if(response)
	        {
	 			if(listitem == 0) // INFERNUS
				{
                    startRace(playerid);
                }
			}
		}

// and this is my function
startRace(playerid)
{
	if(IsPlayerInRace[playerid])
	{
		SetPlayerRaceCheckpoint(playerid, 0, raceCheckpoints[ 0 ][ 0 ], raceCheckpoints[ 0 ][ 1 ], raceCheckpoints[ 0 ][ 2 ], raceCheckpoints[ 1 ][ 3 ], raceCheckpoints[ 1 ][ 4 ], raceCheckpoints[ 1 ][ 5 ], 7.0 );
		SendClientMessage(playerid, -1, "POTANGINAAAAAA" );
	}
	return 1;

}

 

Link to comment
Share on other sites

can you check this my code? when you're at the first checkpoint, the next checkpoint doesn't show, then the first checkpoint hasn't disappeared yet?

CMD:race(playerid, params[])
{
	new targetid;
	if(sscanf(params, "u", targetid))
	{
	    return SCM(playerid, COLOR_SYNTAX, "Usage: /race [playerid]");
	}
	if(PlayerInfo[playerid][pRace])
	{
	   return SCM(playerid, COLOR_SYNTAX, "You are currently in the race, type /quitrace to quit the currently race event.");
	}
    if(!IsPlayerConnected(targetid))
	{
	    return SendClientMessage(playerid, COLOR_GREY, "The player specified is disconnected.");
	}
	if(targetid == playerid)
	{
	    return SCM(playerid, COLOR_SYNTAX, "You can't use this command on yourself.");
	}
	PlayerInfo[playerid][pRace] = 1;
	//Player1 = IsPlayerInRace[playerid];
	//SetPlayerRaceCheckpoint( playerid, 0, raceCheckpoints[ 0 ][ 0 ], raceCheckpoints[ 0 ][ 1 ], raceCheckpoints[ 0 ][ 2 ], raceCheckpoints[ 1 ][ 3 ], raceCheckpoints[ 1 ][ 4 ], raceCheckpoints[ 1 ][ 5 ], 7.0 );
	ShowPlayerDialog(playerid, DIALOG_RACE, DIALOG_STYLE_LIST, "Select Vehicle", "Infernus\nTurismo\nNRG-500\nSuperGT\nBullet", "Select", "Cancel");
	return 1;
}

// for dialog
case DIALOG_RACE:
	    {
	        if(response)
	        {
	 			if(listitem == 0) // INFERNUS
				{
                    startRace(playerid);
                }
			}
		}

// and this is my function
startRace(playerid)
{
	if(IsPlayerInRace[playerid])
	{
		SetPlayerRaceCheckpoint(playerid, 0, raceCheckpoints[ 0 ][ 0 ], raceCheckpoints[ 0 ][ 1 ], raceCheckpoints[ 0 ][ 2 ], raceCheckpoints[ 1 ][ 3 ], raceCheckpoints[ 1 ][ 4 ], raceCheckpoints[ 1 ][ 5 ], 7.0 );
		SendClientMessage(playerid, -1, "POTANGINAAAAAA" );
	}
	return 1;

}
Link to comment
Share on other sites

2 minutes ago, JohnGTPS said:

can you check this my code? when you're at the first checkpoint, the next checkpoint doesn't show, then the first checkpoint hasn't disappeared yet

CMD:race(playerid, params[])
{
	new targetid;
	if(sscanf(params, "u", targetid))
	{
	    return SCM(playerid, COLOR_SYNTAX, "Usage: /race [playerid]");
	}
	if(PlayerInfo[playerid][pRace])
	{
	   return SCM(playerid, COLOR_SYNTAX, "You are currently in the race, type /quitrace to quit the currently race event.");
	}
    if(!IsPlayerConnected(targetid))
	{
	    return SendClientMessage(playerid, COLOR_GREY, "The player specified is disconnected.");
	}
	if(targetid == playerid)
	{
	    return SCM(playerid, COLOR_SYNTAX, "You can't use this command on yourself.");
	}
	PlayerInfo[playerid][pRace] = 1;
	//Player1 = IsPlayerInRace[playerid];
	//SetPlayerRaceCheckpoint( playerid, 0, raceCheckpoints[ 0 ][ 0 ], raceCheckpoints[ 0 ][ 1 ], raceCheckpoints[ 0 ][ 2 ], raceCheckpoints[ 1 ][ 3 ], raceCheckpoints[ 1 ][ 4 ], raceCheckpoints[ 1 ][ 5 ], 7.0 );
	ShowPlayerDialog(playerid, DIALOG_RACE, DIALOG_STYLE_LIST, "Select Vehicle", "Infernus\nTurismo\nNRG-500\nSuperGT\nBullet", "Select", "Cancel");
	return 1;
}

// for dialog
case DIALOG_RACE:
	    {
	        if(response)
	        {
	 			if(listitem == 0) // INFERNUS
				{
                    startRace(playerid);
                }
			}
		}

// and this is my function
startRace(playerid)
{
	if(IsPlayerInRace[playerid])
	{
		SetPlayerRaceCheckpoint(playerid, 0, raceCheckpoints[ 0 ][ 0 ], raceCheckpoints[ 0 ][ 1 ], raceCheckpoints[ 0 ][ 2 ], raceCheckpoints[ 1 ][ 3 ], raceCheckpoints[ 1 ][ 4 ], raceCheckpoints[ 1 ][ 5 ], 7.0 );
		SendClientMessage(playerid, -1, "POTANGINAAAAAA" );
	}
	return 1;

}

 

you should set at StartRace the variable playerCheckpoint[playerid] at value 0

Link to comment
Share on other sites

1 minute ago, JohnGTPS said:

can you fix it? thankyou somuch

 

startRace(playerid)
{
    IsPlayerInRace[playerid] = 1;
    playerCheckpoint[playerid] = 0;
    SetPlayerRaceCheckpoint(playerid, 0, raceCheckpoints[ 0 ][ 0 ], raceCheckpoints[ 0 ][ 1 ], raceCheckpoints[ 0 ][ 2 ], raceCheckpoints[ 1 ][ 3 ], raceCheckpoints[ 1 ][ 4 ], raceCheckpoints[ 1 ][ 5 ], 7.0 );
    SendClientMessage(playerid, -1, "POTANGINAAAAAA");
    return 1;
}
Link to comment
Share on other sites

1 minute ago, Sancky said:
startRace(playerid)
{
    IsPlayerInRace[playerid] = 1;
    playerCheckpoint[playerid] = 0;
    SetPlayerRaceCheckpoint(playerid, 0, raceCheckpoints[ 0 ][ 0 ], raceCheckpoints[ 0 ][ 1 ], raceCheckpoints[ 0 ][ 2 ], raceCheckpoints[ 1 ][ 3 ], raceCheckpoints[ 1 ][ 4 ], raceCheckpoints[ 1 ][ 5 ], 7.0 );
    SendClientMessage(playerid, -1, "POTANGINAAAAAA");
    return 1;
}

one last thing, if i type /race then the dialog_race is shown up there are no checkpoints seted

Link to comment
Share on other sites

21 minutes ago, JohnGTPS said:

one last thing, if i type /race then the dialog_race is shown up there are no checkpoints seted

well, you have there only one check for the first item from dialog, if you press first item which is Infernus it will start the race, otherwise no.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.