Squirrel/Server/Functions/Players/GetClosestPlayer

From Liberty Unleashed Wiki
Revision as of 02:33, 26 May 2010 by Force (Talk | contribs)

Jump to: navigation, search

This function finds the closest player to another player.

Syntax

  1. bool GetClosestPlayer( pointer pPlayer )

Arguments

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

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.

Notes

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

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox