hof-errors/server/sv_errorLog.lua
2025-02-24 17:04:19 -06:00

37 lines
1.8 KiB
Lua

---@diagnostic disable: param-type-mismatch
while not CONFIG_INIT do Wait(100) end print('hof-error/sv/errorLog/CONFIG_INIT')
RegisterServerEvent("Error:Server:Report", function(resource, ...)
local src = source
local errorMessage = ...
errorMessage = errorMessage:gsub("%^%d+", "")
local userName = GetPlayerName(src)
local steamID = GetPlayerIdentifierByType(source, 'steam'):gsub('steam:',"") or 'ERROR: STEAM-NOT-FOUND'
local discordID = GetPlayerIdentifierByType(source, 'discord'):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 = 'https://discord.com/api/webhooks/',
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/'..steamID(source) ..'\n'..
'**Discord:** <@'.. discordID ..'> \n'..
'**Source(ID):** '.. src ..'\n'..
'**CitizenID:** '.. citizenid ..'\n'..
'**Coords:** '.. FormatCoords(x,y,z,heading) ..'\n'..
'**Status:** '.. DeadOrLastStand(source) ..'\n'..
'**Identifiers:** '.. FetchIdentifiers(source)'\n'..
'---------------------------------------\n'..
errorMessage..
'---------------------------------------\n'
})
end)