detachTrailerFromVehicle | Multi Theft Auto: Wiki Skip to content

detachTrailerFromVehicle

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function detaches an already attached trailer from a vehicle.

Note

If 'theTrailer' is specified, it will only detach if this matches. If it is not specified, any trailer attached to 'theVehicle' will be detached.

Syntax

detachTrailerFromVehicle ( )

Code Examples

server

Example 1:A command for players to detach a trailer attached to their vehicle:

-- the handler function for the "unhook" console command
function unhookTrailer(playerSource, commandName)
-- check if a player triggered this command and that they are in a vehicle
if (playerSource and isPedInVehicle(playerSource)) then
local theVehicle = getPedOccupiedVehicle(playerSource) -- get the vehicle the player is in
local success = detachTrailerFromVehicle(theVehicle) -- attempt to detach a trailer from this vehicle
-- report whether the operation waa a success
if (success) then
outputConsole("Trailer detached!", playerSource)
else
outputConsole("Failed to detach trailer.", playerSource)
end
end
end
-- make the function above handle the "unhook" command
addCommandHandler("unhook", unhookTrailer)

See Also

Vehicle Functions