Squirrel/Server/Functions/Players/FindPlayer

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: __NOTOC__ This function finds a player from an ID or part of the nick and returns the pointer to that player. If no player is found, ''null'' will be returned. == Syntax == ''FindPlayer'...)
 
(Example)
Line 14: Line 14:
 
* '''name''' - The name (or part of it) of the player to be found
 
* '''name''' - The name (or part of it) of the player to be found
  
== Example ==
+
function onPlayerCommand( player, cmd, text )
 +
{
 +
if ( cmd == "findplr" )
 +
{
 +
local plr;
  
{{Squirrel/NeedsExample}}
+
if ( ( text ) && ( IsNum( text ) ) ) plr = FindPlayer( text.tointeger() );
<code lang="squirrel">
+
else plr = FindPlayer( text.tointeger() );
-- todo
+
 
 +
if ( plr ) MessagePlayer( "Found player: " + plr + "!", player );
 +
else MessagePlayer( "No player found.", player );
 +
}
 +
}
 
</code>
 
</code>
 +
 +
This command will try and find the specified player.
  
 
=== Notes ===
 
=== Notes ===
  
-- Example notes/list of used functions here
+
The call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in in this example. More info about this in the corresponding page.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Players}}
 
{{Squirrel/Server/Functions/Players}}

Revision as of 03:18, 8 March 2010

This function finds a player from an ID or part of the nick and returns the pointer to that player. If no player is found, null will be returned.

Syntax

FindPlayer can take 2 different lists of parameters. These are:

  1. Player FindPlayer( int id )
  1. Player FindPlayer( string name )

Arguments

  • id - The ID of the player to be found
  • name - The name (or part of it) of the player to be found

function onPlayerCommand( player, cmd, text ) { if ( cmd == "findplr" ) { local plr;

if ( ( text ) && ( IsNum( text ) ) ) plr = FindPlayer( text.tointeger() ); else plr = FindPlayer( text.tointeger() );

if ( plr ) MessagePlayer( "Found player: " + plr + "!", player ); else MessagePlayer( "No player found.", player ); } } </code>

This command will try and find the specified player.

Notes

The call onPlayerCommand was used in in this example. More info about this in the corresponding page.

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox