Jump to content

[SOLVED] Marker


luskanek

Recommended Posts

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 by Guest
Link to comment
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 

Link to comment
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  

Link to comment
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.

Link to comment
  • Other Languages Moderators

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 
) 

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