Jump to content

Help, this is possible?


BrooklyN#

Recommended Posts

I try this:

for i, vehicle in ipairs(getElementsByType("vehicle"))do

if vehicle then

if(getVehicleName(vehicle) == "Roadtrain")then

local trailer = createVehicle(435, 3469.1201171875, -1544.19921875, 4.9000000953674)

if trailer then

attachTrailerToVehicle(vehicle, trailer)

end

end

end

end

but, I spawn just with the Trailer ._.

and I want spawn with the Truck attached with the Trailer

Help me :P

Link to comment

Try this.

  
addCommandHandler('trailer',  
    function( thePlayer ) 
        if ( thePlayer ) then 
             
            local x, y, z = getElementPosition( thePlayer ) 
             
            local truck = createVehicle( 515, 0, 0, 3 ) 
            if ( truck ) then 
                 
                setElementPosition( truck, x + 5, y, z ) 
                 
                local trailer = createVehicle( 435, 0, 0, 3 ) 
                if ( trailer ) then 
                     
                    setElementFrozen( trailer, true ) 
                     
                    local success = attachTrailerToVehicle( truck, trailer) 
                    if ( success ) then 
                         
                        setElementFrozen( trailer, false ) 
                        outputChatBox('Trailer attached to the Truck.', thePlayer ) 
                    end 
                end 
            end 
        end 
    end 
)    
             
  

Link to comment
Try this.
  
addCommandHandler('trailer',  
    function( thePlayer ) 
        if ( thePlayer ) then 
             
            local x, y, z = getElementPosition( thePlayer ) 
             
            local truck = createVehicle( 515, 0, 0, 3 ) 
            if ( truck ) then 
                 
                setElementPosition( truck, x + 5, y, z ) 
                 
                local trailer = createVehicle( 435, 0, 0, 3 ) 
                if ( trailer ) then 
                     
                    setElementFrozen( trailer, true ) 
                     
                    local success = attachTrailerToVehicle( truck, trailer) 
                    if ( success ) then 
                         
                        setElementFrozen( trailer, false ) 
                        outputChatBox('Trailer attached to the Truck.', thePlayer ) 
                    end 
                end 
            end 
        end 
    end 
)    
             
  

Error: Attemp to perform arithmetic on local 'x' (a boolean value)

Warning: Bad argument @ 'getElementPosition'

And I don't want command, I want the map to start with the truck and trailer attached, like a spawnpoint :roll:

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