Skip to content

Commit

Permalink
feat(server/main): getter param overloads to get table entry only (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason authored Dec 1, 2024
1 parent 8e06398 commit 38473d9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,19 @@ end
exports('GetVehicleClass', GetVehicleClass)

---@return table<string, Vehicle>
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<number, Vehicle>
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)
Expand All @@ -119,8 +123,10 @@ end
exports('GetVehiclesByCategory', GetVehiclesByCategory)

---@return table<number, Weapon>
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)
Expand Down

0 comments on commit 38473d9

Please sign in to comment.