Gtagasje Posted October 14, 2011 Share Posted October 14, 2011 Hello, I made a script to move an object onmarkerhit, since I didn't know how to place the colshapes (Bad me.). But, if I enter the marker (debugscript 3 is on) it doesn't show an error message, but the gate won't move. Also if I start it in console, it doesn't show an error message. This is what I have: local marker1 = createMarker ( 1253.0999755859, -1399, 12, 'cylinder', 11, 222, 222, 1, 225 ) local gate1 = createObject ( 980, 1252.8000488281, -1399.0999755859, 14.800000190735, 0, 0, 90 ) function moveObject ( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" then moveObject ( gate1, 3000, 1252.8000488281, -1413, 14.800000190735 ) end end function moveObjectBack () if getElementType ( hitElement ) == "player" then moveObject ( gate1, 3000, 1252.8000488281, -1399.0999755859, 14.800000190735 ) end end addEventHandler ( "onMarkerHit", marker1 , moveObject ) addEventHandler ( "onMarkerLeave", marker1, moveObjectBack ) I hope somebody can help me, or can tell me how and where to place the colShapes. Link to comment
SDK Posted October 14, 2011 Share Posted October 14, 2011 Heh, you're using "moveObject" as name for one of your custom functions, but that way it will overwrite the default mta function. local marker1 = createMarker ( 1253.0999755859, -1399, 12, 'cylinder', 11, 222, 222, 1, 225 ) local gate1 = createObject ( 980, 1252.8000488281, -1399.0999755859, 14.800000190735, 0, 0, 90 ) function movingObject ( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" then moveObject ( gate1, 3000, 1252.8000488281, -1413, 14.800000190735 ) end end function moveObjectBack () if getElementType ( hitElement ) == "player" then moveObject ( gate1, 3000, 1252.8000488281, -1399.0999755859, 14.800000190735 ) end end addEventHandler ( "onMarkerHit", marker1 , movingObject ) addEventHandler ( "onMarkerLeave", marker1, moveObjectBack ) Link to comment
Gtagasje Posted October 14, 2011 Author Share Posted October 14, 2011 Oh, thank you Btw, do u know a place where I can see where to place a colshape for a gate? Link to comment
CapY Posted October 14, 2011 Share Posted October 14, 2011 Use freeroam resource and you will see a position of your place. Or just do it on map editor. Link to comment
Gtagasje Posted October 14, 2011 Author Share Posted October 14, 2011 So it need to be the exact position as yourself? Also the height? Link to comment
CapY Posted October 14, 2011 Share Posted October 14, 2011 If you're using colCircle then it has unlimited height, you just need to change coords and radius to your needs. Link to comment
Gtagasje Posted October 14, 2011 Author Share Posted October 14, 2011 And a colcuboid? I need to set the radius to for example 20 for a height like an AirportGate? Link to comment
CapY Posted October 14, 2011 Share Posted October 14, 2011 Syntax from wiki: colshape createColCuboid ( float fX, float fY, float fZ, float fWidth, float fDepth, float fHeight ) So it's like this : createColCuboid( yourX, yourY, yourZ, width, depth, heightHere) Link to comment
Gtagasje Posted October 14, 2011 Author Share Posted October 14, 2011 Thank you, i'll try to add it to my moveObject script, and see if I did it right ;p Link to comment
Gtagasje Posted October 14, 2011 Author Share Posted October 14, 2011 ok, so I created the colshape, it is also working.. but I don't get the position.. The colshape is there, but at the wrong place. It's a little area far away from the gate. This is what I have: local colshape1= createColCuboid( 1252.98486, -1399.16370, 13.01563, 20, 20, 20) local gate1 = createObject ( 980, 1252.8000488281, -1399.0999755859, 14.800000190735, 0, 0, 90 ) function movingObject ( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" then moveObject ( gate1, 3000, 1252.8000488281, -1413, 14.800000190735 ) end end function moveObjectBack () moveObject ( gate1, 3000, 1252.8000488281, -1399.0999755859, 14.800000190735 ) end addEventHandler ( "onColShapeHit", colshape1 , movingObject ) addEventHandler ( "onColShapeLeave", colshape1 , moveObjectBack ) Link to comment
Gtagasje Posted October 14, 2011 Author Share Posted October 14, 2011 where the **** did my reply go? Never mind I make it again. It doesn't show any debug errors. The colshape sizes may be wrong (I think) but I don't know how to solve this.. I also don't know what depth is.. It is just a little tube far away from the gate, and the coördinates from the colshape (X,Y,Z) are infront of the gate, and very close. Can u tell me what depth is? And maybe you know how to fix this problem.. Link to comment
CapY Posted October 14, 2011 Share Posted October 14, 2011 Lol depth is depth, if you don't understand , google translator may help you. Link to comment
Gtagasje Posted October 14, 2011 Author Share Posted October 14, 2011 I know what it means. But I don't know what it gives.. the depth under the ground or what.. like height says the max height (if i'm right) in the air. Link to comment
CapY Posted October 14, 2011 Share Posted October 14, 2011 The depth under the ground . Use it only if you have something high placed. Link to comment
Gtagasje Posted October 14, 2011 Author Share Posted October 14, 2011 Thx, I make it onMarkerHit again, cus I can't fix this. Link to comment
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