Jump to content

Help me with this function


Phiilip~*

Recommended Posts

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) 

Link to comment
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 
) 

Link to comment
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 :)

Link to comment

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 :)

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