Setup

Steps for setting up your zyke_status resource.

ESX Guide

1

Remove Old Status

Remove your old esx_status resource from the server and server.cfg.

We replicate everything this resource does within zyke_status and more!

2

Remove Basic Needs

Remove your old esx_basicneeds resource from the server files, and optionally server.cfg.

We replicate everything that happens in this resource within zyke_status, no need for it anymore.


QBCore Guide

Basic Compatibility

To get the basic compatibility going, you will need to modify the SetMetaData function. This allows us to catch any attempts to modify your status, which then dispatch it to our system to handle the rest. Our system will execute everything needed for the rest of your server to proceed as normal.

1

Modify Player Method

Navigate here and replace the entire function with the code provided below (L274-L281).

-- Modified to execute our export when triggered
-- Also blocks duplicate requests that will occur when we dispatch
function self.Functions.SetMetaData(meta, value)
    if (not meta or type(meta) ~= "string") then return end

    local invoker = GetInvokingResource()

    -- If the request was not made by our resource, dispatch it to us and block the rest
    -- Our system will re-trigger this event after updating all of our values and sync qb-core
    if (invoker ~= "zyke_status") then
        if (meta == "hunger" or meta == "thirst" or meta == "stress") then
            if (value > 100.0) then value = 100.0 end
            if (value < 0.0) then value = 0.0 end

            return exports["zyke_status"]:SetStatusValue(self.PlayerData.source, {meta, meta}, value)
        end
    end

    self.PlayerData.metadata[meta] = value
    self.Functions.UpdatePlayerData()
end
2

The instructions below removes all draining/additions/effects from the core.

  • [Hunger & Thirst Drain] Navigate here and replace the entire event with the code provided below (L151-167).

-- Modified to remove hunger & thirst drain
RegisterNetEvent('QBCore:UpdatePlayer', function()
    local ply = QBCore.Functions.GetPlayer(source)
    if (not ply) then return end

    ply.Functions.Save()
end)
  • [Stress Effects] Navigate here and remove the entire thread (L977-L1011)


Qbox Guide

Basic Compatibility

To get the basic compatibility going, you will need to modify the SetMetaData function. This allows us to catch any attempts to modify your status, which then dispatch it to our system to handle the rest. Our system will execute everything needed for the rest of your server to proceed as normal.

1

Modify SetMetadata

Replace the SetMetadata function inside of qbx_core/server/player.lua with the snippet below.

qbx_core/server/player.lua
function SetMetadata(identifier, metadata, value)
    if type(metadata) ~= 'string' then return end

    local player = type(identifier) == 'string' and (GetPlayerByCitizenId(identifier) or GetOfflinePlayer(identifier)) or GetPlayer(identifier)

    if not player then return end

    local oldValue

    if metadata:match('%.') then
        local metaTable, metaKey = metadata:match('([^%.]+)%.(.+)')

        if metaKey:match('%.') then
            lib.print.error('cannot get nested metadata more than 1 level deep')
        end

        oldValue = player.PlayerData.metadata[metaTable]

        player.PlayerData.metadata[metaTable][metaKey] = value

        metadata = metaTable
    else
        oldValue = player.PlayerData.metadata[metadata]
        if (metadata == "hunger" or metadata == "thirst" or metadata == "stress") then
            if (GetInvokingResource() ~= "zyke_status") then
                -- We don't support changing these values offline at the moment
                if (player.Offline) then return end

                if (value > 100.0) then value = 100.0 end
                if (value < 0.0) then value = 0.0 end

                local source = player.PlayerData.source

                return exports["zyke_status"]:SetStatusValue(source, {metadata, metadata}, value)
            end
        end

        player.PlayerData.metadata[metadata] = value
    end

    UpdatePlayerData(identifier)

    if not player.Offline then
        local playerState = Player(player.PlayerData.source).state

        TriggerClientEvent('qbx_core:client:onSetMetaData', player.PlayerData.source, metadata, oldValue, value)
        TriggerEvent('qbx_core:server:onSetMetaData', metadata,  oldValue, value, player.PlayerData.source)

        if (metadata == 'hunger' or metadata == 'thirst' or metadata == 'stress') then
            value = lib.math.clamp(value, 0, 100)

            if playerState[metadata] ~= value then
                playerState:set(metadata, value, true)
            end
        end

        if (metadata == 'dead' or metadata == 'inlaststand') then
            playerState:set('canUseWeapons', not value, true)
        end
    end

    if metadata == 'inlaststand' or metadata == 'isdead' then
        if player.Offline then
            SaveOffline(player.PlayerData)
        else
            Save(player.PlayerData.source)
        end
    end
end
2

The instructions below removes all draining/additions/effects from the core.

  • [Hunger & Thirst Drain] Navigate here and remove the entire thread (L15-L23).

  • [Stress Effects] Navigate here and remove the entire thread (L884-L918)

Last updated

Was this helpful?