#Fingerprint metadata on thrown items without gloves (pScripts ox redesign) [QBOX]

1 messages · Page 1 of 1 (latest)

honest ledge
#

If you don't have any gloves when using the throw item function it will add fingerprint metadata, but if you do have gloves it will not add metadata.

Step 1 - make a gloves.lua in ox_inventory/data
paste this

Config = Config or {}

Config.MaleNoGloves = {
  [0]=true,[1]=true,[2]=true,[3]=true,[4]=true,[5]=true,[6]=true,[7]=true,[8]=true,[9]=true,[10]=true,
  [11]=true,[12]=true,[13]=true,[14]=true,[15]=true,[16]=true,[18]=true,[26]=true,[52]=true,[53]=true,
  [54]=true,[55]=true,[56]=true,[57]=true,[58]=true,[59]=true,[60]=true,[61]=true,[62]=true,[112]=true,
  [113]=true,[114]=true,[118]=true,[125]=true,[132]=true
}

Config.FemaleNoGloves = {
  [0]=true,[1]=true,[2]=true,[3]=true,[4]=true,[5]=true,[6]=true,[7]=true,[8]=true,[9]=true,[10]=true,
  [11]=true,[12]=true,[13]=true,[14]=true,[15]=true,[19]=true,[59]=true,[60]=true,[61]=true,[62]=true,
  [63]=true,[64]=true,[65]=true,[66]=true,[67]=true,[68]=true,[69]=true,[70]=true,[71]=true,[129]=true,
  [130]=true,[131]=true,[135]=true,[142]=true,[149]=true,[153]=true,[157]=true,[161]=true,[165]=true
}
#

Step 2
in client.lua find function "local function throwSlot(slot)", replace that with down below

CreateThread(function()
    exports.ox_inventory:displayMetadata('fingerprint', 'FINGERAVTRYCK')
end)

local function IsWearingGloves()
    local ped = cache.ped
    if not ped or not DoesEntityExist(ped) then return true end
    local m = GetEntityModel(ped)
    local arms = GetPedDrawableVariation(ped, 3)
    if m == `mp_m_freemode_01` then
        return not (Config.MaleNoGloves and Config.MaleNoGloves[arms])
    elseif m == `mp_f_freemode_01` then
        return not (Config.FemaleNoGloves and Config.FemaleNoGloves[arms])
    end
    return true
end

local isThrowing = false
local function throwSlot(slot)
    if isThrowing then return end
    local itemData = PlayerData.inventory[slot]
    if not itemData then return end

    client.closeInventory()
    isThrowing = true
    Wait(100)
    lib.showTextUI(locale('throw_item_textui'))

    local plyCoords = GetEntityCoords(cache.ped)
    local throwModel = lib.requestModel(Items[itemData.name]?.prop or 'prop_med_bag_01b')
    local throwObj = CreateObject(throwModel, plyCoords.x, plyCoords.y, plyCoords.z, true, true, true)
    AttachEntityToEntity(throwObj, cache.ped, GetPedBoneIndex(cache.ped, 57005), 0.11, 0.03, -0.04, 0, 0, 0, true, true, false, true, 1, true)

    CreateThread(function()
        while isThrowing do
            Wait(0)
            local power = itemData.weight and math.max(1.0, 5.0 - (itemData.weight / 10)) or 2.0
            DisableControlAction(0, 24, true)
            DisableControlAction(0, 25, true)

            if IsDisabledControlPressed(0, 24) then
                local anim = lib.requestAnimDict('weapons@projectile@')
                TaskPlayAnim(cache.ped, anim, 'throw_h_fb_stand', 8.0, -8.0, 1500, 49, 0, false, false, false)
                isThrowing = false
                lib.hideTextUI()
                Wait(200)

                local fwd = GetEntityForwardVector(cache.ped)
                DetachEntity(throwObj, true, true)
                Wait(1)
                SetEntityVelocity(throwObj, fwd.x * power, fwd.y * power, fwd.z * power + 5.0)
                SetEntityDynamic(throwObj, true)
                SetEntityCollision(throwObj, true, true)
                SetEntityHasGravity(throwObj, true)
                ApplyForceToEntity(throwObj, 1, fwd.x * power * 20, fwd.y * power * 20, 3.0, 0, 0, 0, 0, false, true, true, false, true)
                SetModelAsNoLongerNeeded(throwModel)

                if not IsWearingGloves() then
                    local ok = false
                    local okPcall, res = pcall(function()
                        return lib.callback.await('dg_inventory:ensureFingerprint', false, slot)
                    end)
                    ok = okPcall and res == true
                end

                Wait(1000)
                while GetEntitySpeed(throwObj) > 0.125 do Wait(10) end
                local c = GetEntityCoords(throwObj)
                local hit, gz = GetGroundZFor_3dCoord(c.x, c.y, c.z + 1.5, true)
                TriggerServerEvent('ox_inventory:throwItem', slot, vec3(c.x, c.y, hit and gz or c.z))
                DeleteEntity(throwObj)

            elseif IsDisabledControlPressed(0, 25) then
                isThrowing = false
                lib.hideTextUI()
                DeleteEntity(throwObj)
            end
        end
    end)
end
#

Step 3

In server.lua, go all the way down and add this

lib.callback.register('dg_inventory:ensureFingerprint', function(src, slot)
    if type(slot) ~= 'number' then return false end

    local Player = exports.qbx_core:GetPlayer(src)
    if not Player then return false end

    local fp = Player.PlayerData.metadata and Player.PlayerData.metadata.fingerprint
    if not fp then return false end

    local item = exports.ox_inventory:GetSlot(src, slot)
    if not item or (item.count or 0) <= 0 then return false end

    local meta = item.metadata or {}
    if not meta.fingerprint or meta.fingerprint == '' then
        meta.fingerprint = fp
        exports.ox_inventory:SetMetadata(src, slot, meta)
    end

    return true
end)