Jump to content

Object move


Recommended Posts

Posted

Hi :)

I have this script:

function loadObjects() 
myobject = createObject ( 1609, 809.96142578125, -3110.8703613281, 593.13952636719, 0, 0, 273.76263427734 ) 
end 
addEventHandler("onResourceStart", getRootElement(), loadObjects) 
  
function moveObjects() 
moveObject(myobject, 10000, 855.62, -3110.33, 593.85 ) 
end 
addCommandHandler("showobject", moveObjects) 

Its work good but i want that the obeject 1609 move to the first point then make a 180° rotation and move back to the start and that all 60 sec.

atm i must start the script but i wanna that the object move all the time without "showobject"

I hope someone can help me :) THX!!!!

Posted

Use setTimer instead of addCommandHandler. The delay should be identical to, or higher than, the time it takes the object to move.

Do NOT PM ME for help unless invited. - New MTA Script Editor

Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.

Posted

I want that the object 1609 move

from: 809.96142578125, -3110.8703613281, 593.13952636719, 0, 0, 273.76263427734

to 855.62, -3110.33, 593.85 and make there a 180° rotation and move back

to 809.96142578125, -3110.8703613281, 593.13952636719

this all 1min

Posted

ok when nobody can say me that is there a way that the object move from 809.96142578125, -3110.8703613281, 593.13952636719, 0, 0, 273.76263427734 to 855.62, -3110.33, 593.85 and then the server delete the object and this all 1min?

or that the object move back to start point and this all 1min too?

I hope with that can someone help me :roll: THX :)

Posted

I have now:

function loadObjects() 
myobject = createObject ( 1609, 809.96142578125, -3110.8703613281, 593.13952636719, 0, 0, 273.76263427734 ) 
end 
addEventHandler("onResourceStart", getRootElement(), loadObjects) 
  
function moveObjects() 
moveObject(myobject, 10000, 855.62, -3110.33, 593.85 ) 
end 
setTimer ( moveObjects, 20000, 0 ) 
setTimer ( loadObjects, 20000, 0 ) 
addCommandHandler("setTimer", moveObjects) 

and the object move but now the server create all the time a new object :(

Can i load the object from the .map file so that the server not creat all the time a new object?

Posted

i have new creat a script where read the .map file but the object dont move now can someone help me plz!!! BIG THX :)

function loadObjects() 
  
allObjects = getElementsByType ( "turtle" ) -- the object id is turtle 
  
for key, theObject in ipairs ( allObjects ) do 
        local origX, origY, origZ = getElementPosition ( theObject ) --get the origanal position 
        local newX = 855.62 -- make a new X position 
        local newY = -3110.33 -- make a new Y position 
        local newZ = 593.85 -- make a new Z position 
        moveObject ( theObject, 20000, newX, newY, newZ ) --move the object to this position in 20 seconds. 
  
  
end 
  
end 
  
setTimer ( loadObjects, 20000, 0 ) 
  
addEventHandler("onResourceStart", getRootElement(), loadObjects) 
  
addCommandHandler("setTimer", loadObjects) 

Posted

this is my mapfile:

<map mod="deathmatch" version="1.0"> 
   <meta> 
     <object id="turtle" dimension="0" interior="0" model="1609" posX="809.96142578125" posY="-3110.8703613281" posZ="593.13952636719" rotX="0" rotY="0" rotZ="273.76263427734" /> 
</map> 

Posted
<object id="turtle" .../> <!-- Object element with ID "turtle" --> 
<turtle id="object" .../> <!-- Turtle element with ID "object" --> 

Setting it's ID to turtle doesn't make it a turtle element. ;)

Projects:

Slothbot | Maximap

Posted

My other script work better:

function loadObjects() 
myobject = createObject ( 1609, 809.96142578125, -3110.8703613281, 593.13952636719, 0, 0, 273.76263427734 ) 
end 
addEventHandler("onResourceStart", getRootElement(), loadObjects) 
  
setTimer ( destroyElement, 30000, 0,  myobject) 
addCommandHandler("setTimer", loadObjects) 
  
  
function moveObjects() 
moveObject(myobject, 10000, 855.62, -3110.33, 593.85 ) 
end 
setTimer ( moveObjects, 20000, 0 ) 
setTimer ( loadObjects, 20000, 0 ) 
addCommandHandler("setTimer", moveObjects) 

But the problem is when the turtle is on the endplace i want that the tutle object delete/remove i have test destroyElement but the object dout delete on the endplace.

Is there a way for fix that?????

Posted

I have make a script for all where search the same like me :)

function moveGate () 
    local gate1 = getElementByID ( "turtle" ) 
  
    local x1, y1, z1 = getElementData ( gate1, "posX" ), getElementData ( gate1, "posY" ), getElementData ( gate1, "posZ" ) 
  
                     moveObject(gate1, 10000, -2233.7536621094, 2318.2541503906, 7.546875 ) 
  
end 
  
setTimer ( moveGate, 20000, 0 ) 
addCommandHandler("setTimer", moveGate) 
  
addEventHandler("onResourceStart", getRootElement(), moveGate) 
  
  
  
function moveGateone () 
    local gate1 = getElementByID ( "turtle" ) 
  
    local x1, y1, z1 = getElementData ( gate1, "posX" ), getElementData ( gate1, "posY" ), getElementData ( gate1, "posZ" ) 
  
                     moveObject(gate1, 10000, -2225.376953125, 2333.6584472656, 7.546875 ) 
  
end 
  
setTimer ( moveGateone, 40000, 0 ) 
addCommandHandler("setTimer", moveGateone) 
  
addEventHandler("onResourceStart", getRootElement(), moveGateone) 

.map code

     <object id="turtle" dimension="0" interior="0" model="1609" posX="-2225.376953125" posY="2333.6584472656" posZ="7.546875" rotX="0" rotY="0" rotZ="273.76263427734" /> 

The object move now from left to right all the time :D Have fun!

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