[Release] Towtruck Script V1.2

asser-tow

This is a basic tow script for fivem using chat commands.

The script as is only works using a flatbed. Changeing the flatbed model on your server might break the script as it attaches the vehicle you want to tow to a specific bone on the flatbed.

Please note that if the last vehicle you’ve used is not the flatbed truck you want to tow something on, then you wont be able to tow, and theres no distance built into the script yet, so it wont know if you are towing a vehicle 100ft away or just 10ft away. Either make it yourself or wait for an update :wink:

Download

Installation:

Clone the project or download the master.

Add asser-tow to resources folder.

Add “start asser-tow” to server.cfg

Usage:

Drive a ‘flatbed’ - (the script looks for your last driven vehicle, and it needs it to be a flatbed)

Go near a vehicle you want to tow and write /tow in the chat-

Drive around

Exit flatbed and write /tow to detach vehicle again.

V1.1 - for ES

pv-tow.zip - Did not show error if no vehicle was to tow. Now it does.

V1.2 - for FX

pv-tow.zip
Changelog: Removed all ES command stuff and used the stringsplit instead since mostly people working with ES would know how to convert it. Also change stringsplit to one working with FX which means that it should be working perfectly. Tested and working on FX

V1.3 - Githubbed

Project now gitted, all future versions and contributions goes here + changed name since projectviking no more exists.

26 Likes

OMG U are amazing thanks!

1 Like

That chat message though. Lmao! :+1:

Yah, had to put something in :wink:

@asser90 nice! SoE doesn’t even have that sort of check. I’ve seen a tow truck on a tow truck being towed by a tow truck. Lol.

I am getting the message “Vehicle successfully attached to towtruck!”, but the car does not actually get attached,

No errors ? Console - F8 ingame ?

EDIT:

I see the error occurs when theres not a vehicle infront of you. - That is btw the only check it does. If vehicle infront is more than 5 ft away it wont do anything.

Your awesome Thanks for sharing

Just released a hotfix due to @Refuser having a problem where it would tow even if there was nothing to tow. - Thats not the case now.

Thanks that was the problem. Works perfect

thx for the release @asser90 keep up the good work

yeah for some reason when i go by vehicles parked i type /tow and nothing happens i just get theres no vehicle to tow

1 Like

the vehicle should be behind the towtruck. after exiting the tow truck stand near the drivers side front tire of the car you wish to tow. look towards the car you wish to tow not the towtruck.

I would like to thank you for supplying this to us it is a great script I love it .
Has somebody found a way to implement this so we can create jobs and get paid using essential mode and Freeroam?

This does not necessarily have to be built into a jobscript. It can function as if you are just using the flatbed at all.

We would need to create another table in the database for this to work in order to get paid ?

__resource.lua

-- Towtruck script by Asser90

-- Manifest
resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'

-- General
client_script 'cl_tow.lua'
server_script 'sv_tow.lua' 
server.lua : 
AddEventHandler('chatMessage', function(source, n, message)
    cm = stringsplit(message, " ")

    if(cm[1] == "/tow") then
		CancelEvent()
		TriggerClientEvent("pv:tow", source)
	end
end)

function stringsplit(self, delimiter)
  local a = self:Split(delimiter)
  local t = {}

  for i = 0, #a - 1 do
     table.insert(t, a[i])
  end

  return t
end

This is a modification for people that don’t use ESseintialmode . Be advised that i changed the clientevent nime from pv:tow or how it was to tow on my side,

This wont need to be changed in anyway for a mission to work ppl…

Just make a towtruckmission script that does whatever you like. The script can always listen for if a specific vehicle was towed to a specific place. It has nothing to do with this script…

hi, when i spawn personal vehicle, i can’t /tow this vehicle, work only with vehicule(ped) in circulation

do you have to spawn a flatbed yourself or you have to find one on the street?