Skip to content
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

Closed
Manason opened this issue Sep 28, 2023 · 4 comments
Closed

Add export GetVehiclesByCategory() #183

Manason opened this issue Sep 28, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@Manason
Copy link
Member

Manason commented Sep 28, 2023

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

@Manason Manason added the enhancement New feature or request label Sep 28, 2023
@TonybynMp4
Copy link
Contributor

TonybynMp4 commented Oct 18, 2023

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)

@Manason
Copy link
Member Author

Manason commented Oct 18, 2023

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]

@TonybynMp4
Copy link
Contributor

I'm talking about that 🤔

At the very least, if going the module route, deprecate GetVehiclesByName and GetVehiclesByHash and create GetVehicles

@Manason
Copy link
Member Author

Manason commented Oct 18, 2023

I'm talking about that 🤔

At the very least, if going the module route, deprecate GetVehiclesByName and GetVehiclesByHash and create GetVehicles

Given that we already store this mapping in core, I think the export route is preferred over the module solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants