hof-errors/server/sv_errorLog.lua
2025-03-19 09:39:02 -05:00

41 lines
2.0 KiB
Lua

---@diagnostic disable: param-type-mismatch
local ServerConfig = require "config.server"
local ServerFunctions = require "server.sv_functions"
local QBX = exports.qbx_core
local LOGGER = require '@qbx_core.modules.logger'
RegisterServerEvent("Error:Server:Report", function(resource, ...)
local src = source
local errorMessage = ...
errorMessage = errorMessage:gsub("%^%d+", "")
local userName = GetPlayerName(src)
local steamIdent = GetPlayerIdentifierByType(src, 'steam')
local steamID = (steamIdent and steamIdent:gsub('steam:',"")) or 'ERROR: STEAM-NOT-FOUND'
local discordIdent = GetPlayerIdentifierByType(src, 'discord')
local discordID = (discordIdent and discordIdent:gsub('discord:',"")) or 'ERROR: DISCORD-NOT-FOUND'
local citizenid = QBX:GetPlayer(src).PlayerData.citizenid
local ped = GetPlayerPed(src)
local x, y, z = table.unpack(GetEntityCoords(ped))
local heading = GetEntityHeading(ped)
LOGGER.log({
source = citizenid,
webhook = ServerConfig.Webhook,
event = 'Error:Server:Report',
color = 'red',
message = string.format("**__Script Error In %s__**", resource) ..'\n'..
'---------------------------------------\n'..
'**__Triggered By:__** \n'..
'**Username:** '.. userName ..'\n'..
'**Steam Account:** '.. 'https://steamcommunity.com/profiles/'.. tonumber(steamID, 16) ..'\n'..
'**Discord:** <@'.. discordID ..'> \n'..
'**Source(ID):** '.. src ..'\n'..
'**CitizenID:** '.. citizenid ..'\n'..
'**Coords:** '.. ServerFunctions.FormatCoords(x,y,z,heading) ..'\n'..
'**Status:** '.. ServerFunctions.DeadOrLastStand(src) ..'\n'..
'**Identifiers:** '.. ServerFunctions.FetchIdentifiers(src) .. '\n'..
'---------------------------------------\n'..
errorMessage..
'---------------------------------------\n'
})
end)