diff --git a/client/client.lua b/client/client.lua new file mode 100644 index 0000000..74f6452 --- /dev/null +++ b/client/client.lua @@ -0,0 +1,63 @@ +lib.locale() + +if Config.target == "ox" or Config.target == "ox_target" then +local vehicleOptions = { + icon = Config.icon, + label = Config.label, + distance = Config.distance, + groups = Config.jobs, + onSelect = function(data) + if lib.progressBar({ + duration = Config.progressBarduration, + label = Config.progressBarlabel, + useWhileDead = false, + canCancel = true, + disable = { + car = true, + move = true, + combat = true, + }, + anim = { scenario = Config.towingScenario } + }) then + Notify("Towing", locale("towedsoon"), 2500) + Wait(Config.WaitTimeBeforeDelete) + TriggerServerEvent('lion_towing:tow', NetworkGetNetworkIdFromEntity(data.entity)) + Notify("Towing", locale("towed"), 2500) + end + end +} +exports.ox_target:addGlobalVehicle(vehicleOptions) + +elseif Config.target == "qb" or Config.target == "qb-target" then + local vehicleOptions = { + { + label = Config.label, + icon = Config.icon, + job = Config.jobs, + action = function(entity) + if lib.progressBar({ + duration = Config.progressBarduration, + label = Config.progressBarlabel, + useWhileDead = false, + canCancel = true, + disable = { + car = true, + move = true, + combat = true, + }, + anim = { scenario = Config.towingScenario } + }) then + Notify("Towing", locale("towedsoon"), 2500) + Wait(Config.WaitTimeBeforeDelete) + TriggerServerEvent('lion_towing:tow', NetworkGetNetworkIdFromEntity(entity)) + Notify("Towing", locale("towed"), 2500) + end + end + } + } + + exports['qb-target']:AddTargetModel(GetHashKey('adder'), { + options = vehicleOptions, + distance = Config.distance + }) +end \ No newline at end of file diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..2ec2b79 --- /dev/null +++ b/config.lua @@ -0,0 +1,24 @@ +Config = {} + +-- TARGET SETTINGS +Config.target = "ox" -- ox_target/ox or qb-target/qb +Config.icon = "fas fa-car-side" -- Only fontawesome icons free https://fontawesome.com/search?o=r&m=free +Config.label = "Tow Vehicle" -- Text on the target +Config.distance = 2.0 -- Distance when you see the target on the vehicle +Config.jobs = {['police']= 0} -- For more groups {['police']= 0, ['sheriff']= 0 } or just "police" + +-- PROGRESSBAR SETTINGS / If you want edit more go to client/client.lua +Config.progressBarduration = 5000 -- DURATION IN MILISECONDS +Config.progressBarlabel = "🚗 Towing Vehicle" -- TEXT ON THE PROGRESSBAR +Config.towingScenario = "WORLD_HUMAN_CLIPBOARD" -- https://github.com/DioneB/gtav-scenarios +Config.WaitTimeBeforeDelete = 8000 -- IN MILISECONDS, Time when you tow and need to wait before the vehicle is deleted + +Notify = function(title, desciption, duration) -- SET HERE YOUR OWN NOTIFICATIONS + lib.notify({ + title = title, + description = desciption, + icon = 'fas fa-car-side', + iconColor = "#db9d00", + duration = duration + }) +end \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua new file mode 100644 index 0000000..159f3e6 --- /dev/null +++ b/fxmanifest.lua @@ -0,0 +1,26 @@ +fx_version "cerulean" +game "gta5" +lua54 "true" + +name "lion_towing" +author "Mrlion (@lostedmrlion)" +description "Standalone for towing vehicles" +version '2.0' +repository 'https://github.com/L0stedMrlion/lion_towing' + +shared_scripts { + '@ox_lib/init.lua', + "config.lua" +} + +client_scripts { + "client/client.lua" +} + +server_scripts { + "server/server.lua" +} + +files { + 'locales/*.json' +} diff --git a/locales/cs.json b/locales/cs.json new file mode 100644 index 0000000..eb71896 --- /dev/null +++ b/locales/cs.json @@ -0,0 +1,4 @@ +{ + "towedsoon": "Vozidlo bude brzy odtaženo!", + "towed": "Vozidlo bylo úspěsně odtaženo!" +} diff --git a/locales/en.json b/locales/en.json new file mode 100644 index 0000000..9aea9e4 --- /dev/null +++ b/locales/en.json @@ -0,0 +1,4 @@ +{ + "towedsoon": "Vehicle will be towed soon!", + "towed": "Vehicle was successfully towed!" +} diff --git a/server/server.lua b/server/server.lua new file mode 100644 index 0000000..fd3aeb0 --- /dev/null +++ b/server/server.lua @@ -0,0 +1,18 @@ +RegisterNetEvent('lion_towing:tow',function (entity) + DeleteEntity(NetworkGetEntityFromNetworkId(entity)) +end) + +if not lib.checkDependency('ox_lib', '3.22.2') then + error() +end + +AddEventHandler('onResourceStart', function(resourceName) + if resourceName ~= GetCurrentResourceName() then + return + end + + if resourceName ~= "lion_towing" then + lib.print.warn("The resource name must be 'lion_towing'. Current resource name: " .. resourceName) + StopResource(resourceName) + end +end)