Squirrel/Server/Functions/Players/GetClosestPlayer

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: __NOTOC__ This function finds the closest player to another player. == Syntax == <code>bool GetClosestPlayer( pointer pPlayer )</code> == Arguments == * '''pPlayer''' - The player that...)
 
(Example)
Line 18: Line 18:
 
{
 
{
 
local pClosest = GetClosestPlayer( pPlayer );
 
local pClosest = GetClosestPlayer( pPlayer );
MessagePlayer( "The closest player to you is" + pClosest.Name + ".", pPlayer );
+
MessagePlayer( "The closest player to you is " + pClosest.Name + ".", pPlayer );
 
}
 
}
 
}
 
}

Revision as of 02:33, 26 May 2010

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