SetBanAdmin: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Added oop syntax)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}
{{Server function}}
{{Needs_Example}}
{{New items|3.014|1.4|
{{New items|4.0132|1.4|
This function sets a new admin for a [[ban]].
This function set a new Admin in the [[ban]].
}}
}}


==Syntax==  
==Syntax==  
Line 11: Line 9:
bool setBanAdmin ( ban theBan, string theAdmin )
bool setBanAdmin ( ban theBan, string theAdmin )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[ban]]:setAdmin|admin|getBanAdmin}}


===Required Arguments===  
===Required Arguments===  
*'''theBan:''' The [[ban]] in which you wish to retrieve the username of.
*'''theBan:''' The [[ban]] you want to change the admin of.
*'''theAdmin:''' the new admin name
*'''theAdmin:''' The new admin.


===Returns===
===Returns===
Returns ''true'' when is changed, ''false'' otherwise.
Returns ''true'' if changed, ''false'' otherwise.


==Example==
==Example==
This example changes the ban admin to the admin's IP (If it's a player), when someone gets banned.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
function banHappened(theBan)
    if getElementType(source) == "player" then
        local adminIP = getPlayerIP(source)
        setBanAdmin(theBan,adminIP)
    end
end
 
addEventHandler( "onBan", getRootElement(), banHappened )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Admin_functions}}
{{Admin_functions}}
[[ru:setBanAdmin]]

Latest revision as of 15:17, 6 August 2016

This function sets a new admin for a ban.

Syntax

bool setBanAdmin ( ban theBan, string theAdmin )


OOP Syntax Help! I don't understand this!

Method: ban:setAdmin(...)
Variable: .admin
Counterpart: getBanAdmin


Required Arguments

  • theBan: The ban you want to change the admin of.
  • theAdmin: The new admin.

Returns

Returns true if changed, false otherwise.

Example

This example changes the ban admin to the admin's IP (If it's a player), when someone gets banned.

function banHappened(theBan)
    if getElementType(source) == "player" then
        local adminIP = getPlayerIP(source)
        setBanAdmin(theBan,adminIP)
    end
end

addEventHandler( "onBan", getRootElement(), banHappened )

See Also