From 38473d94f8fa811957e7f4237ecf333bb930091a Mon Sep 17 00:00:00 2001 From: Manason Date: Sat, 30 Nov 2024 23:49:05 -0800 Subject: [PATCH] feat(server/main): getter param overloads to get table entry only (#628) --- server/main.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server/main.lua b/server/main.lua index b5d267190..283383b4a 100644 --- a/server/main.lua +++ b/server/main.lua @@ -98,15 +98,19 @@ end exports('GetVehicleClass', GetVehicleClass) ---@return table -function GetVehiclesByName() - return QBX.Shared.Vehicles +---@overload fun(key: string): Vehicle +function GetVehiclesByName(key) + local vehicles = QBX.Shared.Vehicles + return vehicles[key] or vehicles end exports('GetVehiclesByName', GetVehiclesByName) ---@return table -function GetVehiclesByHash() - return QBX.Shared.VehicleHashes +---@overload fun(key: number): Vehicle +function GetVehiclesByHash(key) + local vehicles = QBX.Shared.VehicleHashes + return vehicles[key] or vehicles end exports('GetVehiclesByHash', GetVehiclesByHash) @@ -119,8 +123,10 @@ end exports('GetVehiclesByCategory', GetVehiclesByCategory) ---@return table -function GetWeapons() - return QBX.Shared.Weapons +---@overload fun(key: number): Weapon +function GetWeapons(key) + local weapons = QBX.Shared.Weapons + return weapons[key] or weapons end exports('GetWeapons', GetWeapons)