diff --git a/client/groups.lua b/client/groups.lua index 47f83630f..11995d7bd 100644 --- a/client/groups.lua +++ b/client/groups.lua @@ -1,20 +1,35 @@ local jobs = require 'shared.jobs' local gangs = require 'shared.gangs' ----@return table -function GetJobs() - return jobs +---@param name string? +---@return table? +function GetJobs(name) + if not name then return jobs end + + if type(name) ~= 'string' then return end + + name = name:lower() + + return jobs[name] end exports('GetJobs', GetJobs) ----@return table -function GetGangs() - return gangs +---@param name string? +---@return table? +function GetGangs(name) + if not name then return gangs end + + if type(name) ~= 'string' then return end + + name = name:lower() + + return gangs[name] end exports('GetGangs', GetGangs) +---@deprecated use the GetJobs function instead ---@param name string ---@return Job? function GetJob(name) @@ -23,6 +38,7 @@ end exports('GetJob', GetJob) +---@deprecated use the GetGangs function instead ---@param name string ---@return Gang? function GetGang(name) diff --git a/client/main.lua b/client/main.lua index 30c822180..7b985449f 100644 --- a/client/main.lua +++ b/client/main.lua @@ -3,6 +3,21 @@ QBX.PlayerData = {} QBX.Shared = require 'shared.main' QBX.IsLoggedIn = false +---@param name string? +---@return table? +function GetVehicles(name) + if not name then return QBX.Shared.Vehicles end + + if type(name) ~= 'string' then return end + + name = name:lower() + + return QBX.Shared.Vehicles[name] +end + +exports('GetVehicles', GetVehicles) + +---@deprecated use the GetVehicles function instead ---@return table function GetVehiclesByName() return QBX.Shared.Vehicles @@ -24,16 +39,30 @@ end exports('GetVehiclesByCategory', GetVehiclesByCategory) ----@return table -function GetWeapons() - return QBX.Shared.Weapons +---@param name string? +---@return table? +function GetWeapons(name) + if not name then return QBX.Shared.Weapons end + + if type(name) ~= 'string' then return end + + name = name:lower() + + return QBX.Shared.Weapons[name] end exports('GetWeapons', GetWeapons) ----@return table -function GetLocations() - return QBX.Shared.Locations +---@param name string? +---@return table? +function GetLocations(name) + if not name then return QBX.Shared.Locations end + + if type(name) ~= 'string' then return end + + name = name:lower() + + return QBX.Shared.Locations[name] end exports('GetLocations', GetLocations) diff --git a/server/groups.lua b/server/groups.lua index 0d46cfe51..74d16b5b7 100644 --- a/server/groups.lua +++ b/server/groups.lua @@ -103,20 +103,35 @@ end exports('RemoveGang', RemoveGang) ----@return table -function GetJobs() - return jobs +---@param name string? +---@return table? +function GetJobs(name) + if not name then return jobs end + + if type(name) ~= 'string' then return end + + name = name:lower() + + return jobs[name] end exports('GetJobs', GetJobs) ----@return table -function GetGangs() - return gangs +---@param name string? +---@return table? +function GetGangs(name) + if not name then return gangs end + + if type(name) ~= 'string' then return end + + name = name:lower() + + return gangs[name] end exports('GetGangs', GetGangs) +---@deprecated use the GetJobs function instead ---@param name string ---@return Job? function GetJob(name) @@ -125,6 +140,7 @@ end exports('GetJob', GetJob) +---@deprecated use the GetGangs function instead ---@param name string ---@return Gang? function GetGang(name) diff --git a/server/main.lua b/server/main.lua index 8e594fb4b..35186c7c3 100644 --- a/server/main.lua +++ b/server/main.lua @@ -18,6 +18,21 @@ QBX.Player_Buckets = {} QBX.Entity_Buckets = {} QBX.UsableItems = {} +---@param name string? +---@return table? +function GetVehicles(name) + if not name then return QBX.Shared.Vehicles end + + if type(name) ~= 'string' then return end + + name = name:lower() + + return QBX.Shared.Vehicles[name] +end + +exports('GetVehicles', GetVehicles) + +---@deprecated use the GetVehicles function instead ---@return table function GetVehiclesByName() return QBX.Shared.Vehicles @@ -39,16 +54,30 @@ end exports('GetVehiclesByCategory', GetVehiclesByCategory) ----@return table -function GetWeapons() - return QBX.Shared.Weapons +---@param name string? +---@return table? +function GetWeapons(name) + if not name then return QBX.Shared.Weapons end + + if type(name) ~= 'string' then return end + + name = name:lower() + + return QBX.Shared.Weapons[name] end exports('GetWeapons', GetWeapons) ----@return table -function GetLocations() - return QBX.Shared.Locations +---@param name string? +---@return table? +function GetLocations(name) + if not name then return QBX.Shared.Locations end + + if type(name) ~= 'string' then return end + + name = name:lower() + + return QBX.Shared.Locations[name] end exports('GetLocations', GetLocations)