For the complete documentation index, see llms.txt. This page is also available as Markdown.

serverConfig.lua

WEBHOOK = "ENTER WEBHOOK"

function SendLog(playerId, action, message)
    local src = playerId
    local playerName = GetPlayerName(src)
    local playerCoords = GetEntityCoords(GetPlayerPed(src))

    local identifiers = {
        steam = "None",
        license = "None",
        discord = "None",
        ip = "None",
        xbl = "None",
        live = "None",
        fivem = "None"
    }

    for _, id in pairs(GetPlayerIdentifiers(src)) do
        if string.find(id, "steam:") then
            identifiers.steam = id
        elseif string.find(id, "license:") then
            identifiers.license = id
        elseif string.find(id, "discord:") then
            identifiers.discord = id:gsub("discord:", "")
        elseif string.find(id, "ip:") then
            identifiers.ip = id:gsub("ip:", "")
        elseif string.find(id, "xbl:") then
            identifiers.xbl = id
        elseif string.find(id, "live:") then
            identifiers.live = id
        elseif string.find(id, "fivem:") then
            identifiers.fivem = id
        end
    end

    local licenseInfo = table.concat({
        identifiers.license and (identifiers.license) or nil,
        identifiers.steam and (identifiers.steam) or nil,
        identifiers.discord and (identifiers.discord) or nil,
        identifiers.ip and (identifiers.ip) or nil,
        identifiers.fivem and (identifiers.fivem) or nil,
        identifiers.xbl and (identifiers.xbl) or nil,
        identifiers.live and (identifiers.live) or nil,
    }, "\n")

    local embed = {
        ["color"] = 373247,
        ["fields"] = {
            {
                ["name"] = action,
                ["value"] = "",
                ["inline"] = false
            },
            {
                ["name"] = "Player Name",
                ["value"] = playerName,
                ["inline"] = true
            },
            {
                ["name"] = "Player ID",
                ["value"] = src,
                ["inline"] = true
            },
            {
                ["name"] = "Action Details",
                ["value"] = message,
                ["inline"] = false
            },
            {
                ["name"] = "License Information",
                ["value"] = licenseInfo ~= "" and "```" .. licenseInfo .. "```" or "No information found",
                ["inline"] = false
            }
        }
    }

    sendWebhook(WEBHOOK, {embed})
end

function sendWebhook(webhook, data)
	PerformHttpRequest(webhook, function() end, 'POST', json.encode({ username = 'AK4Y LOGS', embeds = data}), { ['Content-Type'] = 'application/json' })
end

Last updated