SetBanReason: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (improve description)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}
{{Server function}}
{{New items|4.0132|1.4|
{{New items|3.0140|1.4|
This function set a new reason in the [[ban]].
This function sets the reason for the specified [[ban]].
}}
}}


==Syntax==  
==Syntax==  
Line 10: Line 9:
bool setBanReason( ban theBan, string theReason )
bool setBanReason( ban theBan, string theReason )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[ban]]:setReason|reason|getBanReason}}


===Required Arguments===  
===Required Arguments===  
*'''theBan:''' The [[ban]] in which you wish to retrieve the username of.
*'''theBan:''' The [[ban]] that you wish to set the reason of.
*'''theReason:''' the new reason (max 60 characters)
*'''theReason:''' the new reason (max 60 characters).


===Returns===
===Returns===
Returns ''true'' when is changed, ''false'' otherwise.
Returns ''true'' if the new reason was set successfully, ''false'' otherwise.


==Example==
==Example==
This example adds the command ''setreason'' which can be used to change the reason of a ban by nickname of the banned player. ''For example: setreason someguy reason.''
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function setreason (player,cmd,name,...)
function setReason (player,cmd,name,...)
local reason = table.concat({...}," ")
local reason = table.concat({...}," ")
if name and reason then
if name and reason then
Line 32: Line 34:
end
end
end
end
addCommandHandler("setreason",setreason)
addCommandHandler("setreason", setReason)
</syntaxhighlight>
</syntaxhighlight>


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

Latest revision as of 14:37, 7 August 2016

This function sets the reason for the specified ban.

Syntax

bool setBanReason( ban theBan, string theReason )


OOP Syntax Help! I don't understand this!

Method: ban:setReason(...)
Variable: .reason
Counterpart: getBanReason


Required Arguments

  • theBan: The ban that you wish to set the reason of.
  • theReason: the new reason (max 60 characters).

Returns

Returns true if the new reason was set successfully, false otherwise.

Example

This example adds the command setreason which can be used to change the reason of a ban by nickname of the banned player. For example: setreason someguy reason.

function setReason (player,cmd,name,...)
	local reason = table.concat({...}," ")
	if name and reason then
		local bans = getBans()
		for i,v in ipairs(bans)do
			if getBanNick(v) == name then
				setBanReason(v,reason)
				outputChatBox("Successfully edited the new Ban Reason.",player,0,125,0)
			end
		end
	end
end
addCommandHandler("setreason", setReason)

See Also