SetPlayerCheckpoint
Description:
Function SetPlayerCheckpoint sets a checkpoint (red cylinder) for a player. Also shows a red blip on the radar. When players enter a checkpoint, OnPlayerEnterCheckpoint is called and actions can be performed.
Known Bug(s):
|
Checkpoints are asynchronous, meaning only one can be shown at a time. To 'stream' checkpoints (only show them when players are close enough), use a checkpoint streamer. |
Parameters:
(playerid, Float:x, Float:y, Float:z, Float:size)
int | playerid | The ID of the player for whom to set a checkpoint. |
float | X | The X coordinate to set the checkpoint at. |
float | Y | The Y coordinate to set the checkpoint at. |
float | Z | The Z coordinate to set the checkpoint at. |
float | size | The size of the checkpoint. |
Return Values:
- 1: The function was executed successfully.
- 0: The function failed to execute. This means the player specified does not exist.
Examples:
// In this example the player's checkpoint will be set when they spawn. // On entering the checkpoint they will receive $1000 and the checkpoint will be disabled. new bool:onCheck[MAX_PLAYERS]; public OnPlayerSpawn(playerid) { SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0); onCheck[playerid] = true; return 1; } public OnPlayerEnterCheckpoint(playerid) { if(onCheck[playerid]) // if it's true { GivePlayerMoney(playerid, 1000); DisablePlayerCheckpoint(playerid); onCheck[playerid] = false; } return 1; }
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- IsPlayerInCheckpoint: Check if a player is in a checkpoint.
- DisablePlayerCheckpoint: Disable the player's current checkpoint.
- SetPlayerRaceCheckpoint: Create a race checkpoint for a player.
- IsPlayerInRaceCheckpoint: Check if a player is in a race checkpoint.
- DisablePlayerRaceCheckpoint: Disable the player's current race checkpoint.
Related Callbacks
The following callbacks might be useful as well, as they are related to this callback in one way or another.
- OnPlayerEnterCheckpoint: Called when a player enters a checkpoint.
- OnPlayerLeaveCheckpoint: Called when a player leaves a checkpoint.
- OnPlayerEnterRaceCheckpoint: Called when a player enters a race checkpoint.
- OnPlayerLeaveRaceCheckpoint: Called when a player leaves a race checkpoint.