Jump to content

Link marker with vehicle


Lloyd Logan

Recommended Posts

local markers = { } -- Define a table. 
local vehicle = createVehicle ( ) -- Create a vehicle. 
local marker = createMarker ( ) -- Create a marker. 
  
markers [ marker ] = vehicle -- Add marker to the table with the value of the vehicle element. 
  
addEventHandler ( "onMarkerHit", root, 
    function ( ) 
        local vehicle = markers [ source ] -- Get the vehicle element using the marker as index for the table. 
        if ( vehicle ) then -- If there is a vehicle... 
            -- Do your thing here 
        end 
    end 
) 

Is that what you meant?

Link to comment
Quote

You can also set the marker a parent of the vehicle, or the other way around. This way you can just get the child or parent and have the vehicle.

That's what I was kinda looking for! So if I were to enter a marker, to get the name of a vehicle, would I set the parent vehicle to a marker other vice versa?

Link to comment
That's what I was kinda looking for! So if I were to enter a marker, to get the name of a vehicle, would I set the parent vehicle to a marker other vice versa?

It's easier to fetch if you set the vehicle the marker's parent. This way you can just call getElementParent -function to get the vehicle, the rest is obvious.

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...