OnColShapeHit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 24: Line 24:
addEventHandler ( "onColShapeLeave", hillArea, "hill_Exit" )
addEventHandler ( "onColShapeLeave", hillArea, "hill_Exit" )
function hill_Exit ( thePlayer, matchingDimension )
function hill_Exit ( thePlayer, matchingDimension )
     if isPlayerDead ( player ) ~= true then --check if the player is not dead when he leaves the zone
     if isPlayerDead ( thePlayer ) ~= true then --check if the player is not dead when he leaves the zone
               outputChatBox ( getClientName(player).." left the zone!", getRootElement(), 255, 255, 109 ) --if it is, announce it to everyone
               outputChatBox ( getClientName(thePlayer).." left the zone!", getRootElement(), 255, 255, 109 ) --if it is, announce it to everyone
     end
     end
end
end

Revision as of 18:51, 22 April 2007

This event is triggered when the player hits a colshape.

Syntax

void onColShapeHit ( player thePlayer, bool matchingDimension )  

Parameters

  • The source of this event refers to the col shape which was hit by a player
  • thePlayer: A player element referring to the player who entered the col shape.
  • matchingDimension: A boolean referring to whether the collision shape was hit in the correct dimension.

Example

This example creates a hill area for a king of the hill gamemode. When a player enters the area, it announces it in the chatbox.

hillArea = createColSquare ( -2171.0678710938, 678.17950439453, 0, 15, 15 ) --create our hill area for our gamemode

addEventHandler ( "onColShapeHit", hillArea, "hill_Enter" ) -- add an event handler for onConsole
function hill_Enter ( thePlayer, matchingDimension )   --when a player enters the hill area
    outputChatBox( getClientName(thePlayer).." entered the zone!", getRootElement(),255, 255, 109, ) --announce to everyone that the player entered the hill
end

addEventHandler ( "onColShapeLeave", hillArea, "hill_Exit" )
function hill_Exit ( thePlayer, matchingDimension )
    if isPlayerDead ( thePlayer ) ~= true then --check if the player is not dead when he leaves the zone
               outputChatBox ( getClientName(thePlayer).." left the zone!", getRootElement(), 255, 255, 109 ) --if it is, announce it to everyone
    end
end

See Also