Jump to content

Attach Trailer in .MAP file? Solved


Recommended Posts

i have looked at the MTA WIKI but cant find what im looking for

i want to spawn an attached truck and trailer with the .MAP file

i know how to set car spawn points but am unsure as to how to attach the trailer

can it be done and if it can could someone tell me how or link me to the right part of the WIKI if i have just missed it

any help appreciated thanx :D:D

Edited by Guest
Link to comment

Thanx for the reply

if i manage to figure something out i will try to post it here

Thanx again u r a STAR ACE_GAMBIT :D

EDIT : i am a bit confused by this

if i try to spawn the trailer with the map file it never appears ( even when spawned with no truck cab )

i can spawn the cab ( linerunner , roadtrain ) fine but there doesnt seem to be a way of creating the trailer until your in the game

i have tried writing a function to create cab and trailer then attach them like it says in the wiki but it just messes up the rest of my scripts and doesnt make a truck

im pretty sure im doing something wrong but i just dont know what so here is what ive written and if anybody notices any obvious mistakes could u tell me

THANX

function filltruckstop () 
      local cab1 = ( createVehicle, 514, -476, -489, 25 ) 
      local trailer1 = ( createVehicle, 584, -480, -482, 25 ) 
      attachTrailerToVehicle ( cab1, trailer1 ) 
end 

addEventHandler ( onResourceStart, root, filltruckstop ) 

i have also tried it as a console command but it doesnt do anything :?:shock:

EDIT : i have tried to spawn a trailer on its own in the .MAP file but that doesnt seem to work either

i thought if i could get the .MAP to spawn the cab and trailer i could then write a function to join them together but it seems the only way to create a trailer is within the game

does anyone know if im just being dumb or is this possibly a bug :roll:

i know im missing the rotation in the function above but i was trying to keep it short and easier to read

Link to comment
       local cab1 = ( createVehicle, 514, -476, -489, 25 ) 
       local trailer1 = ( createVehicle, 584, -480, -482, 25 ) 

Replace the above with:

       local cab1 = createVehicle ( 514, -476, -489, 25 ) 
       local trailer1 =  createVehicle ( 584, -480, -482, 25 ) 

Link to comment
       local cab1 = ( createVehicle, 514, -476, -489, 25 ) 
       local trailer1 = ( createVehicle, 584, -480, -482, 25 ) 

Replace the above with:

       local cab1 = createVehicle ( 514, -476, -489, 25 ) 
       local trailer1 =  createVehicle ( 584, -480, -482, 25 ) 

Link to comment

onResourceStart should be a string, therefore:

addEventHandler( "onResourceStart", root, filltruckstop) 

Remember that this will be executed when any resource start! If you don't want to do that use this instead:

addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), filltruckstop) 

Link to comment

onResourceStart should be a string, therefore:

addEventHandler( "onResourceStart", root, filltruckstop)

Remember that this will be executed when any resource start! If you don't want to do that use this instead:

addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), filltruckstop)

Link to comment

have got it almost working

its very difficult to get them to spawn attached but i think its doable if you mess with rotaionZ

function truckstopload () 
         local cab1 = createVehicle ( 514, -594, -1081, 24, 0, 0, 150 )  
         local trailer1 = createVehicle ( 584, -588, -1072, 24, 0, 0, 150 ) 
         attachTrailerToVehicle ( trailer1, cab1 ) 
end 

addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), truckstopload ) 
  

thanx for all the help ACE_GAMIT : 50p : morelli :D:D

Link to comment

have got it almost working

its very difficult to get them to spawn attached but i think its doable if you mess with rotaionZ

function truckstopload ()         local cab1 = createVehicle ( 514, -594, -1081, 24, 0, 0, 150 )          local trailer1 = createVehicle ( 584, -588, -1072, 24, 0, 0, 150 )         attachTrailerToVehicle ( trailer1, cab1 )end

addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), truckstopload ) 

thanx for all the help ACE_GAMIT : 50p : morelli :D:D

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