🔧Functions

Server and client functions file - functions.lua

Client functions:

Functions = {}

-- Client
Functions.showNotification = function (type, msg)
    ESX.ShowNotification(msg, type)
end

Server functions:

-- Server
Functions.notifyAboutDelivery = function (source, coords) -- you can pass delivery location too!
    -- Add your phone export here
    local xPlayer = ESX.GetPlayerFromId(source)
    local seconds = Config.DeliveryTimeNotifyTime / 1000
    local s = math.fmod(seconds, 60)
    local min = (seconds - s) / 60

    xPlayer.showNotification("Ship with your delivery will come in " .. math.floor(min) .. " m. " .. math.floor(s) .. " s. Location: " .. json.encode(coords), 5000)
end

Functions.giveInventoryItem = function (source, name, quantity)
    local xPlayer = ESX.GetPlayerFromId(source)
    if not exports.ox_inventory:CanCarryItem(source, name, quantity) then
        -- player can't carry so it will create a drop
        local coords = xPlayer.getCoords(true)
        exports.ox_inventory:CustomDrop("blackmarket", {
            { name = name, count = quantity }
        }, coords)

        return
    end

    local success, response = exports.ox_inventory:AddItem(source, name, quantity)
    if not success then
        xPlayer.showNotification(response)
    end
end

Last updated