refactor: Ox Inventory Support + More End-User Notifications + Multiple Police Jobs For Raids #125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR is in result of PR #106 that attempts to do the same thing and a little more. I wish for easier to read code whilst utilizing proven performant and safe methods. This will also improve the front-end user experience by notifying them of exactly what they're doing wrong. This will also allow server owners and developers to change the item required to raid properties.
Details
This change will increase code speed along with removing the potential for data corruption.
If the end-user is using ox_inventory, they will take advantage of ox_inventory's search export instead of the slower QBCore GetItemByName player method.
Both inventories have been tested using this code and ox_inventory will even support the code even if the end-user puts the inventory on "qb" by accident. All other code has been tested by me as well.
Players will now be notified of every single thing that they're doing wrong when attempting to raid a property so they're no longer in the dark as to what the issue is.
Server owners and developers will now be able to adjust the item required in order to raid properties by going into shared/config.lua
UI Changes / Functionality
This will eliminate the frustration of not being able to raid a house due to the multiple police job config not being connected to the job check found within the code before my change.
The code will now notify players of every reason possible as to why they're unable to raid the house other than not having the police_stormram item.
The item required to raid a property is now also adjustable by server owners and developers.
Testing Steps
Choose an inventory of choice within shared/config.lua
Go up to the property that you wish to raid as someone who has a job that isn't within the Config.PoliceJobs list. This will trigger an error notification that you must be a police officer (You can't even access the 3rd eye target so skip this step unless you want to modify the code to allow you to have the 3rd eye target anyways).
Ensure that you are not on duty.
Attempt to raid the property whilst not onduty and it will tell you that you must be on duty to raid the apartment.
Go on duty.
Attempt to raid the apartment whilst your job's grade is lower than the value of Config.MinGradeToRaid and it will notify you that you must be of a higher rank.
Set your job's grade to that of an equivalent or higher grade than the value of Config.MinGradeToRaid.
Ensure that you DO NOT have a storm ram. Once you third-eye the house's front door it will prompt you to raid it. Due to the fact that you don't have a storm ram, it will ask you to obtain one.
Obtain a
police_stormram
item and then repeat the previous steps to ensure that you can successfully start a raid on the property.Once you enter the house and your stormram has been removed from your inventory, your test has concluded for that inventory configuration.
Repeat all steps to test for the other Config.Inventory value.