SetPlayerCheckpoint

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 08:39, 10 May 2018
IAmir (Talk | contribs)

← Previous diff
Current revision
IAmir (Talk | contribs)

Line 1: Line 1:
{{Scripting}} {{Scripting}}
-{{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. Hi IRAN :|}}+{{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.}}
{{Parameters|playerid, Float:x, Float:y, Float:z, Float:size}} {{Parameters|playerid, Float:x, Float:y, Float:z, Float:size}}

Current revision



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.


Parameters:
(playerid, Float:x, Float:y, Float:z, Float:size)
playeridThe ID of the player for whom to set a checkpoint.
Float:xThe X coordinate to set the checkpoint at.
Float:yThe Y coordinate to set the checkpoint at.
Float:zThe Z coordinate to set the checkpoint at.
Float:sizeThe size of the checkpoint.


Return Values:

  • 1: The function executed successfully.
  • 0: The function failed to execute. This means the player specified does not exist.


Image:32px-Circle-style-warning.png

Warning

Known Bug(s):
  • If a checkpoint is already set it will use the size of that checkpoint instead of the new one.
  • Checkpoints created on server-created objects (CreateObject/CreatePlayerObject) will appear down on the 'real' ground, but will still function correctly. A pickup can be used instead.


Image:32px-Circle-style-warning.png

Important
Note

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.


Example Usage:

// 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 might be useful, as they're related to this callback in one way or another.


Related Callbacks

The following callbacks might be useful as well, as they are related to this callback in one way or another.

Personal tools
In other languages