Checkpoint help
#1

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    new playervehicleid = GetPlayerVehicleID(playerid);

    if(gObjectiveReached) return;
    if(playervehicleid == OBJECTIVE_VEHICLE_BLUE && gTeam[playerid] == TEAM_BLUE)
    {   // Blue OBJECTIVE REACHED.
        {
            GameTextForAll("~w~Head back to the ~r~Naval Ship",3000,5);
            DisablePlayerCheckpoint(playerid);
            SetPlayerCheckpoint(playerid,-1389.5182,492.2472,3.0391,5.0);
        }
        else if(playervehicleid == OBJECTIVE_VEHICLE_BLUE && gTeam[playerid] == TEAM_BLUE)
        {   // Blue OBJECTIVE REACHED 2.
            {
                GameTextForAll("~w~Get out of the truck, The truck is set to ~n~explode in ~r~15 seconds",3000,5);
                DisablePlayerCheckpoint(playerid);
            }
        }
        return;
    }
}
However, this isn't correct. Whenever the first checkpoint is called, the second one isn't.
Also, I want to know what function to use to create an explosion after the second checkpoint is called.
I still have my rustiness, sorry.
Reply
#2

You are checking twice for the same thing, so only the first will be called

You need to use a pointer, so you know which checkpoint is active

To create an explosion use CreateExplosion (check wiki) in a timer
Reply
#3

..and How can I do this?
Reply
#4

There was a good example in the old area51.pwn which came with the sa-mp package :/

Its quite easy, you create an player array

pawn Код:
stock gPlayerCheckpointStatus[MAX_PLAYERS];
and you define some checkpoints

pawn Код:
enum {
    CHECKPOINT_NONE,
    CHECKPOINT_ONE,
    CHECKPOINT_TWO
}
and than if you set a checkpoint you just set the array to

pawn Код:
gPlayerCheckpointStatus[playerid] = CHECKPOINT_ONE;

SetPlayerCheckpoint(playerid, ...);
in the end if you disable the checkpoint you need to reset the array

pawn Код:
gPlayerCheckpointStatus[playerid] = CHECKPOINT_NONE;

DisPlayerPlayerCheckpoint(playerid);
And in OnPlayerEnterCheckpoint

pawn Код:
switch(gPlayerCheckpointStatus[playerid]) {

    case CHECKPOINT_ONE: {}

    case CHECKPOINT_TWO: {}

    default: {
        gPlayerCheckpointStatus[playerid] = CHECKPOINT_NONE;
        DisPlayerPlayerCheckpoint(playerid);
    }

}
The timer for the explosion should be clear, if not read the wiki page about SetTimerEx
Reply
#5

Okay, I will follow this. Thanks!
Reply
#6

If you get out of the car, you have to restart the whole process again. For example, I get out of the car, then get back on it. I still have to go to the same checkpoint even though I already hit the first checkpoint.
Edit: Nevermind, The variable was set to -1, meaning that when you left the vehicle, the checkpoints would reset themselves.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)