Lloyd Logan Posted January 16, 2014 Posted January 16, 2014 Is there anyway to link a marker with a vehicle? I mean, if i were to enter a marker, it would tell me 'something' of a certain vehicle? Example : Player steps into the marker, and gets details of a certain car?
Castillo Posted January 16, 2014 Posted January 16, 2014 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?
Lloyd Logan Posted January 16, 2014 Author Posted January 16, 2014 Well, because I don't fully understand your code, I cant say for sure, but from looking, i think it's right!
Castillo Posted January 16, 2014 Posted January 16, 2014 I edited the code to add comments so you may understand it better.
myonlake Posted January 16, 2014 Posted January 16, 2014 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.
Lloyd Logan Posted January 16, 2014 Author Posted January 16, 2014 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?
myonlake Posted January 16, 2014 Posted January 16, 2014 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.
Lloyd Logan Posted January 16, 2014 Author Posted January 16, 2014 Solidsnake14 said: I edited the code to add comments so you may understand it better. Actually thanks for that! Because of myonlake post I never saw yours! This also helped, thanks!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now