Lloyd Logan Posted January 12, 2014 Posted January 12, 2014 When someone enters a marker, you would use onMarkerHit(themarkertheyentered) But if I have many markers, how can I use this so that if they enter any of these markers, one event is triggered (onMarkerHit) If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
xXMADEXx Posted January 12, 2014 Posted January 12, 2014 addEventHandler ( "onMarkerHit", root, function ( p ) -- code end ) The Ultimate Lua Tutorial! | MTA PHP SDK
csiguusz Posted January 12, 2014 Posted January 12, 2014 Create a dummy element with createElement and set this elemenet as parent of your markers with setElementParent. Then define your onMarkerHit event handler attached to the dummy element. Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003
Lloyd Logan Posted January 12, 2014 Author Posted January 12, 2014 Create a dummy element with createElement and set this elemenet as parent of your markers with setElementParent. Then define your onMarkerHit event handler attached to the dummy element. Dummy element has to be a real element, or can be made up? If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Lloyd Logan Posted January 12, 2014 Author Posted January 12, 2014 Create a dummy element with createElement and set this elemenet as parent of your markers with setElementParent. Then define your onMarkerHit event handler attached to the dummy element. Dummy element has to be a real element, or can be made up? EDIT: Nevermind, I understand now thanks! If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
csiguusz Posted January 12, 2014 Posted January 12, 2014 Read the wiki page. What you make with that function won't be a real entity in the world, it will youst behave like an element. Eg.: local marker1, marker2 = createMarker ( ... ), createMarker ( ... ) local ele = createElement ( "markers" ) setElementParent ( marker1, ele ) setElementParent ( marker2, ele ) addEventHandler ( "onMarkerHit", ele, function () outputChatBox ( "hit" ) end ) Edit: Great! You are welcome. Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003
Lloyd Logan Posted January 12, 2014 Author Posted January 12, 2014 Read the wiki page. What you make with that function won't be a real entity in the world, it will youst behave like an element. Eg.: local marker1, marker2 = createMarker ( ... ), createMarker ( ... ) local ele = createElement ( "markers" ) setElementParent ( marker1, ele ) setElementParent ( marker2, ele ) addEventHandler ( "onMarkerHit", ele, function () outputChatBox ( "hit" ) end ) Edit: Great! You are welcome. I have quite a number of markers, is there any easier way of doing local marker1, marker2 = createMarker ( ... ), createMarker ( ... ) local ele = createElement ( "markers" ) setElementParent ( marker1, ele ) setElementParent ( marker2, ele ) If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
csiguusz Posted January 13, 2014 Posted January 13, 2014 A loop? local markers = { createMarker ( ... ), createMarker ( ... ), createMarker ( ... ) } for i, v in ipairs ( markers ) do setElementParent ( v, ele ) end Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003
Lloyd Logan Posted January 13, 2014 Author Posted January 13, 2014 A loop? local markers = { createMarker ( ... ), createMarker ( ... ), createMarker ( ... ) } for i, v in ipairs ( markers ) do setElementParent ( v, ele ) end Thank you! A quick question, what does; for i, v in ipairs ( markers ) do mean? If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2014 Posted January 13, 2014 It's a loop. http://lua-users.org/wiki/ForTutorial San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 13, 2014 Author Posted January 13, 2014 It's a loop.http://lua-users.org/wiki/ForTutorial I'll check that out If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
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