GetBanSerial: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Server function}} This function will return the serial of the specified ban element. ==Syntax== <syntaxhighlight lang="lua"> string getBanSerial ( ban theBan ) </syntaxhighlight> ===Required Arg...) |
(Fix oop syntax) |
||
(9 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
This function will return the serial of the specified [[ban]] | This function will return the [[serial]] of the specified [[ban]]. | ||
==Syntax== | ==Syntax== | ||
Line 7: | Line 7: | ||
string getBanSerial ( ban theBan ) | string getBanSerial ( ban theBan ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[ban]]:getSerial|serial}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theBan:''' The [[ban]] | *'''theBan:''' The [[ban]] you want to retrieve the serial of. | ||
===Returns=== | ===Returns=== | ||
Returns a ''string'' of the serial if everything was | 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== | ==Example== | ||
This example will show the user who banned a player the serial of that banned player. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | 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 ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Admin functions}} | {{Admin functions}} | ||
[[ru:getBanSerial]] |
Latest revision as of 15:34, 6 August 2016
This function will return the serial of the specified ban.
Syntax
string getBanSerial ( ban theBan )
OOP Syntax Help! I don't understand this!
- Method: ban:getSerial(...)
- Variable: .serial
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 )