GetCancelReason: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server client function}} Gets the reason for cancelling an event. ==Syntax== <syntaxhighlight lang="lua"> string getCancelEvent ( ) </syntaxhighlight> ===Required Arguments=== ''None'' ===Returns=== R...)
 
No edit summary
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server function}}
 
Gets the reason for cancelling an event.
Gets the reason for cancelling an event.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getCancelEvent ( )
string getCancelReason ( )
</syntaxhighlight>
</syntaxhighlight>


Line 14: Line 13:
===Returns===
===Returns===
Returns the reason that was given with [[cancelEvent]]
Returns the reason that was given with [[cancelEvent]]
==Example==
This example cancels when a hunterPlayer tries to enter a vehicle and outputs to the world what the player tried to do.
<syntaxhighlight lang="lua">-- call 'stopVehicleEntry' whenever hunterPlayer is about to enter a vehicle:
function stopVehicleEntry ( theplayer, seat, jacked )
  cancelEvent (true, "You can't enter a vehicle during war.") -- stop the event from occuring and tell the player the reason.
  outputConsole("We told "..getPlayerName(theplayer).." : "..getCancelReason()) --Now tell everyone what the player tried to do
end
addEventHandler ( "onVehicleStartEnter", huntedPlayer, stopVehicleEntry )
</syntaxhighlight>


==See Also==
==See Also==
{{Event functions}}
{{Event functions}}

Latest revision as of 12:50, 28 July 2013

Gets the reason for cancelling an event.

Syntax

string getCancelReason ( )

Required Arguments

None

Returns

Returns the reason that was given with cancelEvent

Example

This example cancels when a hunterPlayer tries to enter a vehicle and outputs to the world what the player tried to do.

-- call 'stopVehicleEntry' whenever hunterPlayer is about to enter a vehicle:
function stopVehicleEntry ( theplayer, seat, jacked )
   cancelEvent (true, "You can't enter a vehicle during war.") -- stop the event from occuring and tell the player the reason.
   outputConsole("We told "..getPlayerName(theplayer).." : "..getCancelReason()) --Now tell everyone what the player tried to do
end
addEventHandler ( "onVehicleStartEnter", huntedPlayer, stopVehicleEntry )

See Also