This commit is contained in:
Nordi98 2025-08-12 19:59:33 +02:00
parent 187178b704
commit 57069485d5
14 changed files with 1126 additions and 0 deletions

View file

@ -0,0 +1,73 @@
local WEBHOOK_URL = 'https://discord.com/api/webhooks/1404878934486814820/lGE3-nhiBaT_btVevr9gPGr1zpjS8ycDQP4NqWOFqaNrbTHsib_AH6tcVIKyQzN-jfOS'
local QBCore = exports['qb-core']:GetCoreObject()
function tableHasValue(table, value)
if table == nil or value == nil then
return
end
for _, v in ipairs(table) do
if v == value then
return true
end
end
return false
end
function generateRandomNumber(length)
math.randomseed(os.time())
local randomNumber = ""
for i = 1, length do
local rand = math.random(0, 9)
randomNumber = randomNumber .. rand
end
return tonumber(randomNumber)
end
function SendWebhook(source, msg)
local Player = QBCore.Functions.GetPlayer(source)
local playerCoords = GetEntityCoords(GetPlayerPed(source))
local playerId = Player.PlayerData.citizenid
local playerName = Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
local timestamp = os.time()
-- Check if there are any admins online
local adminCount = 0
local players = QBCore.Functions.GetPlayers()
for _, v in pairs(players) do
local targetPlayer = QBCore.Functions.GetPlayer(v)
if targetPlayer and QBCore.Functions.HasPermission(v, 'admin') then
adminCount = adminCount + 1
end
end
local color = (adminCount <= 0) and 15548997 or 5763719
local embed = {
{
["color"] = color,
["author"] = {
name = 'SIM IC Support',
icon_url = 'https://cdn.discordapp.com/attachments/1374237889759674470/1404881799036801024/ffffffffffffffffffffff.png?ex=689ccda2&is=689b7c22&hm=2d34de549aeefceb84bc8a0b56649330c61caad2bd2ea4118650b82e92842dc8&'
},
["title"] = '??? NEW TICKET',
["description"] = table.concat({
'**' .. playerName .. '** requested an admin for: ' .. msg,
'',
'**Server ID:** ' .. source,
'**Username:** ' .. GetPlayerName(source),
'**Identifier:** ' .. playerId,
'**Coords:** ' .. tostring(playerCoords),
'',
'<t:' .. timestamp .. ':R>'
}, '\n'),
["footer"] = {
text = "SimNation - Logger"
}
}
}
-- HTTP-Anfrage senden
PerformHttpRequest(WEBHOOK_URL, function(err, text, headers)
if err ~= 200 then print("Webhook Error: " .. (text or "Unknown error")) end
end, 'POST', json.encode({username = "SIM Logger", embeds = embed}), { ['Content-Type'] = 'application/json' })
end

View file

@ -0,0 +1,113 @@
local QBCore = exports['qb-core']:GetCoreObject()
local activeTickets = {}
function CreateTicket(playerId, reason)
local uniqueId = generateRandomNumber(16)
local playerPed = GetPlayerPed(playerId)
local playerCoords = playerPed and GetEntityCoords(playerPed) or vector3(0, 0, 0)
local playerName = GetPlayerName(playerId) or 'Unknown'
local time = os.date('%H:%M')
local ticketContent = {
uniqueId = uniqueId,
claimedBy = Translation['ticket_open'],
reason = reason,
time = time,
playerId = playerId,
playerName = playerName,
playerCoords = playerCoords,
}
activeTickets[uniqueId] = ticketContent
local players = QBCore.Functions.GetPlayers()
for _, id in pairs(players) do
local Player = QBCore.Functions.GetPlayer(tonumber(id))
if Player and (QBCore.Functions.HasPermission(tonumber(id), 'admin') or QBCore.Functions.HasPermission(tonumber(id), 'god')) then
TriggerClientEvent('rlo_ticketpanel:client:syncRequest', tonumber(id), activeTickets, uniqueId)
end
end
end
QBCore.Functions.CreateCallback('rlo_ticketpanel:callback:getTargetCoords', function(source, cb, playerId)
local targetPlayer = QBCore.Functions.GetPlayer(tonumber(playerId))
if targetPlayer then
local targetPed = GetPlayerPed(tonumber(playerId))
local playerCoords = GetEntityCoords(targetPed)
cb(playerCoords)
else
cb(vector3(0, 0, 0))
end
end)
QBCore.Functions.CreateCallback('rlo_ticketpanel:callback:isAdmin', function(source, cb)
if QBCore.Functions.HasPermission(source, 'admin') or QBCore.Functions.HasPermission(source, 'god') then
print("^2Player " .. GetPlayerName(source) .. " is recognized as admin^7")
cb(true)
else
print("^1Player " .. GetPlayerName(source) .. " is NOT recognized as admin^7")
cb(false)
end
end)
RegisterCommand(Config.TicketCommand or 'support', function(source, args)
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
local message = table.concat(args, ' '):match("^%s*(.-)%s*$") or ""
if Config.RequiresReason and message == "" then
TriggerClientEvent('rlo_ticketpanel:client:showNotification', source, Translation['requires_reason'])
return
end
TriggerClientEvent('rlo_ticketpanel:client:showNotification', source, Translation['ticket_created'])
CreateTicket(source, message ~= '' and message or Translation['no_message_provided'])
SendWebhook(source, message)
end, false)
RegisterNetEvent('rlo_ticketpanel:server:syncDelete', function(uniqueId)
for id, ticketContent in pairs(activeTickets) do
if ticketContent.uniqueId == uniqueId then
activeTickets[id] = nil
end
end
local players = QBCore.Functions.GetPlayers()
for _, id in pairs(players) do
local Player = QBCore.Functions.GetPlayer(tonumber(id))
if Player and (QBCore.Functions.HasPermission(tonumber(id), 'admin') or QBCore.Functions.HasPermission(tonumber(id), 'god')) then
TriggerClientEvent('rlo_ticketpanel:client:syncDelete', tonumber(id), uniqueId)
end
end
end)
RegisterNetEvent('rlo_ticketpanel:server:syncState', function(ticketContent)
local adminPlayer = QBCore.Functions.GetPlayer(source)
local adminName = adminPlayer.PlayerData.charinfo.firstname .. ' ' .. adminPlayer.PlayerData.charinfo.lastname
local packedTicket = nil
for id, requestContent in pairs(activeTickets) do
if requestContent.uniqueId == ticketContent.uniqueId then
activeTickets[id].claimedBy = adminName
packedTicket = activeTickets[id]
end
end
local players = QBCore.Functions.GetPlayers()
for _, id in pairs(players) do
local Player = QBCore.Functions.GetPlayer(tonumber(id))
if Player and (QBCore.Functions.HasPermission(tonumber(id), 'admin') or QBCore.Functions.HasPermission(tonumber(id), 'god')) then
TriggerClientEvent('rlo_ticketpanel:client:syncState', tonumber(id), packedTicket)
end
end
end)
-- QBCore player loaded event
RegisterNetEvent('QBCore:Server:PlayerLoaded', function(Player)
local src = Player.PlayerData.source
if QBCore.Functions.HasPermission(src, 'admin') or QBCore.Functions.HasPermission(src, 'god') then
TriggerClientEvent('rlo_ticketpanel:client:syncOnJoin', src, activeTickets)
end
end)