Skip to content

Commit

Permalink
Added files
Browse files Browse the repository at this point in the history
  • Loading branch information
L0stedMrlion authored Jun 28, 2024
1 parent a7f7f18 commit a2ebbee
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
63 changes: 63 additions & 0 deletions client/client.lua
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -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'
}
4 changes: 4 additions & 0 deletions locales/cs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"towedsoon": "Vozidlo bude brzy odtaženo!",
"towed": "Vozidlo bylo úspěsně odtaženo!"
}
4 changes: 4 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"towedsoon": "Vehicle will be towed soon!",
"towed": "Vehicle was successfully towed!"
}
18 changes: 18 additions & 0 deletions server/server.lua
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a2ebbee

Please sign in to comment.