-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add export GetVehiclesByCategory() #183
Comments
So i guess, if i understand what you'd like correctly, that you'd want a function like this? ---@param vehicle model | hash
---@param category string
function GetVehicles(vehicle, category)
...
end) |
Negative. I mean a function that returns all the vehicles, mapped by category so that I can do exports.qbx_core:GetVehiclesByCategory()[category] |
I'm talking about that 🤔
|
Given that we already store this mapping in core, I think the export route is preferred over the module solution. |
The problem
It's a common operation to create a map of categories to vehicles. adminmenu & vehicleshop both do it. This results in duplicate code across resources implementing the same feature
Ideal solution
create a centralized core export to reduce duplicate code in other resources for a common operation.
Alternative solutions
add a utility function to the utility module which converts the vehicles to the desired format. If we go this route maybe we could make a generic remapper function which inputs the key to map on so it can be re-used to create a map of hashes to vehicles, or for other tables as well.
At the very least, if going the module route, deprecate GetVehiclesByName and GetVehiclesByHash and create GetVehicles
Additional context
No response
The text was updated successfully, but these errors were encountered: