SA-MP Forums Archive
Setplayercheckpoint - 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: Setplayercheckpoint (/showthread.php?tid=462120)



Setplayercheckpoint - JonesyFoCoTDM - 05.09.2013

How do you set a new checkpoint upon entering a current one? I'm wanting to create a route with multiple checkpoints to get you from A to B basically.

Thanks in advance.


Re: Setplayercheckpoint - FiReAlEx - 05.09.2013

You can use OnPlayerEnterCheckpoint and lots of bools. For example
[pawn]OnPlayerEnterCheckpoint(playerid)
{
if(check1[playerid] == true) return SetPlayerCheckpoint(playerid, ....), check1[playerid] = false;
}


Re: Setplayercheckpoint - Eyce - 05.09.2013

Alternatively, you can do something like this:
pawn Код:
new playerCheckpoint[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    playerCheckpoint[playerid] = 0;
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, range, x, y, z) && playerCheckpoint[playerid] == 1)
    {
        DisablePlayerCheckpoint(playerid);
        SetPlayerCheckpoint(playerid, x, y, z, size);
        playerCheckpoint = 2;
    }
    else if(IsPlayerInRangeOfPoint(playerid, range, x, y, z) && playerCheckpoint[playerid] == 2)
    {
        DisablePlayerCheckpoint(playerid);
        SetPlayerCheckpoint(playerid, x, y, z, size);
        playerCheckpoint = 3;
    }
    return 1;
}
Check if the player is really near the range of the checkpoint. Disable the player's current checkpoint upon entering just for assurance. Then set the new player checkpoint and also it's variable for the next validation.