Squirrel/Server/Functions/Players/ID
From Liberty Unleashed Wiki
(Difference between revisions)
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 | + | function onPlayerCommand( pPlayer, szCommand, szText ) |
{ | { | ||
− | + | if ( szCommand == "getid" ) | |
− | + | { | |
− | + | local pPlr; | |
− | + | if ( szText ) | |
− | + | { | |
− | + | 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/ | + | 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
int player.ID
Example
This command gives player's ID when someone types '/getid playername'.
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "getid" ) { local pPlr; if ( szText ) { 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; }
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.