GetPlayerSerial: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 24: Line 24:


==Example==
==Example==
<section name="Server" class="server" show="true">
<section name="Example 1" class="server" show="true">
This example creates a command with which player can check their own serial.
This example creates a command with which player can check their own serial.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 39: Line 39:
</section>
</section>


==Example 2==
<section name="Example 2" class="server" show="true">
<section name="Server" class="server" show="true">
This example add command to ban player serial.
This example add command to ban player serial.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 54: Line 53:
addCommandHandler( "banserial", banSerial )
addCommandHandler( "banserial", banSerial )
</syntaxhighlight>
</syntaxhighlight>
==Example 3==
</section>
<section name="Client" class="client" show="true">
 
<section name="Example 3" class="client" show="true">
This example add command to get client's serial.
This example add command to get client's serial.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">

Revision as of 14:39, 7 December 2011

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( "serial", 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( "serial", getMySerial )

See Also