client/editable.lua

---@return boolean
function isPlayerAdmin()
    return PlayerData and (PlayerData.perm and PlayerData.perm ~= "user")
end

---@param job string
---@return boolean
function isPolice(job)
    for i = 1, #config.weaponPoliceJobs do
        if config.weaponPoliceJobs[i] == job then
            return true
        end
    end
    return false
end

---@param bool boolean
function hotbarIsOpenEditable(bool)
    TriggerEvent("tgiann-inventory:hotbar", bool)
end

---@return boolean
function canOpen()
    if not PlayerData then PlayerData = exports["tgiann-core"]:getPlayerData() end
    return not IsNuiFocused() and not IsDisabledControlPressed(0, 19) and inventoryActive and not isDead and not IsPauseMenuActive() and playerLoaded and not PlayerData.metadata.kelepce and not PlayerData.metadata.pkelepce
end

---@param text string
---@param type "me" | "do"
function emote(text, type)
    if not config.autoEmote then return end
    ExecuteCommand((type or "me") .. " " .. text)
end

RegisterNetEvent('tgiann-inventory:emote')
AddEventHandler('tgiann-inventory:emote', emote)

function opened()
    TriggerEvent("tgiann-hud:ui", false)
    TriggerEvent("tgiann-lumihud:ui", false)
end

function closed()
    TriggerEvent("tgiann-hud:ui", true)
    TriggerEvent("tgiann-lumihud:ui", true)
end

---@return boolean
function disableClotheButton()
    --[[  local onDuty = false
    if PlayerData.job.name == "police" then
        onDuty = PlayerData.job.onduty
    end
    return onDuty or (exports["tgiann-event"]:joinedAnyEvent() and true or false ) or exports["tgiann-clothing"]:isInspect() ]]
    return false
end

---@return boolean
function getTrunkData(vehicle)
    local modelData = config.vehicleModelSlotsMaxWeights[GetEntityModel(vehicle)]
    if modelData then
        return {
            maxweight = modelData.maxWeight,
            slots = modelData.slots,
        }
    end

    local classData = config.vehicleClassSlotsMaxWeights[GetVehicleClass(vehicle)]
    if classData then
        return {
            maxweight = classData.maxWeight,
            slots = classData.slots,
        }
    end

    return {
        maxweight = 10000,
        slots = 5,
    }
end

---@return boolean
function removeWeaponCustom()
    --[[ if exports["tgiann-pvpinventory"]:isActive() then
        SetCurrentWeapon()
        return true
    end ]]
    return false
end

---@return boolean
function dropWeaponWhenDieEditable()
    --[[ local zoneIsRed = exports["tgiann-safezone"]:getZoneType() == "red"
    if zoneIsRed and exports["tgiann-police"]:playerIsPolice() then
        return
    end

    if zoneIsRed and PlayerData.metadata.vip.level == 2 and math.random(1, 100) >= 50 then -- 2 Level VIP Özelliği %50 silah düşme oranı
        TriggerEvent("inventory:client:removeWeapon")
        return
    end ]]

    return true
end

---@param status table
function setPlayerStatus(status)
    if config.framework == "esx" then
        if status.hunger then
            TriggerEvent("esx_status:getStatus", "hunger", function(value)
                value.set(value.val + status.hunger)
            end)
        end
        if status.thirst then
            TriggerEvent("esx_status:getStatus", "thirst", function(value)
                value.set(value.val + status.thirst)
            end)
        end
    elseif config.framework == "qb" then
        if status.hunger then
            TriggerServerEvent("consumables:server:addHunger", tgiCore.core.Functions.GetPlayerData().metadata.hunger + status.hunger)
        end
        if status.thirst then
            TriggerServerEvent("consumables:server:addThirst", tgiCore.core.Functions.GetPlayerData().metadata.thirst + status.thirst)
        end
    end
end

---@param itemConfig table
---@param itemName string
function editableAddCarryItem(itemConfig, itemName)
    -- LocalPlayer.state:set('hrCarry', itemName, false)
end

---@param carryItem table
function editableRemoveCarryItem(carryItem)
    -- LocalPlayer.state:set('hrCarry', nil, false)
end

---@return boolean
function canUseRealisticArmor()
    return true
end

CreateThread(function()
    if not config.disableWeaponWhip then return end
    while true do
        local time = 500
        local ped = PlayerPedId()
        if IsPedArmed(ped, 6) then
            time = 0
            DisableControlAction(1, 140, true)
            DisableControlAction(1, 141, true)
            DisableControlAction(1, 142, true)
        end
        Wait(time)
    end
end)

Last updated