Jump to content

Recommended Posts

Posted (edited)

IF THE PLAYER IS IN THE LAST RACE CHECKPOINT OR THE FINISH LINE, HOW TO BE DISABLED IT AND GIVE A REWARD?

Edited by JohnGTPS
Posted

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

  • Like 1
Posted
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;
}

 

 

Posted (edited)
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
Posted

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;

}

 

Posted
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;

}
Posted
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

Posted
2 minutes ago, Sancky said:

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

can you fix it? thankyou somuch

 

Posted
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;
}
Posted
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

Posted
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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.