forked from Simnation/Main
ed
This commit is contained in:
parent
187178b704
commit
57069485d5
14 changed files with 1126 additions and 0 deletions
339
resources/[Developer]/[Max]/ticketpanel_qb/LICENSE
Normal file
339
resources/[Developer]/[Max]/ticketpanel_qb/LICENSE
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
70
resources/[Developer]/[Max]/ticketpanel_qb/README.md
Normal file
70
resources/[Developer]/[Max]/ticketpanel_qb/README.md
Normal file
|
@ -0,0 +1,70 @@
|
|||
# rlo_ticketpanel
|
||||
This FiveM script for ESX provides an intuitive in-game UI where players can create support tickets. Moderators can then access these tickets, claim them, teleport directly to the player, and manage the entire support process efficiently within the game. It streamlines support, making it easier for both players to get help and staff to provide it.
|
||||
|
||||
## Features
|
||||
|
||||
- **Manage Tickets:** Easily claim them and start working! Teleport, Waypoint and more directly possible.
|
||||
- **Simple User Interface:** Management of tickets made simple.
|
||||
- **XSound Integration:** For a immersive sound.
|
||||
- **Easy Configuration:** All settings can be customized in the `Config.lua` file.
|
||||
|
||||
## Installation
|
||||
|
||||
1. Download this repository and place it in your FiveM server's resources folder.
|
||||
2. Ensure that ESX is installed on your server.
|
||||
3. Add the script to your `server.cfg` file:
|
||||
|
||||
```plaintext
|
||||
ensure rlo_ticketpanel
|
||||
```
|
||||
|
||||
4. Add your Discord Webhook API key for logs at `server/sv_functions.lua` in the first line.
|
||||
5. Adjust the configuration in the `config.lua` file to meet your server requirements.
|
||||
|
||||
## Configuration
|
||||
|
||||
The configuration is handled via the `config.lua` file. Here are some of the key options:
|
||||
|
||||
```lua
|
||||
Config = {
|
||||
Debug = false,
|
||||
Groups = {'admin'},
|
||||
|
||||
TicketCommand = 'support',
|
||||
RequiresReason = true,
|
||||
|
||||
PanelCommand = 'ap',
|
||||
KeepInput = true,
|
||||
|
||||
NoNotifyCommand = 'noadmin',
|
||||
|
||||
Sound = { -- requires xsound
|
||||
Enabled = true,
|
||||
URL = './sounds/adminNotification.ogg',
|
||||
Volume = 1.0,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Zones
|
||||
|
||||
You can customize the translation of the script directly in the `config.lua` in the bottom.
|
||||
|
||||
```lua
|
||||
Translation = {
|
||||
['no_perms'] = '~r~You do not have permissions to use this command',
|
||||
['ticket_created'] = 'Your Ticket got created ~g~successfully ~s~!',
|
||||
['requires_reason'] = 'You ~r~need to provide a message~s~ to request support!',
|
||||
['no_message_provided'] = 'No message',
|
||||
['set_waypoint'] = 'You set a waypoint to the player ~g~successfully.',
|
||||
['teleported'] = 'You teleported to the player ~g~successfully.',
|
||||
['ticket_open'] = 'Open',
|
||||
['nonotify_enable'] = 'You will not recieve a notification for tickets anymore!',
|
||||
['nonotify_disable'] = 'You will recieve a notification for tickets again!',
|
||||
}
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
- **[ESX](https://github.com/esx-framework/esx_core):** ESX framework for FiveM.
|
||||
- **[xsound (optional)]([https://github.com/overextended/ox_lib](https://github.com/Xogy/xsound)):** Improved audio library for FiveM.
|
|
@ -0,0 +1,9 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
RegisterNetEvent('rlo_ticketpanel:client:showNotification', function(args)
|
||||
ShowNotification(args)
|
||||
end)
|
||||
|
||||
function ShowNotification(args)
|
||||
QBCore.Functions.Notify(args)
|
||||
end
|
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)
|
31
resources/[Developer]/[Max]/ticketpanel_qb/config.lua
Normal file
31
resources/[Developer]/[Max]/ticketpanel_qb/config.lua
Normal file
|
@ -0,0 +1,31 @@
|
|||
Config = {
|
||||
Debug = false,
|
||||
Groups = {'admin', 'god'},
|
||||
|
||||
TicketCommand = 'support',
|
||||
RequiresReason = true,
|
||||
|
||||
PanelCommand = 'cp',
|
||||
KeepInput = true,
|
||||
|
||||
NoNotifyCommand = 'noadmin',
|
||||
|
||||
Sound = { -- requires xsound
|
||||
Enabled = true,
|
||||
-- Verwende eine direkte URL zu einer MP3-Datei
|
||||
URL = 'https://cdn.discordapp.com/attachments/1372013724503642203/1404875126083944600/hey_listen.mp3?ex=689cc76b&is=689b75eb&hm=df580a028ae53f20f2d9767d1cb52259e8d1b1f8b275525ba64196d585305864&', -- Beispiel-URL, ersetze mit deiner eigenen
|
||||
Volume = 0.8,
|
||||
}
|
||||
}
|
||||
|
||||
Translation = {
|
||||
['no_perms'] = 'Du hast keine Berechtigung',
|
||||
['ticket_created'] = 'Du hast erfolgreich ein Support-Ticket erstellt!',
|
||||
['requires_reason'] = 'Du musst einen Grund angeben, um ein Ticket zu öffnen!',
|
||||
['no_message_provided'] = 'Keine Nachricht',
|
||||
['set_waypoint'] = 'Wegpunkt zum Spieler erfolgreich gesetzt.',
|
||||
['teleported'] = 'Erfolgreich zum Spieler teleportiert.',
|
||||
['ticket_open'] = 'Offen',
|
||||
['nonotify_enable'] = 'Du erhältst keine Benachrichtigungen mehr für Tickets!',
|
||||
['nonotify_disable'] = 'Du erhältst wieder Benachrichtigungen für Tickets!',
|
||||
}
|
35
resources/[Developer]/[Max]/ticketpanel_qb/fxmanifest.lua
Normal file
35
resources/[Developer]/[Max]/ticketpanel_qb/fxmanifest.lua
Normal file
|
@ -0,0 +1,35 @@
|
|||
fx_version 'cerulean'
|
||||
games {'gta5'}
|
||||
lua54 'yes'
|
||||
|
||||
author 'SirLamaGott'
|
||||
description 'Admin Ticket Panel'
|
||||
version '1.1.2'
|
||||
ui_page 'web/index.html'
|
||||
|
||||
shared_scripts {
|
||||
'config.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'client/cl_main.lua',
|
||||
'client/cl_functions.lua',
|
||||
}
|
||||
|
||||
server_scripts {
|
||||
'server/sv_main.lua',
|
||||
'server/sv_functions.lua',
|
||||
}
|
||||
|
||||
files {
|
||||
'web/index.html',
|
||||
'web/css/style.css',
|
||||
'web/js/main.js',
|
||||
'web/image/*.png',
|
||||
'web/image/*.svg',
|
||||
}
|
||||
|
||||
dependencies {
|
||||
'qb-core',
|
||||
'xsound',
|
||||
}
|
8
resources/[Developer]/[Max]/ticketpanel_qb/readme
Normal file
8
resources/[Developer]/[Max]/ticketpanel_qb/readme
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
##############################
|
||||
####################################
|
||||
|
||||
## Dieses Script wurde NUR für PRIVATE ZWECKE auf QB_Core umgeschrieben! Autor ist RLO_SirLamaGott
|
||||
|
||||
####################################
|
||||
##############################
|
|
@ -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
|
113
resources/[Developer]/[Max]/ticketpanel_qb/server/sv_main.lua
Normal file
113
resources/[Developer]/[Max]/ticketpanel_qb/server/sv_main.lua
Normal 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)
|
144
resources/[Developer]/[Max]/ticketpanel_qb/web/css/style.css
Normal file
144
resources/[Developer]/[Max]/ticketpanel_qb/web/css/style.css
Normal file
|
@ -0,0 +1,144 @@
|
|||
body {
|
||||
background: none;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.header, .content-header {
|
||||
background-color: #2c2c2c;
|
||||
padding: 15px 20px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.header h2 {
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.header .btn, .content-header .btn {
|
||||
margin: 5px;
|
||||
padding: 8px 12px;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.header .btn:hover, .content-header .btn:hover {
|
||||
background-color: #414141;
|
||||
}
|
||||
|
||||
.content-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.content-header .column {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.content-header .column img {
|
||||
width: 27px;
|
||||
height: 27px;
|
||||
margin-right: 10px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.price-up {
|
||||
color: #4caf50; /* Modernes Grün */
|
||||
}
|
||||
|
||||
.price-equal {
|
||||
color: #d3d3d3;
|
||||
}
|
||||
|
||||
.price-down {
|
||||
color: #ff5252; /* Lebendigeres Rot */
|
||||
}
|
||||
|
||||
.bor {
|
||||
border-bottom: 2px solid #555555;
|
||||
}
|
||||
|
||||
.up, .down {
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.up:hover, .down:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
filter: invert(1) brightness(2);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.icon:hover {
|
||||
transform: rotate(20deg);
|
||||
}
|
||||
|
||||
.input-shorter {
|
||||
width: 200px;
|
||||
margin: 6px;
|
||||
padding: 8px;
|
||||
border: 1px solid #444;
|
||||
background-color: #3a3a3a;
|
||||
color: #e0e0e0;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.input-shorter:focus {
|
||||
outline: none;
|
||||
border-color: #007bff;
|
||||
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
|
||||
}
|
||||
|
||||
.background-container {
|
||||
background-color: #2e2e2e;
|
||||
padding: 20px;
|
||||
margin: 50px auto;
|
||||
border-radius: 10px;
|
||||
max-width: 1200px;
|
||||
}
|
||||
|
||||
.max-bounds {
|
||||
max-width: 1400px; /* 1200px */
|
||||
max-height: 768px;
|
||||
padding: 27.5px;
|
||||
overflow-y: auto;
|
||||
background: #1e1e1e;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.55);
|
||||
}
|
||||
|
||||
/* Modern Scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #2c2c2c;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: rgba(180, 180, 180, 0.4);
|
||||
border-radius: 10px;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background-color: rgba(180, 180, 180, 0.7);
|
||||
}
|
||||
|
||||
.header .btn, .content-header .btn {
|
||||
margin: 8px;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 24 24" width="512" height="512"><path d="m16.707,8.707l-3.293,3.293,3.293,3.293-1.414,1.414-3.293-3.293-3.293,3.293-1.414-1.414,3.293-3.293-3.293-3.293,1.414-1.414,3.293,3.293,3.293-3.293,1.414,1.414Zm7.293,3.293c0,6.617-5.383,12-12,12S0,18.617,0,12,5.383,0,12,0s12,5.383,12,12Zm-2,0c0-5.514-4.486-10-10-10S2,6.486,2,12s4.486,10,10,10,10-4.486,10-10Z"/></svg>
|
After Width: | Height: | Size: 485 B |
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" fill="#FFFFFF" viewBox="0 0 24 24" width="512" height="512"><path d="M21,21H3c-1.657,0-3-1.343-3-3v-4l1.096,.003c1.1-.029,1.986-.855,1.986-1.962s-.884-2.009-1.982-2.04l-1.1,.003V6c0-1.657,1.343-3,3-3H21c1.657,0,3,1.343,3,3v4h-.888c-.997,0-1.922,.679-2.084,1.662-.206,1.252,.758,2.338,1.972,2.338h1v4c0,1.657-1.343,3-3,3Z"/></svg>
|
After Width: | Height: | Size: 442 B |
31
resources/[Developer]/[Max]/ticketpanel_qb/web/index.html
Normal file
31
resources/[Developer]/[Max]/ticketpanel_qb/web/index.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<meta charset='UTF-8'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>Ticket Panel</title>
|
||||
<link href='https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css' rel='stylesheet'>
|
||||
<link href='css/style.css' rel='stylesheet'>
|
||||
</head>
|
||||
|
||||
<body class='d-none'>
|
||||
<div class='container mt-5 max-bounds'>
|
||||
<div class='header row align-items-center'>
|
||||
<div class='col-md-3'>
|
||||
<h2>Ticket Panel</h2>
|
||||
</div>
|
||||
<div class='col-md-9 d-flex justify-content-end align-items-center'>
|
||||
<button class='btn btn-secondary d-flex align-items-center justify-content-center' onClick='closeUi()' style='height: 39px;'>
|
||||
<img src='image/circle-xmark.svg' alt='Close' class='icon'>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id='content'></div>
|
||||
</div>
|
||||
|
||||
<script src='https://code.jquery.com/jquery-3.5.1.slim.min.js'></script>
|
||||
<script src='https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js'></script>
|
||||
<script src='https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js'></script>
|
||||
<script src='js/main.js'></script>
|
||||
</body>
|
||||
</html>
|
121
resources/[Developer]/[Max]/ticketpanel_qb/web/js/main.js
Normal file
121
resources/[Developer]/[Max]/ticketpanel_qb/web/js/main.js
Normal file
|
@ -0,0 +1,121 @@
|
|||
$(function() {
|
||||
window.addEventListener('message', (event) => {
|
||||
const { data } = event;
|
||||
if (!data || !data.type) return;
|
||||
|
||||
const actions = {
|
||||
'open': () => $('body').removeClass('d-none'),
|
||||
'close': () => $('body').addClass('d-none'),
|
||||
'removeTicket': () => removeTicket(data.uniqueId),
|
||||
'createTicket': () => createTicket(data.ticketContent),
|
||||
'syncState': () => changeState(data.ticketContent),
|
||||
};
|
||||
|
||||
const action = actions[data.type];
|
||||
if (action) action();
|
||||
});
|
||||
});
|
||||
|
||||
function createTicket(ticketContent) {
|
||||
const { uniqueId, claimedBy, playerName, playerId, reason, time, playerCoords } = ticketContent;
|
||||
|
||||
const createElement = (tag, { className = '', textContent = '', attributes = {} } = {}) => {
|
||||
const element = document.createElement(tag);
|
||||
if (className) element.className = className;
|
||||
if (textContent) element.textContent = textContent;
|
||||
Object.entries(attributes).forEach(([key, value]) => element.setAttribute(key, value));
|
||||
return element;
|
||||
};
|
||||
|
||||
const createButton = (text, className, onClick) => {
|
||||
const button = createElement('button', { className, textContent: text });
|
||||
button.style.height = '38px';
|
||||
button.addEventListener('click', onClick);
|
||||
return button;
|
||||
};
|
||||
|
||||
const contentHeader = createElement('div', {
|
||||
className: 'content-header row mt-1 text-center bor',
|
||||
attributes: { 'data-unique-id': uniqueId },
|
||||
});
|
||||
|
||||
const col1 = createElement('div', { className: 'col-md-2 column' });
|
||||
const img = createElement('img', { attributes: { src: 'image/ticket.svg', alt: 'Icon' } });
|
||||
const playerInfo = createElement('div', { textContent: `${playerName} [${playerId}]` });
|
||||
col1.append(img, playerInfo);
|
||||
|
||||
const col2 = createElement('div', { className: 'col-md-3 column', textContent: reason });
|
||||
|
||||
const col5 = createElement('div', { className: 'col-sm column align-items-center justify-content-center', textContent: `${time} Uhr` });
|
||||
|
||||
const col3 = createElement('div', { className: 'col-md-2 column' });
|
||||
const buttonOpen = createButton(claimedBy, 'btn btn-success me-2 d-flex align-items-center justify-content-center');
|
||||
col3.appendChild(buttonOpen);
|
||||
|
||||
const col4 = createElement('div', { className: 'column' });
|
||||
const buttonClaim = createButton('Claim', 'btn btn-info me-2 d-flex align-items-center justify-content-center', () => {
|
||||
fetch(`https://${GetParentResourceName()}/syncState`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(ticketContent),
|
||||
headers: {'Content-Type': 'application/json; charset=UTF-8'},
|
||||
}).catch(err => console.error(err));
|
||||
});
|
||||
|
||||
const buttonTP = createButton('TP', 'btn btn-secondary me-2 d-flex align-items-center justify-content-center', () => teleport(playerId));
|
||||
const buttonWP = createButton('WP', 'btn btn-secondary me-2 d-flex align-items-center justify-content-center', () => waypoint(playerCoords));
|
||||
const buttonDEL = createButton('DEL', 'btn btn-danger me-2 d-flex align-items-center justify-content-center', () => {
|
||||
fetch(`https://${GetParentResourceName()}/syncDelete`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(uniqueId),
|
||||
headers: {'Content-Type': 'application/json; charset=UTF-8'},
|
||||
}).catch(err => console.error(err));
|
||||
});
|
||||
|
||||
col4.append(buttonClaim, buttonTP, buttonWP, buttonDEL);
|
||||
contentHeader.append(col1, col2, col5, col3, col4);
|
||||
|
||||
document.getElementById('content').appendChild(contentHeader);
|
||||
console.log('I created a ticket with id: ' + uniqueId)
|
||||
}
|
||||
|
||||
function changeState(ticketContent) {
|
||||
const element = document.querySelector(`.content-header[data-unique-id="${ticketContent.uniqueId}"]`);
|
||||
if (element) {
|
||||
const button = element.querySelector('button.btn-success');
|
||||
if (button) {
|
||||
console.log(ticketContent.claimedBy);
|
||||
button.textContent = ticketContent.claimedBy;
|
||||
button.className = 'btn btn-warning me-2 d-flex align-items-center justify-content-center';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function teleport(playerId) {
|
||||
fetch(`https://${GetParentResourceName()}/teleport`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(playerId),
|
||||
headers: {'Content-Type': 'application/json; charset=UTF-8'},
|
||||
}).catch(err => console.error(err));
|
||||
}
|
||||
|
||||
function waypoint(playerCoords) {
|
||||
fetch(`https://${GetParentResourceName()}/waypoint`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(playerCoords),
|
||||
headers: {'Content-Type': 'application/json; charset=UTF-8'},
|
||||
}).catch(err => console.error(err));
|
||||
}
|
||||
|
||||
function removeTicket(uniqueId) {
|
||||
const element = document.querySelector(`.content-header[data-unique-id="${uniqueId}"]`);
|
||||
if (element) {
|
||||
element.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function closeUi() {
|
||||
fetch(`https://${GetParentResourceName()}/close`, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json; charset=UTF-8'}
|
||||
}).catch(error => console.error('Error:', error));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue