Squirrel/Server/Functions/Players/GetClosestPlayer

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
 
Line 1: Line 1:
__NOTOC__
+
{{Squirrel/Title|GetClosestPlayer}}
 
This function finds the closest player to another player.
 
This function finds the closest player to another player.
  

Latest revision as of 10:30, 11 October 2010

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This function finds the closest player to another player.

[edit] Syntax

  1. bool GetClosestPlayer( pointer pPlayer )

[edit] Arguments

  • pPlayer - The player that you wish to find the closest player to.

[edit] Example

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "closest" )
  5. {
  6. local pClosest = GetClosestPlayer( pPlayer );
  7. MessagePlayer( "The closest player to you is " + pClosest.Name + ".", pPlayer );
  8. }
  9. }
  10.  

This will tell the player who is closest to them.

[edit] Notes

The call onPlayerCommand and Player.Name and MessagePlayer were used in in this example. More info about them in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox