ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. detachTrailerFromVehicle

Function

detachTrailerFromVehicle

ServerVehiclesIdentical to MTA:SA

Detaches a trailer from the towing vehicle for every player and fires onTrailerDetach on the trailer. A specific trailer can be given; then the function only works if that trailer is the one attached.

Syntax

bool detachTrailerFromVehicle(vehicle truck [, vehicle trailer = nil])

Arguments

truckvehicle
The towing vehicle.
trailervehicle, optional = nil
The trailer to detach; nil = whichever is attached.

Returns

true when detached; false when nothing was attached.

Example

addCommandHandler("odczep", function(player)
    local truck = getPedOccupiedVehicle(player)
    if truck then detachTrailerFromVehicle(truck) end
end)

See also