Jump to content

moveObject problem


bucky

Recommended Posts

Hello guys, I have a problem with moveObject, and more directly - the rotation.

Here you are the code:

  
fl = createObject (968, -2002, 2263.6, 18.7, 0 ,90 ,90) -- left barrier 
fr = createObject (968, -2001.9, 2273.9, 18.64, 0 ,270 ,90) -- right barrier 
  
f = createMarker ( -2001.9, 2268.7, 16.2, "cylinder", 10, 0, 0, 0, 0 ) 
  
 function onfMarkerHit( hitElement, matchingDimension ) 
   if getElementType( hitElement ) == "player" then 
    local florigX, florigY, florigZ = getElementPosition ( fl ) 
    local frorigX, frorigY, frorigZ = getElementPosition ( fr ) 
     
    local flrotX, flrotY, flrotZ = getElementRotation ( fl ) 
    local frrotX, frrotY, frrotZ = getElementRotation ( fr ) 
  
    moveObject ( fl, 5000, florigX + 0.002, florigY, florigZ, flrotX, flrotY, flrotZ - 10 ) 
    moveObject ( fr, 5000, frorigX + 0.002, frorigY, frorigZ, frrotX, frrotY, frrotZ + 80 ) 
     
   end 
end 
addEventHandler( "onMarkerHit", f, onfMarkerHit ) 
  
function onfmarkerLeave( leaveElement, matchingDimension ) 
   if getElementType( leaveElement ) == "player" then 
    
   local flrotX, flrotY, flrotZ = getElementRotation ( fl ) 
    local frrotX, frrotY, frrotZ = getElementRotation ( fr ) 
     moveObject ( fl, 5000, florigX, florigY, florigZ, flrotX, flrotY, flrotZ ) 
     moveObject ( fr, 5000, frorigX, frorigY, frorigZ, frrotX, frrotY, frrotZ ) 
      
   end 
end 
addEventHandler( "onMarkerLeave", f, onfmarkerLeave ) 

The problem is that the object (barrier) is rotation to it's own positions when I enter the marker, and nothing happens when I leave it.

Here are some screens:

** Screens are too big for here (blabla) so here is the link with the images:

http://prikachi.com/gallery_view.php?us ... &gal=10821

The barriers:

(pic 1)

Entering the marker:

(pic 2,3,9)

And they finaly stand like this:

(pic 11)

And on every next markerHit, they only rotate by rotZ and when I leave - nothing again.

/debugscript 3 screen:

(pic debug)

So I wonder how can I fix this. Can anyone please help me? Thanks in advance!

-- Offtopic --

I am new scripter and I want to learn the LUA. My question is, how should I learn it?

With MTA Wiki, without it, with it + some other places.. ?

How have you guys learned it? This would help me alot too. Thanks, bye!

Link to comment

I take it your problem is the fact that if you re-enter the marker before moveObject has completed, it will go past the destination. You need to add a few variables like 'barrierMoving', and onMarkerHit you can check that it isn't already moving. You can reset it by creating a timer with the same interval as moveObject (in this case, 5000 milliseconds - 5 seconds).

Moreover, if you don't want it to rotate on an axis, set it as 0 (not it's current rotation), as it uses these values in a relative manor, not absolute.

To answer your other question, yes, read the MTA wiki - specifically this page.

Link to comment

I didn't re-enter it before it's done. I've waited untill it's finished but nothing happens...

And as I said I am new, so I didn't understand the next part. :D

And thanks for the suggestion about Wiki. Also, should I read all the funcions, or some other information?

And.. are you Callum from SAES?

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