SA-MP Forums Archive
Checkpoint help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Checkpoint help (/showthread.php?tid=262344)



Checkpoint help - HydraX - 17.06.2011

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.


AW: Checkpoint help - Nero_3D - 17.06.2011

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


Re: Checkpoint help - HydraX - 17.06.2011

..and How can I do this?


AW: Checkpoint help - Nero_3D - 17.06.2011

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


Re: Checkpoint help - HydraX - 17.06.2011

Okay, I will follow this. Thanks!


Re: Checkpoint help - HydraX - 17.06.2011

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.