├── Credits.txt ├── README.md ├── TOS.txt └── Tow-script ├── README.md ├── __resource.lua └── client.lua /Credits.txt: -------------------------------------------------------------------------------- 1 | Join the raven mods discord here: https://discord.gg/ZZK43qQeMt 2 | 3 | Thanks To our script developer Killer-one96 aka Eagle Production Mods for making this! 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Do not re-sale or claim this as yours. 2 | you may edit the script as you feel fit 3 | 4 | If you need help with the scrpit Go to "Raven Mods" on discord 5 | 6 | command is "/tow" in chat 7 | you can add basicly any flat bed tow truck and config the cars/trucks to sit perfectly on the trucks 8 | 9 | If you need any help or want to check out our other stuff join our discord here! https://discord.gg/ZZK43qQeMt 10 | -------------------------------------------------------------------------------- /TOS.txt: -------------------------------------------------------------------------------- 1 | Do Not Leak This Script Or Claim it as your own 2 | 3 | If you want to re release it with edits you MUST have raven's express permission to do so. -------------------------------------------------------------------------------- /Tow-script/README.md: -------------------------------------------------------------------------------- 1 | Do not re-sale or claim this as yours. 2 | you may edit the script as you feel fit 3 | 4 | If you need help with the scrpit Go to "Raven Mods" on discord 5 | 6 | command is "/tow" in chat 7 | you can add basicly any flat bed tow truck and config the cars/trucks to sit perfectly on the trucks -------------------------------------------------------------------------------- /Tow-script/__resource.lua: -------------------------------------------------------------------------------- 1 | -- Created by Eagle Production Mods 2 | resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' 3 | 4 | client_script 'client.lua' 5 | -------------------------------------------------------------------------------- /Tow-script/client.lua: -------------------------------------------------------------------------------- 1 | -- Created by Eagle Mods 2 | 3 | -- NOTICE 4 | -- This script is licensed under "No License". https://choosealicense.com/no-license/ 5 | -- You are allowed to: Download, Use and Edit the Script. 6 | -- You are not allowed to: Copy, re-release, re-distribute it without our written permission. 7 | 8 | -- These vehicles will be registered as "allowed/valid" tow trucks. 9 | -- Change the x, y and z offset values for the towed vehicles to be attached to the tow truck. 10 | -- x = left/right, y = forwards/backwards, z = up/down 11 | local allowedTowModels = { 12 | ['flatbed'] = {x = 0.0, y = -0.85, z = 1.25}, -- default GTA V flatbed 13 | } 14 | 15 | 16 | local allowTowingBoats = false -- Set to true if you want to be able to tow boats. 17 | local allowTowingPlanes = false -- Set to true if you want to be able to tow planes. 18 | local allowTowingHelicopters = false -- Set to true if you want to be able to tow helicopters. 19 | local allowTowingTrains = false -- Set to true if you want to be able to tow trains. 20 | local allowTowingTrailers = true -- Disables trailers. NOTE: THIS ALSO DISABLES THE AIRTUG, TOWTRUCK, SADLER, AND ANY OTHER VEHICLE THAT IS IN THE UTILITY CLASS. 21 | 22 | local currentlyTowedVehicle = nil 23 | 24 | RegisterCommand("tow", function() 25 | TriggerEvent("tow") 26 | end,false) 27 | 28 | 29 | 30 | function isTargetVehicleATrailer(modelHash) 31 | if GetVehicleClassFromName(modelHash) == 11 then 32 | return true 33 | else 34 | return false 35 | end 36 | end 37 | 38 | local xoff = 0.0 39 | local yoff = 0.0 40 | local zoff = 0.0 41 | 42 | function isVehicleATowTruck(vehicle) 43 | local isValid = false 44 | for model,posOffset in pairs(allowedTowModels) do 45 | if IsVehicleModel(vehicle, model) then 46 | xoff = posOffset.x 47 | yoff = posOffset.y 48 | zoff = posOffset.z 49 | isValid = true 50 | break 51 | end 52 | end 53 | return isValid 54 | end 55 | 56 | RegisterNetEvent('tow') 57 | AddEventHandler('tow', function() 58 | 59 | local playerped = PlayerPedId() 60 | local vehicle = GetVehiclePedIsIn(playerped, true) 61 | 62 | local isVehicleTow = isVehicleATowTruck(vehicle) 63 | 64 | if isVehicleTow then 65 | 66 | local coordA = GetEntityCoords(playerped, 1) 67 | local coordB = GetOffsetFromEntityInWorldCoords(playerped, 0.0, 5.0, 0.0) 68 | local targetVehicle = getVehicleInDirection(coordA, coordB) 69 | 70 | 71 | Citizen.CreateThread(function() 72 | while true do 73 | Citizen.Wait(0) 74 | isVehicleTow = isVehicleATowTruck(vehicle) 75 | local roll = GetEntityRoll(GetVehiclePedIsIn(PlayerPedId(), true)) 76 | if IsEntityUpsidedown(GetVehiclePedIsIn(PlayerPedId(), true)) and isVehicleTow or roll > 70.0 or roll < -70.0 then 77 | DetachEntity(currentlyTowedVehicle, false, false) 78 | currentlyTowedVehicle = nil 79 | ShowNotification("~o~~h~Tow Service:~n~~s~Looks like the cables holding on the vehicle have broke!") 80 | end 81 | 82 | end 83 | end) 84 | 85 | if currentlyTowedVehicle == nil then 86 | if targetVehicle ~= 0 then 87 | local targetVehicleLocation = GetEntityCoords(targetVehicle, true) 88 | local towTruckVehicleLocation = GetEntityCoords(vehicle, true) 89 | local distanceBetweenVehicles = GetDistanceBetweenCoords(targetVehicleLocation, towTruckVehicleLocation, false) 90 | -- print(tostring(distanceBetweenVehicles)) -- debug only 91 | -- Distance allowed (in meters) between tow truck and the vehicle to be towed 92 | if distanceBetweenVehicles > 12.0 then 93 | ShowNotification("~o~~h~Tow Service:~n~~s~Your cables can't reach this far. Move your tow truck closer to the vehicle.") 94 | else 95 | local targetModelHash = GetEntityModel(targetVehicle) 96 | -- Check to make sure the target vehicle is allowed to be towed (see settings at lines 8-12) 97 | if not ((not allowTowingBoats and IsThisModelABoat(targetModelHash)) or (not allowTowingHelicopters and IsThisModelAHeli(targetModelHash)) or (not allowTowingPlanes and IsThisModelAPlane(targetModelHash)) or (not allowTowingTrains and IsThisModelATrain(targetModelHash)) or (not allowTowingTrailers and isTargetVehicleATrailer(targetModelHash))) then 98 | if not IsPedInAnyVehicle(playerped, true) then 99 | if vehicle ~= targetVehicle and IsVehicleStopped(vehicle) then 100 | -- TriggerEvent('chatMessage', '', {255,255,255}, xoff .. ' ' .. yoff .. ' ' .. zoff) -- debug line 101 | AttachEntityToEntity(targetVehicle, vehicle, GetEntityBoneIndexByName(vehicle, 'bodyshell'), 0.0 + xoff, -1.5 + yoff, 0.0 + zoff, 0, 0, 0, 1, 1, 0, 1, 0, 1) 102 | currentlyTowedVehicle = targetVehicle 103 | ShowNotification("~o~~h~Tow Service:~n~~s~Vehicle has been loaded onto the flatbed.") 104 | else 105 | ShowNotification("~o~~h~Tow Service:~n~~s~There is currently no vehicle on the flatbed.") 106 | end 107 | else 108 | ShowNotification("~o~~h~Tow Service:~n~~s~You need to be outside of your vehicle to load or unload vehicles.") 109 | end 110 | else 111 | ShowNotification("~o~~h~Tow Service:~n~~s~Your tow truck is not equipped to tow this vehicle.") 112 | end 113 | end 114 | else 115 | ShowNotification("~o~~h~Tow Service:~n~~s~No towable vehicle detected.") 116 | end 117 | elseif IsVehicleStopped(vehicle) then 118 | DetachEntity(currentlyTowedVehicle, false, false) 119 | local vehiclesCoords = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, -12.0, 0.0) 120 | SetEntityCoords(currentlyTowedVehicle, vehiclesCoords["x"], vehiclesCoords["y"], vehiclesCoords["z"], 1, 0, 0, 1) 121 | SetVehicleOnGroundProperly(currentlyTowedVehicle) 122 | currentlyTowedVehicle = nil 123 | ShowNotification("~o~~h~Tow Service:~n~~s~Vehicle has been unloaded from the flatbed.") 124 | end 125 | else 126 | ShowNotification("~o~~h~Tow Service:~n~~s~Your vehicle is not registered as an official tow truck.") 127 | end 128 | end) 129 | 130 | function getVehicleInDirection(coordFrom, coordTo) 131 | local rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, PlayerPedId(), 0) 132 | local a, b, c, d, vehicle = GetRaycastResult(rayHandle) 133 | return vehicle 134 | end 135 | 136 | function ShowNotification(text) 137 | SetNotificationTextEntry("STRING") 138 | AddTextComponentSubstringPlayerName(text) 139 | DrawNotification(false, false) 140 | end 141 | --------------------------------------------------------------------------------