luskanek Posted January 20, 2015 Posted January 20, 2015 (edited) Hello, for key, corona in pairs (getElementsByType("marker")) do if getMarkerType(corona) == "corona" then What I'm trying to do is to detect when a element hits a corona marker, however, the code triggers always, so not when it's a corona only. How do I fix this? Edited January 21, 2015 by Guest
Enkanet Posted January 20, 2015 Posted January 20, 2015 Hello, for key, corona in pairs (getElementsByType("marker")) do if getMarkerType(corona) == "corona" then What I'm trying to do is to detect when a element hits a corona marker, however, the code triggers always, so not when it's a corona only. How do I fix this? Try this: local corona = getElementsByType("marker") for key, v in pairs (corona) do if getMarkerType(corona[i]) == "corona" then
Enkanet Posted January 20, 2015 Posted January 20, 2015 Hello, for key, corona in pairs (getElementsByType("marker")) do if getMarkerType(corona) == "corona" then What I'm trying to do is to detect when a element hits a corona marker, however, the code triggers always, so not when it's a corona only. How do I fix this? Try this: local corona = getElementsByType("marker") for key, v in pairs (corona) do if getMarkerType(corona[i]) == "corona" then -- or this: if getMarkerType(v[i]) == "corona" then -- not sure with this
TAPL Posted January 20, 2015 Posted January 20, 2015 What is the event used and why you need this loop?
..:D&G:.. Posted January 20, 2015 Posted January 20, 2015 Maybe this? for key, corona in pairs (getElementsByType("marker")) do if not getMarkerType(corona) == "corona" then return end else --[[What is going to happen if the element is hitting an actual corona]] end end
luskanek Posted January 21, 2015 Author Posted January 21, 2015 TAPL, the event is onMarkerHit. I need the loop to check whenever the players hits a corona.
Et-win Posted January 21, 2015 Posted January 21, 2015 https://wiki.multitheftauto.com/wiki/OnMarkerHit The source of this event is the marker that got hit by the element. function lol(tElement) if (getElementType(tElement) == "player") then if (getMarkerType(source) == "corona") then --Stuff end end end addEventHandler("onMarkerHit", root, lol)
luskanek Posted January 21, 2015 Author Posted January 21, 2015 addEventHandler("onMarkerHit", getRootElement(), function(tElement) if getElementType(tElement) == "vehicle" then if getMarkerType(source) == "corona" then local x, y, z = getElementVelocity(tElement) setElementVelocity(tElement, x * 1.06, y * 1.06, z) end end end ) Doesn't work, no errors.
luskanek Posted January 21, 2015 Author Posted January 21, 2015 Yes. Tried to change the element to player instead of vehicle and get the player's vehicle, however, nothing works.
TAPL Posted January 21, 2015 Posted January 21, 2015 Try increase the number. addEventHandler("onMarkerHit", getRootElement(), function(tElement) if getElementType(tElement) == "vehicle" then if getMarkerType(source) == "corona" then local x, y, z = getElementVelocity(tElement) setElementVelocity(tElement, x * 2.5, y * 2.5, z) end end end )
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