Jump to content

How to attach wagon to the train?


Turbe$Z

Recommended Posts

54 minutes ago, *BeaT* said:

Use attachTrailerToVehicle function

addCommandHandler("tt",
function (player)
   if isPedInVehicle (player) then
      local theVehicle = getPedOccupiedVehicle(player)
      if getVehicleType(theVehicle) == "Train" then
			trailer = createVehicle ( 570, 0, 0, 4 )
			attachTrailerToVehicle ( theVehicle, trailer )
			outputChatBox("#FFffFFSikeresen létrehoztál egy vagont!", player, r,g,b, true)
	  else
			outputChatBox("#FFffFFMozdonyban kell ülnöd ehhez!", player, r,g,b, true)
			end
		end
	end
)

addEventHandler ( "onPlayerVehicleExit", getRootElement(),
function ( vehicle, seat, jacked, player )
local theVehicle = getPedOccupiedVehicle(player)
	if isPedInVehicle (player) then
		if getVehicleType(theVehicle) == "Train" then
			detachTrailerFromVehicle(theVehicle)
		end
	end
end
)

why not working detach? O.o 

Edited by Turbo777
Link to comment

Event parameters

Quote

Parameters


vehicle theVehicle, int seat, player jacker
  • theVehicle: A vehicle element representing the vehicle in which the player exited from
  • seat: An integer representing the seat in which the player was before exiting
  • jacker: A player element representing the player who jacked the driver

Source

The source of this event is the player that left the vehicle.

 

addEventHandler ( "onPlayerVehicleExit", getRootElement(),
function ( vehicle, seat, jacked )
		if getVehicleType(theVehicle) == "Train" then
			detachTrailerFromVehicle(theVehicle)
		end
end, )

 

  • Like 1
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...