Squirrel/Server/Functions/Players/ID

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
m (Squirrel/Functions/Players/ID moved to Squirrel/Server/Functions/Players/ID: Separating the server-side functions from client-side ones)
Line 11: Line 11:
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function OnPlayerCommand( player, cmd, text )
+
function onPlayerCommand( pPlayer, szCommand, szText )
 
{
 
{
    if ( cmd == "getid" )
+
if ( szCommand == "getid" )
    {
+
{
          local plr = FindPlayer( text );
+
local pPlr;
          if ( !plr ) MessagePlayer( "Player '" + text + "' is not online.", player );
+
if ( szText )
          else MessagePlayer( plr.Name + "'s ID: " + plr.ID, player );
+
{
    }
+
pPlr = FindPlayer( szText );
 +
if ( pPlr ) MessagePlayer( pPlr.Name + "'s ID is " + pPlr.ID + " ticks.", pPlayer );
 +
else MessagePlayer( "Unknown player!", pPlayer );
 +
}
 +
else MessagePlayer( "Your ID is " + pPlayer.ID + " ticks.", pPlayer );
 +
}
 +
 +
return 1;
 
}
 
}
 
</code>
 
</code>
Line 24: Line 31:
 
=== Notes ===
 
=== Notes ===
  
The functions [[Squirrel/Functions/Misc/MessagePlayer|MessagePlayer]], [[Squirrel/Functions/Misc/GetPlayerName|GetPlayerName]] and call [[Squirrel/Events/Player/OnPlayerCommand|OnPlayerCommand]] were used in in this example. More info about them in corresponding pages.
+
The functions [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and [[Squirrel/Server/Functions/Players/FindPlayer|FindPlayer]] and [[Squirrel/Server/Functions/Players/Player.Name|Player.Name]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Functions/Players}}
 
{{Squirrel/Functions/Players}}

Revision as of 17:02, 4 October 2010

This function returns player's ID.

Syntax

  1. int player.ID

Example

This command gives player's ID when someone types '/getid playername'.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "getid" )
  5. {
  6. local pPlr;
  7. if ( szText )
  8. {
  9. pPlr = FindPlayer( szText );
  10. if ( pPlr ) MessagePlayer( pPlr.Name + "'s ID is " + pPlr.ID + " ticks.", pPlayer );
  11. else MessagePlayer( "Unknown player!", pPlayer );
  12. }
  13. else MessagePlayer( "Your ID is " + pPlayer.ID + " ticks.", pPlayer );
  14. }
  15. return 1;
  16. }
  17.  

Notes

The functions MessagePlayer and FindPlayer and Player.Name and event onPlayerCommand were used in this example. More info about them in the corresponding pages.

Related Functions

Template:Squirrel/Functions/Players

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox