Jump to content

Creating/Separating elements node ?


relief

Recommended Posts

Still attaches the event to all the elements.

Can anyone post a simple example on how this is done?

To use the event system, you attach event handlers to elements in the element tree using addEventHandler. When you do this, your function will get triggered for all the events triggered on that element, it's parents (and their parents, etc.) and it's children (and their children). As such, an event handler attached to the root element will be triggered when an event occurs for any element. As a consequence you should generally use as specific a handler as you can. If you wish to just see when the player enters a specific marker, just attach the event handler to that marker.

Source: https://wiki.multitheftauto.com/wiki/Event_system

Link to comment

Somthing like this .( Maybe i did something wrong , i never tryed to use Parent Element in EventHandler)

group1 = createElement("carGroups1") 
  
local veh1 = createVehicle() 
local veh2 = createVehicle() 
  
setElementParent(veh1,groupe1) 
setElementParent(veh2,groupe1) 
  
  
function entered() 
  
outputChatBox("You are in a car from groupe1") 
  
end 
  
addEventHandler("onVehicleEnter",group1,entered) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...