GetPlayerDistanceFromPoint
From SA-MP Wiki
(Difference between revisions)
Revision as of 14:35, 19 June 2013 Smithy (Talk | contribs) ← Previous diff |
Revision as of 17:44, 2 February 2014 Connor Mead (Talk | contribs) Next diff → |
||
Line 1: | Line 1: | ||
{{Scripting}} | {{Scripting}} | ||
- | {{Title}} | ||
{{AddedIn0.3c|function|R3}} | {{AddedIn0.3c|function|R3}} | ||
Line 40: | Line 39: | ||
[[Category:Scripting Functions]] | [[Category:Scripting Functions]] | ||
+ | |||
+ | [[fr:GetPlayerDistanceFromPoint]] |
Revision as of 17:44, 2 February 2014
Description:
Calculate the distance between a player and a map coordinate.
(playerid, Float:X, Float:Y, Float:Z)
playerid | The ID of the player to calculate the distance from. |
Float:X | The X map coordinate. |
Float:Y | The Y map coordinate. |
Float:Z | The Z map coordinate. |
Return Values:
The distance between the player and the point as a float.
/* when the player types '/vend' into the chat box, they'll see this.*/ public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext, "/vend", true) == 0) { new Float: fDistance = GetPlayerDistanceFromPoint(playerid, 237.9, 115.6, 1010.2), szMessage[44]; format(szMessage, sizeof(szMessage), "You're %0.2f meters away from the vending machine.", fDistance); SendClientMessage(playerid, 0xA9C4E4FF, szMessage); return 1; } return 0; }
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- IsPlayerInRangeOfPoint: Check whether a player is in range of a point.
- GetVehicleDistanceFromPoint: Get the distance between a vehicle and a point.
- GetPlayerPos: Get a player's position.