meta-hub / meta_target

A complete third eye solution for FiveM and RedM, aiming to proving all solutions from fivem-target, bt-target and qtarget under one resource.
21 stars 15 forks source link

Add support for job restrictions #2

Closed Senlar closed 2 years ago

Senlar commented 2 years ago

Add option for job and rank restriction on the main interaction and options. Allow jobs to be sent as key value pairs with the value being the minimum rank to interact. {ambulance = 0, police = 3}

Example: Below is a use case where there is one interaction created that has an overall restriction to only allow police or ambulance to see the interaction. Then, each interaction has further limitations.

Hands up can only be done by police, then rank matches the access rank so there are no further rank restrictions. Open Inventory can only be done by police, but it HAS a restriction on the higher rank so only rank 3 and up can do it. Ragdoll can only be done by ambulance job. High Five can be done by any police or ambulance since it is restricted to just those two jobs at the top level.

If we didn't include the top level restriction, then the job restrictions would still apply on each option, but High Five could be done by anyone.

  target.addNetEnt('my_netEnt_target', 'Network Entity', 'fas fa-user', networkId, 10.0, onInteract,{police = 0, ambulance = 0}, {
    {
      name = 'hands_up',
      label = 'Hands Up',
      onInteract = 'myscript:handsUp',
      jobs = {police = 0}
    },
    {
      name = 'open_inventory',
      label = 'Open Inventory',
      onInteract = 'myscript:openInventory',
      jobs = {police = 3}
    },
    {
      name = 'ragdoll',
      label = 'Ragdoll',
      jobs = {ambulance = 0}
    },
    {
      name = 'highfive',
      label = 'High Five'
    }
  },{
    foo = 'bar'
  })
Taavi-AU commented 2 years ago

You can do this yourself, but do it outside of the script

setupTargets = function()
   if ESX.GetPlayerData().job.name == job then
       exports["fivem-target"]
   end
end
Senlar commented 2 years ago

Only the top level access, which I'm doing now. But MF asked for people to make reports for features so that's what I'm doing.

Taavi-AU commented 2 years ago

nah yeha thats fair enough

meta-hub commented 2 years ago

The only way any "character data" restrictions will be applied are through state bags, if ever. That won't work by default for ESX jobs so this is likely something you will need to handle yourself when adding/removing targets.

Reason is of course, no framework requirements.