Difference between revisions of "GetBanSerial"

From Multi Theft Auto: Wiki
m
Line 19: Line 19:
 
function banPlayerCommand ( thisPlayer, commandName, bannedName, reason )
 
function banPlayerCommand ( thisPlayer, commandName, bannedName, reason )
 
     if ( hasObjectPermissionTo ( thisPlayer, "function.banPlayer" ) ) then -- If the command user has the rights
 
     if ( hasObjectPermissionTo ( thisPlayer, "function.banPlayer" ) ) then -- If the command user has the rights
         local bannedPlayer = getPlayerFromNick ( bannedName ) -- Get the ID from the player who gets banned
+
         local bannedPlayer = getPlayerFromName ( bannedName ) -- Get the ID from the player who gets banned
 
         if getElementType ( bannedPlayer ) == "player" then -- If it's a player
 
         if getElementType ( bannedPlayer ) == "player" then -- If it's a player
 
             local theBan = banPlayer ( bannedPlayer, thisPlayer, reason ) -- Ban the player
 
             local theBan = banPlayer ( bannedPlayer, thisPlayer, reason ) -- Ban the player

Revision as of 16:20, 22 November 2011

This function will return the serial of the specified ban.

Syntax

string getBanSerial ( ban theBan )

Required Arguments

  • theBan: The ban you want to retrieve the serial of.

Returns

Returns a string of the serial if everything was successful, false if invalid arguments are specified or if there was no serial specified for the ban.

Example

This example will show the user who banned a player the serial of that banned player.

function banPlayerCommand ( thisPlayer, commandName, bannedName, reason )
    if ( hasObjectPermissionTo ( thisPlayer, "function.banPlayer" ) ) then -- If the command user has the rights
        local bannedPlayer = getPlayerFromName ( bannedName ) -- Get the ID from the player who gets banned
        if getElementType ( bannedPlayer ) == "player" then -- If it's a player
            local theBan = banPlayer ( bannedPlayer, thisPlayer, reason ) -- Ban the player
            outputChatBox ( "ban: " .. bannedName .. " successfully banned", thisPlayer ) -- Send the banner a succes message
            outputChatBox ( "At Serial: " ..getBanSerial ( theBan ), thisPlayer ) -- And send him the serial of the banned player
        end
    else
        outputChatBox ( "ban: You don't have enough permissions", thisPlayer ) -- If the command user doesn't have the permissions
    end
end
addCommandHandler ( "ban", banPlayerCommand )

See Also