Jump to content

moveObject


Gtagasje

Recommended Posts

Posted

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.

Yes, this is infact a signature.

Posted

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 ) 

Learn Lua - Learn to script - GUI scripting

Scripter tools - Find/fix errors yourself(!)

Don't pm me for scripting help, keep it for the Scripting subforum!

Posted

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) 

Posted

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 ) 
  

Yes, this is infact a signature.

Posted

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

Yes, this is infact a signature.

Posted

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.

Yes, this is infact a signature.

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