Jump to content

help plis


Jacobob14

Recommended Posts

You must define the object a variable in order to move it later on.

I doubt it is going to work this way, because you are creating these this way. You should place the objects in a table and create one function and command, then for-loop through all the objects and move them.

for _,object in ipairs( Objects ) do  
    local newObject = createObject( unpack( object ) ) 
    addCommandHandler( "1", 
        function( player, cmd ) 
            moveObject( newObject, 100000, x, y, z + 10 ) 
        end 
    ) 
end 

So perhaps something like this could help you out:

local objects = { } 
  
addEventHandler( "onResourceStart", resourceRoot, 
    function( ) 
        for i,data in ipairs( objects ) do 
            local modelID, x, y, z = unpack( data ) 
            objects[ i ].object = createObject( modelID, x, y, z ) 
        end 
    end 
) 
  
addCommandHandler( "1", 
    function( player, cmd ) 
        for _,data in ipairs( objects ) do 
            if ( data.object ) and ( isElement( data.object ) ) then 
                local x, y, z = getElementPosition( data.object ) 
                moveObject( data.object, 100000, x, y, z + 10 ) 
            end 
        end 
    end 
) 

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