GetPlayerSerial

From Multi Theft Auto: Wiki
Revision as of 14:10, 13 February 2013 by Prestege (talk | contribs) (→‎Example)
Jump to navigation Jump to search

This function returns the serial for a specified player.

Syntax

Click to collapse [-]
Server
string getPlayerSerial ( player thePlayer )

Required Arguments

  • thePlayer: A player object referencing the specified player.
Click to collapse [-]
Client
string getPlayerSerial ( )

Returns

Returns the serial as a string if it was found, false otherwise.

Example

Click to collapse [-]
Example 1

This 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 2

This 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 3

This example add command to get client's serial.

function getMySerial( )
      local theSerial = getPlayerSerial()
      outputChatBox("Your serial is: "..tostring(theSerial))
     end
end
addCommandHandler( "myserial", getMySerial )
Click to collapse [-]
Example 3

This 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
)
Click to collapse [-]
Example 4

This example if the player Tries to change the nickname was not the Serial is located will be banned .

Serial = {
["You,re Serial"] = true,
}
addEventHandler("onPlayerChangeNick",root,
function (old,new)
local getSerial = getPlayerSerial (source)
 if ( new ~= "You,re Nick Name" ) then return end
 if ( new == "You,re Nick Name" and Serial[getSerial] ) then
        return outputChatBox ( "Been successfully verify the Serial (=", source, 255, 255, 0, true )
    else    
       outputChatBox ( "No verification of serial will be banned player now", root, 255, 255, 0, true )
      banPlayer ( source, false, false, true, source, "Reason" )
      cancelEvent()
    end
end
)

See Also