[FREE] Flatbed Script

One issue. When someone takes it out of jg-garages

this happens

4 Likes

I am not sure what the issue would be here, I personally do not use jg-garages.

What my script at least does is the following:

  • When a flatbed vehicle is spawned, it attempts to spawn a bed-prop onto the vehicle. This is server-sided, to ensure a smooth synchronization between clients.
  • It then sends an event to the entity owner, to physically connect the flatbed vehicle and the bed-prop.
  • If something goes wrong here, the server is notified and the bed-prop is attempted to be despawned, and it tries again by spawning a new bed-prop.

I am not sure if there is something in jg-garages that breaks this. Do you experience this only when using jg-garages?

Yes, I do, Very weird

I have had the same issues on my test server with nothing else running other than ox.

Hey, really awesome script! You can tell right away that you’ve put some real thought into fixing the usual issues most flatbed scripts have — sync, performance, and bugs. It runs smoothly and feels way more polished than many of the overpriced paid versions out there.

I’ve seen a few similar scripts before, but I really like your focus on optimization and immersion. If you manage to add a winch or tow cable system to pull damaged vehicles onto the flatbed — that would be the cherry on top. It’d make the whole thing even more immersive and useful!

Keep it up, can’t wait to see where you take this next! :articulated_lorry::sparkles:

1 Like

Thank you for the kind words!

I actually looked into a winch/rope before, but in my experience (proper) synchronization can be quite a challenge since rope physics are not synced between clients.

Maybe I will look into this again in the future :slight_smile:

1 Like

Hey, totally understandable — syncing rope physics between clients is nearly impossible in GTA/FiveM.
Here’s a simple and stable workaround that simulates a realistic winch without using rope physics:

  1. Simulate the winch pull (no rope needed)
  2. Attach and lock the vehicle once on the bed
  3. Optionally add a fake rope prop for immersion

Example implementation:

local pulling = false

RegisterNetEvent("flatbed:winchVehicle", function()
    local flatbed = GetVehiclePedIsIn(PlayerPedId(), false)
    local veh = GetClosestVehicle(GetEntityCoords(flatbed), 6.0, 0, 70)
    if not veh or veh == 0 then return end

    local bedCoords = GetOffsetFromEntityInWorldCoords(flatbed, 0.0, -6.0, 0.2)
    local targetCoords = GetOffsetFromEntityInWorldCoords(flatbed, 0.0, -2.0, 0.6)

    pulling = true
    PlaySoundFromEntity(-1, "Winch_Start", flatbed, "DLC_HEIST_PLANNING_BOARD_SOUNDS", false, 0)

    local steps = 50
    for i = 1, steps do
        if not pulling then break end
        local ratio = i / steps
        local newPos = vec3(
            bedCoords.x + (targetCoords.x - bedCoords.x) * ratio,
            bedCoords.y + (targetCoords.y - bedCoords.y) * ratio,
            bedCoords.z + (targetCoords.z - bedCoords.z) * ratio
        )
        SetEntityCoords(veh, newPos.x, newPos.y, newPos.z, false, false, false, false)
        Wait(100)
    end

    AttachEntityToEntity(veh, flatbed, 20, 0.0, -2.0, 0.6, 0.0, 0.0, 0.0, false, false, true, false, 2, true)
    PlaySoundFromEntity(-1, "Winch_Stop", flatbed, "DLC_HEIST_PLANNING_BOARD_SOUNDS", false, 0)
    pulling = false
end)

This moves the vehicle smoothly up the ramp and fixes it in place — no desync, no physics glitches, and it looks like a real winch in action.
If desired, add a small prop (like “prop_rope_hook_01”) between flatbed and vehicle for the visual cable effect.

GreetZ,
NebelRebell
Nebelbank.net

Maybe in the future I will work on an update. In the meantime, if you need a script to push broken vehicles on the flatbed, we also offer a free vehicle push script: Free FiveM Vehicle Push Script | Gamzky Scripts

1 Like

Update (1.0.1),

  • A small rework is done on the spawning and attaching of bed props. This should decrease the occurrences of beds not properly attaching to vehicles.
  • You can now also configure multiple flatbed vehicles in the script, if your server uses more than one flatbed vehicle model.

@XyroGFX @ArduousGamer Maybe this update fixes the issues you guys were facing.

4 Likes

how do we get the car on the flatbed when the car is completely broken down (cant move at all)… can you install a rope in the next update please

If you need a script to push broken vehicles on the flatbed, we also offer a free vehicle push script: Free FiveM Vehicle Push Script | Gamzky Scripts

1 Like

maybe add a rope to the flatbed script, it would be more realistic please boss


Awesome script bro, i am also using JG-garages and everything works unless i interact with the garage with the flatbed at all. The bed seems to duplicate each time. Here are the only warnings i am noticing:
Warning: [entity] NETWORK_GET_NETWORK_ID_FROM_ENTITY: no net object for entity (script id 1432066)^7

I am not sure about the rules on all this stuff but I ended up going through the ringer with chatgpt because i have minimal programming knowledge. In the end i was able to fix the issue with JG garages. I am willing to share the edited sv_main as long as its allowed. Just going to wait for confirmation

1 Like

Hi @Sansuish,

You are free to share any code or fixes here that may also help other users! :slight_smile:

Other users also faced issues when using jg-garage, so it may help them as well.

sv_main.lua (6.3 KB)
Like i said i really am a noob so for all i know this could be less optimized than the original but it works with jg-garages for me. Again, thank you for the awesome script!

1 Like

You fixed it?

i mean it works with JG garages, but technically ChatGPT fixed it haha

New free tow script release

Since there were a lot of requests, I also released a free tow script which works together with the flatbed script. Check it out here: [FREE] Tow Rope Script

@NebelRebell @EldrinP

1 Like

I can’t and others can’t on our test server get the bed to load.