GetPlayerSerial: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 36: Line 36:
==Example 2==
==Example 2==
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="true">
This example add command to ban player serial.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
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( "ban-serial", banSerial )
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Revision as of 16:25, 17 March 2010

This function returns the serial for a specified player.

Syntax

string getPlayerSerial ( player thePlayer )

Required Arguments

  • thePlayer: A player object referencing the specified player.

Returns

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

The format of the serial has been changed.

Example

Click to collapse [-]
Server

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 )

Example 2

Click to collapse [-]
Server

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

See Also