GetPlayerPos

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 11:37, 4 August 2016
OstGot (Talk | contribs)

← Previous diff
Revision as of 15:05, 21 January 2018
Jelly23 (Talk | contribs)

Next diff →
Line 3: Line 3:
{{Description|Get the position of a player, represented by X, Y and Z coordinates.}} {{Description|Get the position of a player, represented by X, Y and Z coordinates.}}
-{{Parameters|playerid, Float:x, Float:y, Float:z}}+{{Parameters|playerid, &Float:x, &Float:y, &Float:z}}
{{Param|playerid|The ID of the player to get the position of.}} {{Param|playerid|The ID of the player to get the position of.}}
{{Param|Float:x|A float variable in which to store the X coordinate in, passed by reference.}} {{Param|Float:x|A float variable in which to store the X coordinate in, passed by reference.}}

Revision as of 15:05, 21 January 2018



Description:

Get the position of a player, represented by X, Y and Z coordinates.


Parameters:
(playerid, &Float:x, &Float:y, &Float:z)
playeridThe ID of the player to get the position of.
Float:xA float variable in which to store the X coordinate in, passed by reference.
Float:yA float variable in which to store the Y coordinate in, passed by reference.
Float:zA float variable in which to store the Z coordinate in, passed by reference.


Return Values:

  • true on success.
  • false on failure (i.e. player not connected).


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

Important
Note

This function is known to return unreliable values when used in OnPlayerDisconnect and OnPlayerRequestClass. This is because the player is not spawned.


public OnPlayerDeath(playerid, killerid, reason)
{
    // Declare 3 float variables to store the X, Y and Z coordinates in
    new Float:x, Float:y, Float:z;
 
    // Use GetPlayerPos, passing the 3 float variables we just created
    GetPlayerPos(playerid, x, y, z);
 
    // Create a cash pickup at the player's position
    CreatePickup(1212, 4, x, y, z, -1);
   return 1;
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.

Personal tools
In other languages