GetBanIP: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server function}} This function will return the IP of the specified ban element. ==Syntax== <syntaxhighlight lang="lua"> string getBanIP ( ban theBan ) </syntaxhighlight> ===Required Arguments==...)
 
(Added oop syntax)
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}
{{Server function}}
This function will return the IP of the specified [[ban]] element.
This function will return the IP of the specified [[ban]].


==Syntax==  
==Syntax==  
Line 7: Line 7:
string getBanIP ( ban theBan )
string getBanIP ( ban theBan )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[ban]]:getIP|ip|}}


===Required Arguments===  
===Required Arguments===  
*'''theBan:''' The [[ban]] element which IP you want to return.
*'''theBan:''' The [[ban]] in which you want to return the IP of.


===Returns===
===Returns===
Returns a ''string'' of the IP if everything was successfull, ''false'' if invalid arguments are specified.
Returns a ''string'' of the IP if everything was successful, ''false'' if invalid arguments are specified if there was no IP specified for the [[ban]].


==Example==
==Example==
This example will show the user who banned a player the IP adress of that banned player.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
function banPlayerCommand ( thisPlayer, commandName, bannedName, reason )
    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
        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 IP Adress: " ..getBanIP ( theBan ), thisPlayer ) -- And send him the IP adress 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 )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Admin functions}}
{{Admin functions}}
[[ru:getBanIP]]

Latest revision as of 15:20, 6 August 2016

This function will return the IP of the specified ban.

Syntax

string getBanIP ( ban theBan )


OOP Syntax Help! I don't understand this!

Method: ban:getIP(...)
Variable: .ip


Required Arguments

  • theBan: The ban in which you want to return the IP of.

Returns

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

Example

This example will show the user who banned a player the IP adress 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 = getPlayerFromNick ( 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 IP Adress: " ..getBanIP ( theBan ), thisPlayer ) -- And send him the IP adress 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