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

refactor: Ox Inventory Support + More End-User Notifications + Multiple Police Jobs For Raids #125

Merged
merged 4 commits into from
Aug 22, 2023

Conversation

WLVF
Copy link
Contributor

@WLVF WLVF commented Aug 17, 2023

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.

  • [YES] Did you test the changes you made?
  • [YES] Did you test core functionality of the script to ensure your changes do not regress other areas?
  • [YES] Did you test your changes in multiplayer to ensure it works correctly on all clients?

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.
@MonkeyWhisper
Copy link
Member

Thank you! This is much better than the previous PR

@MonkeyWhisper
Copy link
Member

Tested by myself and Bostra

@MonkeyWhisper MonkeyWhisper merged commit cb4ef70 into Project-Sloth:main Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants