GetDistanceBetweenPlayers: Difference between revisions
Jump to navigation
Jump to search
Automatyczna aktualizacja dokumentacji funkcji |
Complete Lua function catalog |
||
| Line 32: | Line 32: | ||
* Available only in server-side resource scripts. | * Available only in server-side resource scripts. | ||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:Player Functions]] | [[Category:Player Functions]] | ||
Latest revision as of 09:52, 15 August 2026
getDistanceBetweenPlayers
Calculates the latest known 3D distance between two players.
Syntax
number getDistanceBetweenPlayers(int firstPlayerId, int secondPlayerId)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
firstPlayerId |
int |
yes | The first connected player. |
secondPlayerId |
int |
yes | The second connected player. |
Returns
Returns the distance in metres, or false when either position is unavailable.
Examples
Send a message when two players are nearby:
local distance = getDistanceBetweenPlayers(playerId, otherPlayerId)
if distance and distance <= 10 then
outputChatBox("The other player is nearby", playerId)
end
Notes
- Available only in server-side resource scripts.