#Job option for ox_target

1 messages · Page 1 of 1 (latest)

faint oyster
#

Hello, do you know how to add a job parameter to the AddBoxZone function of ox_inventory so that only the job (ambulance for example) can interact ? thanks

lunar orbit
faint oyster
#

yes but when I add groups everyone can still interact with the ped

lunar orbit
#

Share your code

faint oyster
#
CreateThread(function()
    for k,v in pairs(JobCore.Ped) do
        if v.hash ~= nil then
            setPedPos(v.hash, v.pos, v.heading, v.scenario)
        end
        exports.ox_target:addBoxZone({
            coords = v.pos,
            size = vector3(1, 1, 2),
            rotation = v.heading,
            debug = v.debug,
            groups = v.group,
            options = {
                {
                    icon = v.icon,
                    job = v.job,
                    label = v.label,
                    event = v.event,
                    parameters = v.parameters
                }
            }
        })
    end
end)

JobCore.Ped = {
    ['EMS - Pharmacie'] = {
        hash = 's_f_y_scrubs_01',
        pos = vector3(-665.78, 322.14, 83.08),
        heading = 269.29,
        enableTarget = true,
        debug = false,
        icon = 'fas fa-ambulance',
        label = 'Pharmacie',
        group = {'ambulance'},
        event = 'iAmbulance:OpenPharmacie'
    }
}
lunar orbit
#

Yeah so groups needs to go inside the options = {} table

#

Then it should work I believe

faint oyster
#

No it doesn't work, everyone still has access

lunar orbit
#

What did you change

faint oyster
#

I tried to pass the job directly into the function instead of in the config file

lunar orbit
#

No, just move the code inside the options table

faint oyster
#

okay i try

#

i moved into a options table

lunar orbit
#
CreateThread(function()
    for k,v in pairs(JobCore.Ped) do
        if v.hash ~= nil then
            setPedPos(v.hash, v.pos, v.heading, v.scenario)
        end
        exports.ox_target:addBoxZone({
            coords = v.pos,
            size = vector3(1, 1, 2),
            rotation = v.heading,
            debug = v.debug,
          --groups = v.group, <<< ------- DELETE THIS ....
            options = {
                {
                    icon = v.icon,
                    job = v.job,
                    label = v.label,
                    event = v.event,
                    parameters = v.parameters,
                    groups = v.group, -- <<< ------- MOVE TO HERE ....
                }
            }
        })
    end
end)

JobCore.Ped = {
    ['EMS - Pharmacie'] = {
        hash = 's_f_y_scrubs_01',
        pos = vector3(-665.78, 322.14, 83.08),
        heading = 269.29,
        enableTarget = true,
        debug = false,
        icon = 'fas fa-ambulance',
        label = 'Pharmacie',
        group = {'ambulance'},
        event = 'iAmbulance:OpenPharmacie'
    }
}
faint oyster
#

yeah it work !

#

sorry 😅

#

thanks for help