GetPlayerSerial: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server | {{Server function}} | ||
This function returns the [[serial]] for a specified [[player]]. | This function returns the [[serial]] for a specified [[player]]. | ||
{{Note| | {{Note|The client side version of [[getPlayerSerial]] has been deprecated as it can return the wrong value for some players, and is potentially insecure.}} | ||
==Syntax== | ==Syntax== | ||
Line 12: | Line 12: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePlayer:''' A [[player]] object referencing the specified player. | *'''thePlayer:''' A [[player]] object referencing the specified player. | ||
</section> | </section> | ||
Line 55: | Line 49: | ||
</section> | </section> | ||
<section name="Example 3 | <section name="Example 3" class="server" show="true"> | ||
This example is Firewall Account Player by serial on Login | This example is Firewall Account Player by serial on Login | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> |
Revision as of 11:12, 21 April 2016
This function returns the serial for a specified player.
Syntax
Click to collapse [-]
Serverstring getPlayerSerial ( player thePlayer )
OOP Syntax Help! I don't understand this!
- Method: player:getSerial(...)
- Variable: .serial
Required Arguments
- thePlayer: A player object referencing the specified player.
Returns
Returns the serial as a string if it was found, false otherwise.
Example
Click to collapse [-]
Example 1This example creates a command with which player can check their own serial.
function checkMySerial( thePlayer, command ) local theSerial = getPlayerSerial( thePlayer ) if theSerial then outputChatBox( "Your serial is: " .. theSerial, thePlayer ) else outputChatBox( "Sorry, you have no serial. =(", thePlayer ) end end addCommandHandler( "myserial", checkMySerial )
Click to collapse [-]
Example 2This example add command to ban player serial.
function banSerial( source, command, noob, reason ) if ( noob ) then local theNoob = getPlayerFromName( noob ) local theNoobSerial = getPlayerSerial( theNoob ) if ( theNoob ) then addBan( theNoobSerial, source, reason ) end end end addCommandHandler( "banserial", banSerial )
Click to collapse [-]
Example 3This example is Firewall Account Player by serial on Login
Firewall = { [ 'AccountName' ] = 'SerialPlayer', [ '3ash8' ] = '9C9F3B55D9D7BB7135FF274D3BF444E4', [ 'test5' ] = '1D6F76CF8D7193792D13789849498452', } addEventHandler ( 'onPlayerLogin', getRootElement ( ), function ( _, theCurrentAccount ) local Serial = Firewall[getAccountName(theCurrentAccount)] if ( Serial ) then if Serial ~= getPlayerSerial ( source ) then banPlayer ( source, false, false, true, getRootElement ( ), 'reason ban' ) end end end )