IsBan: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}
{{Server function}}
{{New items|4.0132|1.4|
{{New items|3.014|1.4|
This function checks if the passed value is valid [[ban]].
This function checks whether the passed value is valid [[ban]] or not.
}}
}}


==Syntax==  
==Syntax==  
Line 12: Line 11:


===Required Arguments===  
===Required Arguments===  
*'''theValue:''' The value to check
*'''theBan:''' The value to check


===Returns===
===Returns===
Line 22: Line 21:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function banRecieve ( ban )
function banRecieve ( ban )
if ban and isBan(ban) == true then
if ban and isBan(ban) then
outputChatBox("this is a ban!")--Valid ban is recieved!
outputChatBox("this is a ban!")--Valid ban is recieved!
else
else
outputChatBox("this is not a ban, this is a "..getElementType(ban))--if the argument is not a ban, then checks its type and output it into the chat box.
outputChatBox("this is not a ban, this is a "..getElementType(ban))--if the argument is not a ban, then checks its type and output it into the chat box.
end
end
end
end


function onBan ( ban ) -- This function will be triggered every time a player is banned.
function onBan ( ban ) -- This function will be triggered every time a player is banned.
banRecieve(ban)
banRecieve(ban)
end
end
addEventHandler ( "onPlayerBan", getRootElement(), onBan )
addEventHandler ( "onPlayerBan", getRootElement(), onBan )


function sendWrongBanArguement()
function sendWrongBanArguement()
vehicle = createVehicle(411,0,5,3)
local vehicle = createVehicle(411,0,5,3)
object = createObject(2600,0,0,0)
local object = createObject(2600,0,0,0)
ped = createPed(61,0,0,3)
local ped = createPed(61,0,0,3)
banRecieve(vehicle)--sends a vehicle as an argument.
banRecieve(object)--sends an object as an argument.
banRecieve(vehicle)--sends a vehicle as an argument.
banRecieve(ped)--sends a ped as an argument.
banRecieve(object)--sends an object as an argument.
banRecieve(ped)--sends a ped as an argument.
end
end
addCommandHandler("sendWrongArgument",sendWrongBanArguement)
addCommandHandler("sendWrongArgument",sendWrongBanArguement)

Latest revision as of 21:06, 11 July 2019

This function checks whether the passed value is valid ban or not.

Syntax

bool isBan ( ban theBan )

Required Arguments

  • theBan: The value to check

Returns

Returns true if the value is a ban, false otherwise.

Example

Click to collapse [-]
Example1

This example chechks if the passed argument is a ban or not.

function banRecieve ( ban )
	if ban and isBan(ban) then
		outputChatBox("this is a ban!")--Valid ban is recieved!
	else
		outputChatBox("this is not a ban, this is a "..getElementType(ban))--if the argument is not a ban, then checks its type and output it into the chat box.
	end
end

function onBan ( ban ) -- This function will be triggered every time a player is banned.
	banRecieve(ban)
end
addEventHandler ( "onPlayerBan", getRootElement(), onBan )

function sendWrongBanArguement()
	local vehicle = createVehicle(411,0,5,3)
	local object = createObject(2600,0,0,0)
	local ped = createPed(61,0,0,3)
	
	banRecieve(vehicle)--sends a vehicle as an argument.
	banRecieve(object)--sends an object as an argument.
	banRecieve(ped)--sends a ped as an argument.
end
addCommandHandler("sendWrongArgument",sendWrongBanArguement)

See Also