Move to public repo

This commit is contained in:
GetParanoid 2025-02-24 17:04:19 -06:00
commit 1d03bf3cd3
9 changed files with 150 additions and 0 deletions

32
client/cl_main.lua Normal file
View File

@ -0,0 +1,32 @@
local _trace = Citizen.Trace
local errorWords = {"failure", "error", "not", "failed", "not safe", "invalid", "cannot", ".lua", "server", "client", "attempt", "traceback", "stack", "function"}
function error(...)
local resource = GetCurrentResourceName()
print(string.format("----- RESOURCE ERROR -----"))
print(...)
print(string.format("------ PLEASE REPORT THIS TO STAFF ------"))
print(string.format("------ IDEALLY WITH CLIPS & SCREENSHOTS OF WHAT YOU'RE DOING ------"))
TriggerServerEvent("Error:Server:Report", resource, ...)
end
---@diagnostic disable-next-line: duplicate-set-field
function Citizen.Trace(...)
if type(...) == "string" then
local args = string.lower(...)
for _, word in ipairs(errorWords) do
if string.find(args, word) then
error(...)
return
end
end
end
_trace(...)
end
RegisterCommand('error:trigger', function()
local math = 1 + nil
print(math)
end)

0
config/client.lua Normal file
View File

0
config/server.lua Normal file
View File

0
config/shared.lua Normal file
View File

30
fxmanifest.lua Normal file
View File

@ -0,0 +1,30 @@
---@diagnostic disable: undefined-global
fx_version 'cerulean'
games {'gta5'}
lua54 'yes'
author 'GetParanoid'
description ''
version '1.0.0'
shared_scripts {
'@ox_lib/init.lua',
'@qbx_core/modules/lib.lua',
}
client_script {
'@qbx_core/modules/playerdata.lua',
"client/*.lua",
}
server_script {
"@oxmysql/lib/MySQL.lua",
"server/*.lua",
}
files {
'config/client.lua',
'config/shared.lua',
}
lua54 'yes'
use_experimental_fxv2_oal 'yes'

8
readme.md Normal file
View File

@ -0,0 +1,8 @@
# Error Logging
Automatic client side error logs for QBX
Just add `client_script "@hof-errors/client/cl_main.lua"` to any script's fxmanifest you want to integrate with
Add webhook to server/sv_errorLog.lua

37
server/sv_errorLog.lua Normal file
View File

@ -0,0 +1,37 @@
---@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)

29
server/sv_functions.lua Normal file
View File

@ -0,0 +1,29 @@
FormatCoords = function(x,y,z,heading)
local formattedX = math.floor(x * 100) / 100
local formattedY = math.floor(y * 100) / 100
local formattedZ = math.floor(z * 100) / 100
local formattedHeading = math.floor(heading * 100) / 100
local formattedString = formattedX .. ', '.. formattedY .. ', '.. formattedZ .. ', H: '..formattedHeading
return formattedString
end
FetchIdentifiers = function (source)
local identifiersString = ''
for _, identifier in ipairs(GetPlayerIdentifiers(source)) do
identifiersString = identifiersString .. '\n'..identifier
end
identifiersString = identifiersString .. '\n'
return identifiersString
end
DeadOrLastStand = function (source)
local _source = source
local Player = QBX:GetPlayer(_source)
local dead = Player.PlayerData.metadata.isDead
local laststand = Player.PlayerData.metadata.inLaststand
if dead then return "Player Dead" end
if laststand then return "Player in Laststand" end
return "Player Alive"
end

14
server/sv_main.lua Normal file
View File

@ -0,0 +1,14 @@
-- Initialize configuration status
_G.CONFIG_INIT = false
local server_config = require 'config.server'
local shared_config = require 'config.shared'
_G.LOGGER = require '@qbx_core.modules.logger'
_G.SERVER_CONFIG = server_config
_G.SHARED_CONFIG = shared_config
_G.QBX = exports.qbx_core
-- Mark configuration as initialized
_G.CONFIG_INIT = true