gear-codeFramework

Framework Support

The script supports the following frameworks with an auto detection mode:

  • ESX

  • QBCore

  • Standalone (customizable) (Custom logic must be implemented)

Config.Framework = 'auto'   --- | 'esx' | 'qb-core' | 'standalone' |

Item Usage Handling

For each item defined in Ks_Ctu, the script registers it as a usable item:

  • QBCore: Uses QBCore.Functions.CreateUseableItem

  • ESX: Uses ESX.RegisterUsableItem

  • Standalone: Uses a RegisterCommand even

if Config.Framework == 'qb-core' then
    QBCore.Functions.CreateUseableItem(itemName, function(source, item)
        local Player = QBCore.Functions.GetPlayer(source)
        if not Player then return end
        TriggerEvent('Ks_Ctu:Internal:server:UseItem', source, itemName, itemData, categoryName)
    end)

elseif Config.Framework == 'esx' then
    ESX.RegisterUsableItem(itemName, function(source)
        local xPlayer = ESX.GetPlayerFromId(source)
        if not xPlayer then return end
        TriggerEvent('Ks_Ctu:Internal:server:UseItem', source, itemName, itemData, categoryName)
    end)

elseif Config.Framework == 'standalone' then
    RegisterCommand(itemName, function(source, args, rawCommand)
        TriggerEvent('Ks_Ctu:Internal:server:UseItem', source, itemName, itemData, categoryName)
    end)
end

For Standalone (It is recommended to implement your own logic) By default, items are registered as commands, but it is recommended that you implement your own logic to properly integrate item usage into your server.

Additionally we leave other functions on the server side

Handling Surprise Item Rewards

The system gives random items to players for surprise boxes.

Removing Items from Inventory

The system allows removing items from a player's inventory.

Last updated