OnColShapeLeave: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(6 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
This event is triggered when a player leaves a collision shape.
{{Server event}}
This event is triggered when a player or a vehicle leaves a collision shape.


==Syntax==  
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
onColShapeLeave ( element leaveElement, bool matchingDimension )
element leaveElement, bool matchingDimension
</syntaxhighlight>  
</syntaxhighlight>  


*'''leaveElement''': The [[element]] that who exited the col shape. This can be a player or a vehicle.
*'''matchingDimension''': a [[boolean]] referring to whether the collision shape was in the same [[dimension]] as the element.


==Variables==
==Source==
* The source of this event refers to the col object in which an element has left
The [[event system#Event source|source]] of this event is the [[colshape]] that the element no longer is in contact with.
*'''leaveElement''': The [[element]] that who exited the col shape.
*'''matchingDimension''': a boolean referring to whether the collision shape was in the same dimension as the element.


==Example==  
==Example==  
This example kills the player whenever they leave a certain collision shape:
This example kills the player whenever they leave a certain collision shape:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
jailZone = createColCircle ( 1024, 1024, 15, 50 ) -- create a collision shape
local jailZone = createColCircle ( 1024, 1024, 15 ) -- create a collision shape


-- call 'jailZoneLeave' whenever a player leaves the collision shape:
-- call 'jailZoneLeave' whenever a player leaves the collision shape:
addEventHandler ( "onColShapeLeave", jailZone, "jailZoneLeave" )
function jailZoneLeave ( thePlayer )
function jailZoneLeave ( thePlayer )
   killPlayer ( thePlayer ) -- kill the player
   if getElementType ( thePlayer ) == "player" then -- if the element that left was player
  outputChatBox ( "You are not allowed to leave the jail!", thePlayer )
      killPlayer ( thePlayer ) -- kill the player
      outputChatBox ( "You are not allowed to leave the jail!", thePlayer )
  end
end
end
addEventHandler ( "onColShapeLeave", jailZone, jailZoneLeave )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
{{See also/Server event|Colshape events}}
{{Event_functions}}

Latest revision as of 02:55, 27 September 2018

This event is triggered when a player or a vehicle leaves a collision shape.

Parameters

element leaveElement, bool matchingDimension
  • leaveElement: The element that who exited the col shape. This can be a player or a vehicle.
  • matchingDimension: a boolean referring to whether the collision shape was in the same dimension as the element.

Source

The source of this event is the colshape that the element no longer is in contact with.

Example

This example kills the player whenever they leave a certain collision shape:

local jailZone = createColCircle ( 1024, 1024, 15 ) -- create a collision shape

-- call 'jailZoneLeave' whenever a player leaves the collision shape:
function jailZoneLeave ( thePlayer )
   if getElementType ( thePlayer ) == "player" then -- if the element that left was player
      killPlayer ( thePlayer ) -- kill the player
      outputChatBox ( "You are not allowed to leave the jail!", thePlayer )
   end
end
addEventHandler ( "onColShapeLeave", jailZone, jailZoneLeave )

See Also

Colshape events


Event functions