Editable Files

client/editable.lua

function cameraScreenShot()
    if config.tgiannServer then
        return exports['tgiann-main']:screenShot()
    else
        local screenShotData = nil
        tgiCore.cbFunction("tgiann-postcard:server:getScreenshotWebHook", function(hook)
            if hook and hook ~= "" then
                exports['screenshot-basic']:requestScreenshotUpload(tostring(hook), "files[]", function(data)
                    local image = json.decode(data)
                    if image then
                        screenShotData = image.attachments[1].proxy_url
                    else
                        screenShotData = false
                    end
                end)
            else
                screenShotData = false
            end
        end)
        while screenShotData == nil do Wait(10) end
        return screenShotData
    end
end

function camModeIsOpen()
    -- Your code here
end

client/target.lua

if not config.target then return end

if config.target == "ox" then
    local options = {
        {
            name = 'tgiann-postcard:openmenu',
            event = 'tgiann-postcard:openMenu',
            icon = 'fa-solid fa-envelope',
            label = config.langs[config.lang].lowpostcard,
        },
    }
    
    exports.ox_target:addModel(config.postBox, options)

elseif config.target == "qb" then
    local options = {
        {
            num = 1, -- This is the position number of your option in the list of options in the qb-target context menu (OPTIONAL)
            type = "client", -- This specifies the type of event the target has to trigger on click, this can be "client", "server", "command" or "qbcommand", this is OPTIONAL and will only work if the event is also specified
            event = "tgiann-postcard:openmenu", -- This is the event it will trigger on click, this can be a client event, server event, command or qbcore registered command, NOTICE: Normal command can't have arguments passed through, QBCore registered ones can have arguments passed through
            icon = 'fa-solid fa-envelope', -- This is the icon that will display next to this trigger option
            label = config.langs[config.lang].lowpostcard, -- This is the label of this option which you would be able to click on to trigger everything, this has to be a string
            targeticon = 'fa-solid fa-envelope', -- This is the icon of the target itself, the icon changes to this when it turns blue on this specific option, this is OPTIONAL
            item = 'handcuffs', -- This is the item it has to check for, this option will only show up if the player has this item, this is OPTIONAL
        },
        distance = 2.5,
    }
    exports["qb-target"]:AddTargetModel(config.postBox, options)
end

server/editable.lua

local screenshotWebHook = ""

tgiCore.cbFunction("tgiann-postcard:server:getScreenshotWebHook", function(source, cb)
    cb(screenshotWebHook)
end)

if config.framework == "qb" then
    tgiCore.useableItem(config.itemName, function(source, item)
        local playerName = tgiCore.getCharacterName(xPlayer)
        TriggerClientEvent("tgiann-postcard:useItem", source, item.info.postcard, item.slot, playerName)
    end)
elseif config.framework == "esx" then
    exports(config.itemName, function(event, item, inventory, slot, data)
        if event == 'usingItem' then
            local xPlayer = tgiCore.getPlayer(inventory.player.source)
            local playerName = tgiCore.getCharacterName(xPlayer)
            TriggerClientEvent("tgiann-postcard:useItem", inventory.player.source, tgiCore.getItemBySlot(xPlayer, slot).metadata.postcard, slot, playerName)
        end
    end)
end

RegisterServerEvent("tgiann-postcard:save")
AddEventHandler("tgiann-postcard:save", function(data, slot)
    local xPlayer = tgiCore.getPlayer(source)
    single("SELECT "..config.userTableIdType.." FROM "..config.userTableName.." WHERE CONCAT(firstname, ' ', lastname) LIKE @search", {
        ['@search'] = '%'..data.input..'%'
    }, function (result)
        data.playerCitizenId = result[config.userTableIdType]
        if tgiCore.removeItem(xPlayer, config.itemName, 1, slot) then
            tgiCore.addItem(xPlayer, config.itemName, 1, slot, {postcard = data})
            tgiCore.notif(xPlayer, config.langs[config.lang].saved, "success")
        end
    end) 
end)

Last updated