Jump to content

elementColShapeHit HELP


jortjuh

Recommended Posts

hello,

i want to try to use moving objects in maps, that works for me but i want to use it when the player is in a certain area.

there for i use: elementColShapeHit.

i'm currently using a test script i got from MTA wiki. when i use this in free roam resource it works. but when i'm using the script in my race resource(so i'm using cars) it stops working, but MTA wiki says it should work with both(player and cars)

this is the code i got from MTA wiki:

local gate_test = createColCircle ( 2482, -1701, 20 ) 
  
function elementColShapeHit( colShapeHit ) 
    if colShapeHit == gate_test then -- if element entered the created colshape 
        outputChatBox( getElementType( source ) .. " entered the colCircle!" ) -- print the type of the element to chatbox 
    end 
end 
addEventHandler( "onElementColShapeHit", getRootElement(), elementColShapeHit ) -- add a handler function for the event 

Edited by Guest
Link to comment
Maybe you forgot to load you script in the meta.xml ?

And why a colCircle ? because if a plane flies over the circle, it will activate the gate

so I you advice to use createColSphere

i added it in my meta.xml but i it really doesn't work. it doesn't give any errors. and when i use it in a freeroam and i walk through it, it works but when i use it in my race resource it doesnt work. maybe it isn't compatible with race resource?

Link to comment
  • Moderators

Try with onColShapeHit:

function elementColShapeHit( theElement ) 
    if source == gate_test then -- if element entered the created colshape 
        outputChatBox( getElementType( theElement ) .. " entered the colCircle!" ) 
    end 
end 
addEventHandler( "onColShapeHit", getRootElement(), elementColShapeHit ) 

Link to comment
  • Moderators

What's the problem ? There no errors ? I think there is a conflict with your GM.

Try this:

local gate_test = createColCircle ( 2482, -1701, 20 ) 
  
function elementColShapeHitTheColCircle( theElement ) 
    outputChatBox( getElementType( theElement ).. " entered the colCircle!" ) 
end 
addEventHandler( "onColShapeHit", gate_test, elementColShapeHitTheColCircle ) 

EDIT: I tested this code and it works perfectly !

Link to comment
What's the problem ? There no errors ? I think there is a conflict with your GM.

Try this:

local gate_test = createColCircle ( 2482, -1701, 20 ) 
  
function elementColShapeHitTheColCircle( theElement ) 
    outputChatBox( getElementType( theElement ).. " entered the colCircle!" ) 
end 
addEventHandler( "onColShapeHit", gate_test, elementColShapeHitTheColCircle ) 

EDIT: I tested this code and it works perfectly !

it works!

thanks for helping all!

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