forked from Simnation/Main
ed
This commit is contained in:
parent
187178b704
commit
57069485d5
14 changed files with 1126 additions and 0 deletions
148
resources/[Developer]/[Max]/ticketpanel_qb/client/cl_main.lua
Normal file
148
resources/[Developer]/[Max]/ticketpanel_qb/client/cl_main.lua
Normal file
|
@ -0,0 +1,148 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
local isInPanel, noNotify = false, false
|
||||
|
||||
RegisterNUICallback('close', function(data, cb) closeUi() end)
|
||||
function closeUi()
|
||||
isInPanel = false
|
||||
SetNuiFocus(false, false)
|
||||
SetNuiFocusKeepInput(false)
|
||||
SendNUIMessage({type = 'close'})
|
||||
end
|
||||
|
||||
RegisterCommand(Config.PanelCommand or 'adminPanel', function(source, args, rawCommand)
|
||||
QBCore.Functions.TriggerCallback('rlo_ticketpanel:callback:isAdmin', function(isAdmin)
|
||||
if isAdmin then
|
||||
if not isInPanel then
|
||||
isInPanel = true
|
||||
SendNUIMessage({type = 'open'})
|
||||
SetNuiFocus(true, true)
|
||||
if Config.KeepInput then
|
||||
SetNuiFocusKeepInput(true)
|
||||
CreateThread(function()
|
||||
while isInPanel do
|
||||
Wait(0)
|
||||
DisableControlAction(0, 24, true) --INPUT_ATTACK
|
||||
DisableControlAction(0, 45, true) --INPUT_RELOAD
|
||||
DisableControlAction(0, 1, true) --LookLeftRight
|
||||
DisableControlAction(0, 2, true) --LookUpDown
|
||||
DisableControlAction(2, 200, true) --ESC
|
||||
|
||||
if IsDisabledControlJustReleased(2, 200) then
|
||||
closeUi()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
else
|
||||
ShowNotification(Translation['no_perms'])
|
||||
end
|
||||
end, source)
|
||||
end)
|
||||
|
||||
RegisterCommand(Config.NoNotifyCommand or 'noNotify', function(source, args, rawCommand)
|
||||
QBCore.Functions.TriggerCallback('rlo_ticketpanel:callback:isAdmin', function(isAdmin)
|
||||
if not isAdmin then
|
||||
ShowNotification(Translation['no_perms'])
|
||||
return
|
||||
end
|
||||
|
||||
noNotify = not noNotify
|
||||
local message = noNotify and Translation['nonotify_enable'] or Translation['nonotify_disable']
|
||||
ShowNotification(message)
|
||||
end, source)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('rlo_ticketpanel:client:syncRequest', function(activeTickets, newUniqueId)
|
||||
local ticketContent = activeTickets[newUniqueId]
|
||||
if not ticketContent then return end
|
||||
|
||||
-- Sichere Debug-Ausgabe ohne QBCore.Debug
|
||||
print('Trying to sync, TicketContent:')
|
||||
for k, v in pairs(ticketContent) do
|
||||
print(k, v)
|
||||
end
|
||||
|
||||
SendNUIMessage({type = 'createTicket', ticketContent = ticketContent})
|
||||
|
||||
if not noNotify then
|
||||
print('Notifying!')
|
||||
TriggerEvent('chat:addMessage', {
|
||||
template = '<div class="chat-message support"><i class="fas fa-bell"></i> <b><span style="color: #28b3de"> Support-Anfrage {0}</span> <span style="font-size: 14px; color: #e1e1e1;"></span></b><div style="margin-top: 5px; font-weight: 300;">{1}</div></div>',
|
||||
args = { '[' .. ticketContent.playerName .. ' - ' .. ticketContent.playerId .. ']', ticketContent.reason }
|
||||
})
|
||||
|
||||
if Config.Sound.Enabled then
|
||||
print('Sound is enabled, trying to play sound...')
|
||||
|
||||
-- Prüfe, ob xSound gestartet ist
|
||||
local xsoundState = GetResourceState('xsound')
|
||||
print('xSound resource state: ' .. xsoundState)
|
||||
|
||||
if xsoundState ~= 'started' then
|
||||
print('^1Error: xSound resource is not started!^7')
|
||||
else
|
||||
print('^2Attempting to play sound with xSound...^7')
|
||||
print('Sound URL: ' .. Config.Sound.URL)
|
||||
print('Sound Volume: ' .. Config.Sound.Volume)
|
||||
|
||||
-- Eindeutige Sound-ID für jede Benachrichtigung
|
||||
local soundId = 'ticket_notify_' .. math.random(100000, 999999)
|
||||
|
||||
-- Direkter Aufruf ohne pcall für bessere Fehlermeldungen
|
||||
print('Trying to play sound with direct method...')
|
||||
exports['xsound']:PlayUrl(soundId, Config.Sound.URL, Config.Sound.Volume, false)
|
||||
|
||||
-- Sound nach 10 Sekunden stoppen
|
||||
Citizen.SetTimeout(1500, function()
|
||||
if exports['xsound']:soundExists(soundId) then
|
||||
exports['xsound']:Destroy(soundId)
|
||||
print('Sound stopped after 10 seconds timeout')
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNUICallback('waypoint', function(data)
|
||||
SetNewWaypoint(data.x, data.y)
|
||||
ShowNotification(Translation['set_waypoint'])
|
||||
end)
|
||||
|
||||
RegisterNUICallback('teleport', function(targetId)
|
||||
QBCore.Functions.TriggerCallback('rlo_ticketpanel:callback:getTargetCoords', function(targetCoords)
|
||||
SetEntityCoords(PlayerPedId(), targetCoords.x, targetCoords.y, targetCoords.z)
|
||||
ShowNotification(Translation['teleported'])
|
||||
end, targetId)
|
||||
end)
|
||||
|
||||
RegisterNUICallback('syncDelete', function(uniqueId) TriggerServerEvent('rlo_ticketpanel:server:syncDelete', uniqueId) end)
|
||||
RegisterNetEvent('rlo_ticketpanel:client:syncDelete', function(uniqueId) SendNUIMessage({type = 'removeTicket', uniqueId = uniqueId}) end)
|
||||
|
||||
RegisterNUICallback('syncState', function(ticketContent)
|
||||
-- Sichere Debug-Ausgabe ohne QBCore.Debug
|
||||
print('(Client) syncing this is the ticket content:')
|
||||
for k, v in pairs(ticketContent) do
|
||||
print(k, v)
|
||||
end
|
||||
|
||||
TriggerServerEvent('rlo_ticketpanel:server:syncState', ticketContent)
|
||||
end)
|
||||
RegisterNetEvent('rlo_ticketpanel:client:syncState', function(ticketContent) SendNUIMessage({type = 'syncState', ticketContent = ticketContent}) end)
|
||||
|
||||
RegisterNetEvent('rlo_ticketpanel:client:syncOnJoin', function(activeTickets)
|
||||
if not activeTickets then
|
||||
print('Active Tickets is nil')
|
||||
return
|
||||
end
|
||||
|
||||
print('Active Tickets:')
|
||||
for uniqueId, ticketContent in pairs(activeTickets) do
|
||||
print('uniqueId: ' .. uniqueId)
|
||||
for k, v in pairs(ticketContent) do
|
||||
print(' ' .. k .. ': ' .. tostring(v))
|
||||
end
|
||||
SendNUIMessage({type = 'createRequest', ticketContent = ticketContent})
|
||||
end
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue