AWS DEVELOPMENT / DOCUMENTATION

Your server. Our expertise.

Everything you need to install, configure and build.

94 guides • 11 resources • Always here to help
About resource versions

These guides include the original resource names. Use the folder and SQL names supplied with your downloaded version. A renamed AWS package may differ from the original EXIT release.

qb.lua

if Config.Framework ~= 'qb' and Config.Framework ~= 'qbox' and (Config.Framework ~= 'auto' or GetResourceState('qb-core') ~= 'started') then return end


local QBCore = exports['qb-core']:GetCoreObject()
Bridge = {}

function Bridge.CreateCallback(name, cb)
    QBCore.Functions.CreateCallback(name, cb)
end

function Bridge.GetPoliceCount()
    local count = 0
    for _, v in pairs(QBCore.Functions.GetPlayers()) do
        local Player = QBCore.Functions.GetPlayer(v)
        if Player and Player.PlayerData.job.name == 'police' and Player.PlayerData.job.onduty then
            count = count + 1
        end
    end
    return count
end

function Bridge.HasItem(source, item)
    if GetResourceState('ox_inventory') == 'started' then
        local count = exports.ox_inventory:Search(source, 'count', item)
        return count and count > 0
    end
    
    local Player = QBCore.Functions.GetPlayer(source)
    if not Player then return false end
    local itm = Player.Functions.GetItemByName(item)
    return itm and (itm.amount or itm.count or 0) > 0
end

function Bridge.RemoveItem(source, item, amount)
    if GetResourceState('ox_inventory') == 'started' then
        return exports.ox_inventory:RemoveItem(source, item, amount)
    end
    
    local Player = QBCore.Functions.GetPlayer(source)
    if not Player then return false end
    if Player.Functions.RemoveItem(item, amount) then
        TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[item], "remove")
        return true
    end
    return false
end

function Bridge.AddMoney(source, type, amount, reason)
    local Player = QBCore.Functions.GetPlayer(source)
    if not Player then return false end
    Player.Functions.AddMoney(type, amount, reason)
    return true
end

function Bridge.AddItem(source, item, amount)
    local Player = QBCore.Functions.GetPlayer(source)
    if not Player then return false end
    Player.Functions.AddItem(item, amount)
    TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[item], "add")
    return true
end

function Bridge.CreateUseableItem(item, cb)
    QBCore.Functions.CreateUseableItem(item, cb)
end

function Bridge.AlertPolice(coords)
    local msg = Config.Locales[Config.Lang]['dispatch_msg'] or 'Uyuşturucu Satışı İhbarı'
    
    -- We can trigger client-side dispatch for all police
    local players = QBCore.Functions.GetPlayers()
    for _, v in pairs(players) do
        local Player = QBCore.Functions.GetPlayer(v)
        if Player and Player.PlayerData.job.name == 'police' and Player.PlayerData.job.onduty then
            TriggerClientEvent('corner-selling:client:CallDispatch', v, coords)
        end
    end
end