[Release] Boat Trailer - Cart your boat around! [1.0]

        if GetDisplayNameFromVehicleModel(GetEntityModel(veh)) == "DINGHY" then
		elseif GetDisplayNameFromVehicleModel(GetEntityModel(veh)) == "FIREBOAT1" then
        elseif GetDisplayNameFromVehicleModel(GetEntityModel(veh)) == "FIREBOAT2" then
		elseif GetDisplayNameFromVehicleModel(GetEntityModel(veh)) == "LEOBOAT1" then
		elseif GetDisplayNameFromVehicleModel(GetEntityModel(veh)) == "LEOBOAT2" then

This is what I did but no workie

:man_facepalming: :man_facepalming: :man_facepalming:

That’s not how elseif's work…

explain

bruvv

can we change the boat that your able to attach in the config file? if so what line

Just put “or” after the first boat spawn_name then put the next boat.
For example it should look like this vv
…(GetEntityModel(veh)) == “PREDATOR” or “DINGHY” then

only issue is the boattrailer is small so something like the PREDATOR won’t fit like a DINGHY will.

may I ask what those fire boats are / where you got them :wink:

His custom made them by the looks of it.

Y’all still using that trailer? I need it LOL!

when i add the script to my server it doesnt seem to work i spawn in the boat trailer and they dinghy when i drive to boat on the trailer and press e it doesnt work

Is it possible to extend the radius of where the boat needs to be to go on the trailer? We are going to use this for our FD and LEO personnel to be able to haul boats to the water for calls/patrols and when they go on duty, it would be nice if they could spawn the boat on the ground next to it to get it on the trailer. (yea, I know that makes it less legit technically for getting it on their the first time but it allows us to be more legit when pulling the boat out of a station to respond to a call).

did you figure out why it won’t detach

I have edited this script to enable the SUNTRAP boat to attach nicely. My full client.lua is below so you can see (and easily adapt it to use different boats):

-----------------------------------
--- Boat Trailer, Made by FAXES ---
-----------------------------------

--- Config ---

attachKey = 51 -- Index number for attach key - http://docs.fivem.net/game-references/controls/
attachKeyName = "~INPUT_CONTEXT~" -- Key name (center column) of above key.

--- Code ---

function GetVehicleInDirection(cFrom, cTo)
    local rayHandle = CastRayPointToPoint(cFrom.x, cFrom.y, cFrom.z, cTo.x, cTo.y, cTo.z, 10, GetPlayerPed(-1), 0)
    local _, _, _, _, vehicle = GetRaycastResult(rayHandle)
    return vehicle
end

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        local ped = GetPlayerPed(-1) -- Made the whole thing forgot to add this line lol, maybe thats why it broke #4:32AMLife
        local veh = GetVehiclePedIsIn(ped)
        if veh ~= nil then
            if GetDisplayNameFromVehicleModel(GetEntityModel(veh)) == "DINGHY" then -- After a few hours here at 4am GetDisplayNameFromVehicleModel() got it working well :P
                local belowFaxMachine = GetOffsetFromEntityInWorldCoords(veh, 1.0, 0.0, -1.0)
				local boatCoordsInWorldLol = GetEntityCoords(veh)
                local trailerLoc = GetVehicleInDirection(boatCoordsInWorldLol, belowFaxMachine)
                
				if GetDisplayNameFromVehicleModel(GetEntityModel(trailerLoc)) == "BOATTRAILER" then -- Is there a trailer????
                    if IsEntityAttached(veh) then -- Is boat already attached?
                        if IsControlJustReleased(1, attachKey) then -- detach
							DetachEntity(veh, false, true)
						end
                        -- Start Prompt
                        Citizen.InvokeNative(0x8509B634FBE7DA11, "STRING") -- BeginTextCommandDisplayHelp()
						Citizen.InvokeNative(0x5F68520888E69014, "Press " .. attachKeyName .. " to detach boat.") -- AddTextComponentScaleform()
						Citizen.InvokeNative(0x238FFE5C7B0498A6, 0, false, true, -1) -- EndTextCommandDisplayHelp()
                    else
                        if IsControlJustReleased(1, attachKey) then -- Attach
							AttachEntityToEntity(veh, trailerLoc, 20, 0.0, -1.0, 0.25, 0.0, 0.0, 0.0, false, false, true, false, 20, true)
							TaskLeaveVehicle(ped, veh, 64)
                        end
                        -- Start Prompt
                        Citizen.InvokeNative(0x8509B634FBE7DA11, "STRING") -- BeginTextCommandDisplayHelp()
						Citizen.InvokeNative(0x5F68520888E69014, "Press " .. attachKeyName .. " to attach boat.") -- AddTextComponentScaleform()
						Citizen.InvokeNative(0x238FFE5C7B0498A6, 0, false, true, -1) -- EndTextCommandDisplayHelp()
                        -- Made by Faxes with some help of the bois
					end
                end
            --end --original 'end' for orig 'if' statement
			--new code below to attach SUNTRAP
			elseif GetDisplayNameFromVehicleModel(GetEntityModel(veh)) == "SUNTRAP" then -- After a few hours here at 4am GetDisplayNameFromVehicleModel() got it working well :P
                local belowFaxMachine = GetOffsetFromEntityInWorldCoords(veh, 1.0, 0.0, -1.0)
				local boatCoordsInWorldLol = GetEntityCoords(veh)
                local trailerLoc = GetVehicleInDirection(boatCoordsInWorldLol, belowFaxMachine)
                
				if GetDisplayNameFromVehicleModel(GetEntityModel(trailerLoc)) == "BOATTRAILER" then -- Is there a trailer????
                    if IsEntityAttached(veh) then -- Is boat already attached?
                        if IsControlJustReleased(1, attachKey) then -- detach
							DetachEntity(veh, false, true)
						end
                        -- Start Prompt
                        Citizen.InvokeNative(0x8509B634FBE7DA11, "STRING") -- BeginTextCommandDisplayHelp()
						Citizen.InvokeNative(0x5F68520888E69014, "Press " .. attachKeyName .. " to detach boat.") -- AddTextComponentScaleform()
						Citizen.InvokeNative(0x238FFE5C7B0498A6, 0, false, true, -1) -- EndTextCommandDisplayHelp()
                    else
                        if IsControlJustReleased(1, attachKey) then -- Attach
							AttachEntityToEntity(veh, trailerLoc, 20, 0.0, -0.6, 0.3, 0.0, 0.0, 0.0, false, false, true, false, 20, true)
							TaskLeaveVehicle(ped, veh, 64)
                        end
                        -- Start Prompt
                        Citizen.InvokeNative(0x8509B634FBE7DA11, "STRING") -- BeginTextCommandDisplayHelp()
						Citizen.InvokeNative(0x5F68520888E69014, "Press " .. attachKeyName .. " to attach boat.") -- AddTextComponentScaleform()
						Citizen.InvokeNative(0x238FFE5C7B0498A6, 0, false, true, -1) -- EndTextCommandDisplayHelp()
                        -- Made by Faxes with some help of the bois
					end
                end
            end
        end
    end
    -- Just a comment here. Why the fuck not? Its 6 am now
end)
-- All done, only lots of bullshit with code lol. Timestamp, its not 6:15AM. Why we still here? Just to suffer?
1 Like

I have RedNeck’s Boat pack in my test server, and this script doesn’t work. I was wondering if there is any way that they could work with this script? If Not is there any other script that works with addon boats?

Nice script.

Hi how do I make this compatible with redneck boats and other boats other than the dinghy

I am wondering the same

wheres that trailer

LOL - yes we are, come on by and try it out!