Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Gang System #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 76 additions & 1 deletion client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -950,14 +1024,15 @@ 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
elseif CurrentHouseGarage then
TriggerEvent('qb-garages:client:OpenHouseGarage')
end
end)

RegisterNetEvent('qb-garages:client:ParkVehicle', function()
local ped = PlayerPedId()
local canPark = true
Expand Down
29 changes: 29 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion locales/da.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
3 changes: 2 additions & 1 deletion locales/de.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
3 changes: 2 additions & 1 deletion locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
3 changes: 2 additions & 1 deletion locales/es.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
3 changes: 2 additions & 1 deletion locales/fr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
1 change: 1 addition & 0 deletions locales/sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
3 changes: 2 additions & 1 deletion locales/tr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down