WaypointRP / wp-placeables

Waypoint Placeables - Framework for placing/picking up props in the world
GNU General Public License v3.0
59 stars 21 forks source link

job lock items so people cat have it in the inventory #5

Closed djraymond1 closed 11 months ago

djraymond1 commented 1 year ago

how can i job lock items so people cat have it in the inventory

BackSH00TER commented 11 months ago

Support for this was provided in QB Core Discord thread. https://discord.com/channels/831626422232678481/1120256052106113175/1171234006096937042

Closing issue as I do not intend to build this functionality into this script.


Pasting below for reference:

There are many ways to solve this, I’ll give you an example of one way.

Let’s assume you want to just lock one item called policeItem and lock it to only the police job.

You could add another field onto this item in the Config.PlaceableProps. Maybe call it allowedJobs. It can accept a list of jobs that can use the item. allowedJobs = { “police”, “bcso” }

In the server file where we loop over the Config.PlaceableProps to create useable items and return the callback function. Add a condition checking if allowedJobs is defined on the item. If it is not defined then just carry on with existing logic. If it is defined, get the players job and check if it is one of the allowedJobs. If yes carry on with the existing logic. If no then you could notify the user they aren’t allowed to use this item