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 () 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!