IsBan: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 19: Line 19:


==Example==
==Example==
<section name="Example1" class="server" show="true">
This example chechks if the passed argument is a ban or not.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
function banRecieve ( ban )
if ban and isBan(ban) == true 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()
vehicle = createVehicle(411,0,5,3)
object = createObject(2600,0,0,0)
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)
</syntaxhighlight>
</syntaxhighlight>
</section>


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

Revision as of 11:59, 11 April 2015

Accessories-text-editor.png Script Example Missing Function IsBan needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.
ADDED/UPDATED IN VERSION 1.4 :

This function checks if the passed value is valid ban.


Syntax

bool isBan ( ban theBan )

Required Arguments

  • theValue: 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) == true 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()
vehicle = createVehicle(411,0,5,3)
object = createObject(2600,0,0,0)
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