Jump to content

Help me with this function


Phiilip~*

Recommended Posts

Posted

Hey guys

Help me pls

How I make for a Truck spawn with a Trailer attached? "Petrotr" for example...

I know the function

attachTrailerToVehicle 

But, I failed to use it (and I'm noob in Script xD)

Someone could help me do it?

Thanks

Posted
function attachTrailerToMyTruck() 
    local x, y, z = getElementPosition(source) 
    local vehicle = createVehicle(vehicleID, x, y, z) 
    local trailer = createVehicle(trailerID, x, y+5, z) 
    warpPedIntoVehicle(source, vehicle) 
    attachTrailerToVehicle(trailer, vehicle) 
end 
addCommandHandler("createTruck", attachTrailerToMyTruck) 

Posted
function attachTrailerToMyTruck() 
    local x, y, z = getElementPosition(source) 
    local vehicle = createVehicle(vehicleID, x, y, z) 
    local trailer = createVehicle(trailerID, x, y+5, z) 
    warpPedIntoVehicle(source, vehicle) 
    attachTrailerToVehicle(trailer, vehicle) 
end 
addCommandHandler("createTruck", attachTrailerToMyTruck) 

local vehicleID = 353; 
local trailerID = 653; 
  
addCommandHandler( "createtruck", 
    function( player ) 
        local nX, nY, nZ = getElementPosition( player ); 
         
        local pVehicle = createVehicle( vehicleID, nX, nY, nZ ); 
        local pTrailer = createVehicle( trailerID, nX, nY + 5, nZ ); 
         
        warpPedIntoVehicle( player, pVehicle ); 
        attachTrailerToVehicle( pTrailer, pVehicle ); 
    end 
) 

Posted
function attachTrailerToMyTruck() 
    local x, y, z = getElementPosition(source) 
    local vehicle = createVehicle(vehicleID, x, y, z) 
    local trailer = createVehicle(trailerID, x, y+5, z) 
    warpPedIntoVehicle(source, vehicle) 
    attachTrailerToVehicle(trailer, vehicle) 
end 
addCommandHandler("createTruck", attachTrailerToMyTruck) 

Thanks man, but, I don't want command to spawn it, my idea is when start my map, the players spawn with a truck and a trailer attached them :)

Posted

it's almost the same, just you need:

local vehicle = createVehicle(vehicleID, x, y, z) 
local trailer = createVehicle(trailerID, x, y+5, z) 
warpPedIntoVehicle(source, vehicle) 
attachTrailerToVehicle(trailer, vehicle) 

change (x, y, z) with coordonates where the vehicle will be spawned when you start a map, same for vehicleID and trailerID.

also remeber to change 'source' with element that you use :)

Posted
also remeber to change 'source' with element that you use :)

Sorry, I don't understand this :z

and what element I'll use?

I don't know anything about script :roll:

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