Zyke Resources' Products
DiscordStore
  • Introduction
  • Common Issues
    • zyke_lib error
    • Lacking Entitlement
    • UI Not Working
    • Missing Files Via FTP
    • Resource Starting Sequence
    • Item Not Usable
    • Any other issues?
  • FAQ
  • Paid Resources
    • Consumables
      • Resource Description
      • Config
      • Exports & Events
      • Dependencies
      • Changelog
      • Guides
      • Setup
    • Smoking
      • Resource Description
      • Config
      • Exports & Events
      • Examples
      • Dependencies
      • Changelog
      • Test Server
      • Setup
    • Garages
      • Resource Description
      • Config
      • Exports & Events
      • Dependencies
      • Changelog
      • Setup
      • Common Issues
    • Drugdealer
      • Resource Description
      • Config
      • Exports & Events
      • Dependencies
      • Changelog
    • Crafting
      • Resource Description
      • Config
      • Exports & Events
      • Dependencies
      • Changelog
    • Plants
      • Resource Description
      • Config
      • Exports & Events
      • Dependencies
      • Changelog
    • Mugging
      • Resource Description
      • Config
      • Exports & Events
      • Changelog
    • Gangsystem
      • Resource Description
      • Config
      • Exports & Events
      • Examples
      • Dependencies
      • Changelog
  • Free Resources
    • Zyke Lib
      • Resource Description
      • Dependencies
      • Config
      • Setup
    • Status
      • Resource Description
      • Dependencies
      • Changelog
      • Setup
    • Propaligner
      • Resource Description
      • Exports & Events
      • Dependencies
      • Changelog
    • Vending Machines
      • Resource Description
      • Dependencies
      • Changelog
    • Sounds
      • Resource Description
      • Exports & Events
    • Key Minigame
      • Resource Description
      • Exports & Events
      • Changelog
    • Stabwheels
      • Resource Description
      • Dependencies
      • Changelog
    • Burncars
      • Resource Description
      • Dependencies
      • Changelog
    • Catalytic
      • Resource Description
      • Exports & Events
      • Config
      • Dependencies
      • Changelog
Powered by GitBook
On this page
  • ESX Guide
  • QBCore Guide
  • Basic Compatibility
  • Qbox Guide
  • Basic Compatibility

Was this helpful?

  1. Free Resources
  2. Status

Setup

Steps for setting up your zyke_status resource.

PreviousChangelogNextPropaligner

Last updated 1 day ago

Was this helpful?

ESX Guide

1

Remove Old Status

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


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 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

Full Control (Optional, Recommended)

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

  • [Hunger & Thirst Drain] Navigate 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 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

Full Control (Optional, Recommended)

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

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

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

here
here
here
here
here