Lumaktaw patungo sa pangunahing content

SetPlayerCheckpoint

Description

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.

NameDescription
playeridThe ID of the player for whom to set a checkpoint.
Float:centreXThe X coordinate to set the checkpoint at.
Float:centreYThe Y coordinate to set the checkpoint at.
Float:centreZThe Z coordinate to set the checkpoint at.
Float:radiusThe size of the checkpoint.

Returns

true - The function executed successfully.

false - 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:gOnCheck[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0);
gOnCheck[playerid] = true;
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
if (gOnCheck[playerid]) // if it's true
{
GivePlayerMoney(playerid, 1000);
DisablePlayerCheckpoint(playerid);
gOnCheck[playerid] = false;
}
return 1;
}

Notes

warning

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.