From b4ab52c9aa3408cc2b8fb08f3492320d2ab16486 Mon Sep 17 00:00:00 2001 From: Tomi Date: Wed, 14 Feb 2024 03:37:54 -0300 Subject: [PATCH] Gang System --- client/main.lua | 77 ++++++++++++++++++++++++++++++++++++++++++++++++- config.lua | 29 +++++++++++++++++++ locales/da.lua | 3 +- locales/de.lua | 3 +- locales/en.lua | 3 +- locales/es.lua | 3 +- locales/fr.lua | 3 +- locales/sv.lua | 1 + locales/tr.lua | 3 +- 9 files changed, 118 insertions(+), 7 deletions(-) diff --git a/client/main.lua b/client/main.lua index 8001800..8a80110 100755 --- a/client/main.lua +++ b/client/main.lua @@ -588,6 +588,80 @@ function JobMenuGarage(garageName) exports['qb-menu']:openMenu(vehicleMenu) end +function GangMenuGarage(garageName) + local playerGang = PlayerGang.name + local garage = Config.Garages[garageName] + local gangGarage = Config.GangVehicles[garage.gangGarageIdentifier] + + if not gangGarage then + if garage.gangGarageIdentifier then + TriggerEvent('QBCore:Notify', + string.format('Gang garage with id %s not configured.', garage.gangGarageIdentifier), 'error', 5000) + else + TriggerEvent('QBCore:Notify', + string.format("'gangGarageIdentifier' not defined on job garage %s ", garageName), 'error', 5000) + end + return + end + + local vehicleMenu = {{ + header = gangGarage.label, + isMenuHeader = true + }} + + local gangGrade = QBCore.Functions.GetPlayerData().gang.grade.level + local vehicles = gangGarage.vehicles[gangGrade] + + for index, data in pairs(vehicles) do + local model = index + local label = data + local vehicleConfig = nil + local addVehicle = true + + if type(data) == "table" then + local vehicleGang = data.gang + if vehicleGang then + if type(vehicleGang) == "table" and not TableContains(vehicleGang, playerGang) then + addVehicle = false + elseif playerJob ~= vehicleGang then + addVehicle = false + end + end + + if addVehicle then + label = data.label + model = data.model + vehicleConfig = Config.VehicleSettings[data.configName] + end + end + + if addVehicle then + vehicleMenu[#vehicleMenu + 1] = { + header = label, + txt = "", + params = { + event = "qb-garages:client:TakeOutGarage", + args = { + vehicleModel = model, + garage = garage, + vehicleConfig = vehicleConfig + } + } + } + end + end + + vehicleMenu[#vehicleMenu + 1] = { + header = Lang:t('menu.leave.gang'), + txt = "", + params = { + event = "qb-menu:client:closeMenu" + } + } + + exports['qb-menu']:openMenu(vehicleMenu) +end + function GetFreeParkingSpots(parkingSpots) local freeParkingSpots = {} for _, parkingSpot in ipairs(parkingSpots) do @@ -950,6 +1024,8 @@ RegisterNetEvent('qb-garages:client:OpenMenu', function() local garageType = garage.type if garageType == 'job' and garage.useVehicleSpawner then JobMenuGarage(CurrentGarage) + elseif garageType == 'gang' and garage.useVehicleSpawner then + GangMenuGarage(CurrentGarage) else PublicGarage(CurrentGarage, garageType) end @@ -957,7 +1033,6 @@ RegisterNetEvent('qb-garages:client:OpenMenu', function() TriggerEvent('qb-garages:client:OpenHouseGarage') end end) - RegisterNetEvent('qb-garages:client:ParkVehicle', function() local ped = PlayerPedId() local canPark = true diff --git a/config.lua b/config.lua index 9ad4271..609f9b5 100755 --- a/config.lua +++ b/config.lua @@ -35,6 +35,7 @@ Config = Config or {} -- job = {'police', 'ambulance'), -- optional, multi job support useVehicleSpawner = true, uses the configured job vehicles, make sure to have the job attribute set! (job = 'police') <--- NEW jobGarageIdentifier = 'pd1', required when using vehicle spawner, references the JobVehicles down below, make sure this matches what you used in the JobVehicles table <--- NEW + gangGarageIdentifier = 'pd1', required when using vehicle spawner, references the GangVehicles down below, make sure this matches what you used in the GangVehicles table <--- NEW gang = 'vagos', -- optional, same as job but for gangs, do not use both -- gang = {'vagos', 'gsf'}, -- optional, multi gang support jobVehiclesIndex = 'pd1', -- the corresponding index (JobVehicles) @@ -185,6 +186,34 @@ Config.JobVehicles = { } } +Config.GangVehicles = { + ['ballas'] = { -- <-- jobGarageIdentifier + label = "Ballas", + vehicles = { + -- Grade 0 + [0] = { + ["sultan"] = "Sultan" + }, + -- Grade 1 + [1] = { + ["sultan"] = "Sultan" + }, + -- Grade 2 + [2] = { + ["sultan"] = "Sultan" + }, + -- Grade 3 + [3] = { + ["sultan"] = "Sultan" + }, + -- Grade 4 + [4] = { + ["sultan"] = "Sultan" + } + } + } +} + Config.VehicleSettings = { ['myUniqueNameForThisCarConfiguration'] = { -- configName ["livery"] = 1, diff --git a/locales/da.lua b/locales/da.lua index 388f1be..1b7bf65 100644 --- a/locales/da.lua +++ b/locales/da.lua @@ -39,7 +39,8 @@ local Translations = { car = "⬅ Forlad garagen", sea = "⬅ Forlad bådehus", air = "⬅ Forlad Hangar", - job = "⬅ Forlad garagen" + job = "⬅ Forlad garagen", + gang = "⬅ Forlad garagen", }, text = { vehicles = "Se lagrede køretøjer!", diff --git a/locales/de.lua b/locales/de.lua index eb92b16..28fc63b 100755 --- a/locales/de.lua +++ b/locales/de.lua @@ -39,7 +39,8 @@ local Translations = { car = "⬅ Verlasse Garage", sea = "⬅ Verlasse Bootshaus", air = "⬅ Verlasse Hangar", - job = "⬅ Verlasse Garage" + job = "⬅ Verlasse Garage", + gang = "⬅ Verlasse Garage", }, text = { vehicles = "Deine geparkten Autos!", diff --git a/locales/en.lua b/locales/en.lua index 70ce398..79287c3 100755 --- a/locales/en.lua +++ b/locales/en.lua @@ -39,7 +39,8 @@ local Translations = { car = "⬅ Leave Garage", sea = "⬅ Leave Boathouse", air = "⬅ Leave Hangar", - job = "⬅ Leave Garage" + job = "⬅ Leave Garage", + gang = "⬅ Leave Garage", }, text = { vehicles = "View stored vehicles!", diff --git a/locales/es.lua b/locales/es.lua index 25718c3..350a87e 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -39,7 +39,8 @@ local Translations = { car = "⬅ Salir garaje", sea = "⬅ Salir marina", air = "⬅ Salir hangar", - job = "⬅ Salir garaje" + job = "⬅ Salir garaje", + gang = "⬅ Salir garaje", }, text = { vehicles = "¡Ver vehículos estacionados!", diff --git a/locales/fr.lua b/locales/fr.lua index af35af3..0773870 100755 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -39,7 +39,8 @@ local Translations = { car = "⬅ Quitter le garage", sea = "⬅ Quitter le hangar à bateaux", air = "⬅ Quitter le Hangar", - job = "⬅ Quitter le garage" + job = "⬅ Quitter le garage", + gang = "⬅ Quitter le garage" }, text = { vehicles = "Voir les véhicules stockés!", diff --git a/locales/sv.lua b/locales/sv.lua index 6e2709a..61543bd 100755 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -40,6 +40,7 @@ local Translations = { sea = "⬅ Lämna båthus", air = "⬅ Lämna Hangar", job = "⬅ Lämna garage", + gang = "⬅ Lämna garage" }, text = { vehicles = "Visa dina parkerade fordon!", diff --git a/locales/tr.lua b/locales/tr.lua index c6de427..f8b0ad7 100755 --- a/locales/tr.lua +++ b/locales/tr.lua @@ -39,7 +39,8 @@ local Translations = { car = "⬅ Garajdan Ayrıl", sea = "⬅ Bot Garajından Ayrıl", air = "⬅ Hangardan Ayrıl", - job = "⬅ Garajdan Ayrıl" + job = "⬅ Garajdan Ayrıl", + gang = "⬅ Garajdan Ayrıl" }, text = { vehicles = "Garajdaki arçaları görüntüle!",