1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-04 04:28:47 +02:00
parent 875c8448e1
commit c81ae4bb6d
219 changed files with 8036 additions and 7 deletions

View file

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey 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;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
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
state 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 3 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, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU 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. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View file

@ -0,0 +1,43 @@
# Byte Labs - Bridge
An extendible and modular bridge for FiveM Frameworks. Made to unify and simplify the process of creating and maintaining resources for multiple frameworks.
Website: [Byte Labs](https://byte-labs.net)
Discord: [Byte Labs](https://discord.gg/fqsqSjZfxE)
# Instruction (Follow [Docs](https://docs.byte-labs.net/bl_bridge))
### Do `none` to disable wanted module like `setr bl:inventory 'none'` if we want to disable inventory module
## CFG
```
# Frameworks 'ox' | 'qb' | 'esx' | 'qbx'
setr bl:framework 'qb'
# Inventories 'ox' | 'qb' | 'esx' | 'ps' | 'qs' | 'origen' | 'none'
setr bl:inventory 'ox'
# Context 'ox' | 'qb'
setr bl:context 'ox'
# Target 'ox' | 'qb'
setr bl:target 'ox'
# Progress 'ox' | 'qb'
setr bl:progressbar 'ox'
# Radial 'ox' | 'qb'
setr bl:radial 'ox'
# Notification 'ox' | 'qb' | 'esx'
setr bl:notify 'ox'
# TextUI 'ox' | 'qb' | 'esx'
setr bl:textui 'ox'
```
## Import
```lua
client_scripts '@bl_bridge/imports/client.lua',
server_scripts '@bl_bridge/imports/server.lua',
```

View file

@ -0,0 +1,49 @@
---@alias IconProp 'fas' | 'far' | 'fal' | 'fat' | 'fad' | 'fab' | 'fak' | 'fass'
---@alias NotificationPosition 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' | 'center-right' | 'center-left'
---@alias MoneyType 'cash' | 'bank'
---@alias CharInfo {firstname: string, lastname: string}
---@alias GroupData {name: string, label: string, onDuty: boolean, isBoss: boolean, grade: {name: string, label: string, salary: number}}
---@class NotificationParams
---@field title? string
---@field description? string
---@field duration? number
---@field position? NotificationPosition
---@field status? 'info' | 'warning' | 'success' | 'error'
---@field id? number
---@class ContextMenuItem
---@field title? string
---@field menu? string
---@field icon? string | {[1]: IconProp, [2]: string};
---@field iconColor? string
---@field image? string
---@field progress? number
---@field onSelect? fun(args: any)
---@field arrow? boolean
---@field description? string
---@field metadata? string | { [string]: any } | string[]
---@field disabled? boolean
---@field event? string
---@field serverEvent? string
---@field args? any
---@class ContextMenuArrayItem : ContextMenuItem
---@field title string
---@class ContextMenuProps
---@field id string
---@field title string
---@field menu? string
---@field onExit? fun()
---@field onBack? fun()
---@field canClose? boolean
---@field options { [string]: ContextMenuItem } | ContextMenuArrayItem[]
---@class TextUIOptions
---@field position? 'right-center' | 'left-center' | 'top-center';
---@field icon? string | {[1]: IconProp, [2]: string};
---@field iconColor? string;
---@field style? string | table;

View file

@ -0,0 +1,27 @@
local Context = {}
local menu = exports.ox_lib
local function findHeader(data)
for k, v in ipairs(data) do
if v.isMenuHeader then
return k, v.title
end
end
return false, 'Header'
end
---@param data ContextMenuProps | ContextMenuProps[]
function Context.openContext(data)
local id = require'utils'.await('UUID', false, 8)
local index, header = findHeader(data)
if index then table.remove(data, index) end
menu:registerContext({id = id, title = header, options = data})
menu:showContext(id)
return id
end
function Context.closeContext(onExit)
menu:hideContext(onExit)
end
return Context

View file

@ -0,0 +1,66 @@
local menuName = 'qb-menu'
if GetResourceState(menuName) ~= 'started' then
error('The imported file from the chosen framework isn\'t starting')
return
end
local Context = {}
local qb_menu = exports[menuName]
local Utils = require 'utils'
local overRideData = {
header = {
originalMethod = 'title',
},
txt = {
originalMethod = 'description',
},
icon = {
originalMethod = 'icon',
modifier = {
executeFunc = true,
effect = function(value)
local text = ('fas fa-%s'):format(value)
return text
end
}
},
params = {
originalMethod = 'none',
hasKeys = true,
modifier = {
effect = function(data)
local params = {}
if data.onSelect then
params.event = data.onSelect
params.isAction = true
elseif data.event then
params.event = data.event
params.args = data.args
elseif data.serverEvent then
params.event = data.serverEvent
params.isServer = true
params.args = data.args
end
return params
end
},
},
disabled = {
originalMethod = 'disabled',
},
isMenuHeader = {
originalMethod = 'isHeader',
},
}
---@param data ContextMenuProps | ContextMenuProps[]
function Context.openContext(data)
qb_menu:openMenu(Utils.retreiveNumberIndexedData(data, overRideData))
end
function Context.closeContext()
qb_menu:closeMenu()
end
return Context

View file

@ -0,0 +1,63 @@
local coreName = 'es_extended'
if GetResourceState(coreName) ~= 'started' then
error('The imported file from the chosen framework isn\'t starting')
return
end
local Core = {}
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
RegisterNetEvent('esx:playerLoaded', function(playerId)
TriggerEvent('bl_bridge:client:playerLoaded', playerId)
end)
RegisterNetEvent('esx:onPlayerLogout', function()
TriggerEvent('bl_bridge:client:playerUnloaded')
end)
RegisterNetEvent('esx:setJob', function(job)
TriggerEvent('bl_bridge:client:jobUpdated', {name = job.name, label = job.label, onDuty = true, isBoss = false, grade = {name = job.grade, label = job.grade_label, salary = job.grade_salary}})
end)
local shared = exports[coreName]:getSharedObject()
local coreFunctionsOverride = {
playerData = {
originalMethod = 'GetPlayerData',
modifier = {
executeFunc = true,
effect = function(originalFun)
while not shared.IsPlayerLoaded() do
Wait(1000)
end
local data = originalFun()
local job = data.job
local month, day, year = data.dateofbirth and data.dateofbirth:match("(%d+)/(%d+)/(%d+)") or 00, 00, 24
return {
cid = data.identifier,
money = data.money or 0,
inventory = data.inventory or {},
job = {name = job.name, label = job.label, onDuty = true, isBoss = false, grade = {name = job.grade, label = job.grade_label, salary = job.grade_salary}},
firstName = data.firstName or 'Unknown',
lastName = data.lastName or 'Unknown',
phone = data.phone_number or '0',
gender = data.sex == 'm' and 'male' or 'female',
dob = ('%s/%s/%s'):format(month, day, year)
}
end
}
},
}
function Core.getPlayerData()
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
return wrappedPlayer.playerData
end
function Core.playerLoaded()
return shared.IsPlayerLoaded()
end
return Core

View file

@ -0,0 +1,74 @@
local coreName = 'ND_Core'
if GetResourceState(coreName) ~= 'started' then
error('The imported file from the chosen framework isn\'t starting')
return
end
local Core = {}
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
local jobInfo = {}
local loaded = false
RegisterNetEvent('ND:characterLoaded', function(character)
TriggerEvent('bl_bridge:client:playerLoaded')
jobInfo = character.jobInfo
jobInfo.name = character.job
loaded = true
Wait(1000)
end)
AddEventHandler("ND:characterUnloaded", function(character)
TriggerEvent('bl_bridge:client:playerUnloaded')
jobInfo = {}
loaded = false
end)
RegisterNetEvent('ND:updateCharacter', function(character)
local jobData = character.jobInfo
if character.job ~= jobInfo.name or jobInfo.rank ~= jobData.rank then
TriggerEvent('bl_bridge:client:jobUpdated', { name = character.job, label = jobData.label, onDuty = true, isBoss = jobData.isBoss or false, grade = { name = jobData.rank, label = jobData.rankName, salary = 0 } })
end
end)
local shared = exports[coreName]
local coreFunctionsOverride = {
playerData = {
originalMethod = 'getPlayer',
modifier = {
executeFunc = true,
effect = function(originalFun)
while not loaded do
Wait(1000)
end
local data = originalFun()
local jobData = data.jobInfo
local year, month, day = data.dob:match("(%d+)-(%d+)-(%d+)")
return {
cid = data.id,
money = data.cash,
inventory = type(data.inventory) == 'string' and json.decode(data.inventory) or data.inventory,
job = { name = data.job, label = jobData.label, onDuty = true, isBoss = jobData.isBoss, grade = { name = jobData.rank, label = jobData.rankName, salary = 0 } },
firstName = data.firstname,
lastName = data.lastname,
phone = 'Unknown',
gender = string.lower(data.gender),
dob = ('%s/%s/%s'):format(month, day, year),
}
end
}
},
}
function Core.getPlayerData()
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
return wrappedPlayer.playerData
end
function Core.playerLoaded()
return loaded
end
return Core

View file

@ -0,0 +1,69 @@
local Ox = require '@ox_core/lib/init'
local Core = {}
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
LocalPlayer.state.isLoggedIn = true
AddEventHandler('ox:playerLoaded', function()
TriggerEvent('bl_bridge:client:playerLoaded')
LocalPlayer.state.isLoggedIn = true
end)
RegisterNetEvent('bl_bridge:client:playerUnloaded',function()
LocalPlayer.state.isLoggedIn = false
end)
local function prepareJobData(job, grade)
return {name = job.name, label = job.label, onDuty = true, isBoss = job.accountRoles[tostring(grade)] == 'owner', type = job.type, grade = { name = grade, label = job.grades[grade], salary = 0 } }
end
RegisterNetEvent('ox:setGroup', function(groupName, grade)
local job = Ox.GetGroup(groupName)
TriggerEvent('bl_bridge:client:jobUpdated', prepareJobData(job, grade))
end)
local coreFunctionsOverride = {
playerData = {
originalMethod = 'GetPlayer',
modifier = {
executeFunc = true,
effect = function(originalFun) -- TODO: lazy loading for all data, only return what need, others can be requested like get(key)
while not LocalPlayer.state.isLoggedIn do
Wait(1000)
end
local data = originalFun()
---@type function
local get = data.get
local activeJob = get('activeGroup')
if not activeJob then return end
local grade = data.getGroup(activeJob)
local job = Ox.GetGroup(activeJob)
local group = prepareJobData(job, grade)
return {
cid = data.citizenid,
money = data.money or 0,
inventory = exports.ox_inventory:GetPlayerItems(),
job = group,
gang = group,
firstName = get('firstName') or 'Unknown',
lastName = get('lastName') or 'Unknown',
phone = get('phoneNumber') or '0000000',
gender = get('gender'),
dob = get('dateOfBirth') -- DD/MM/YYYY
}
end
}
},
}
function Core.getPlayerData()
local wrappedPlayer = retreiveStringIndexedData(Ox, coreFunctionsOverride)
return wrappedPlayer.playerData
end
function Core.playerLoaded()
return LocalPlayer.state.isLoggedIn
end
return Core

View file

@ -0,0 +1,71 @@
local coreName = 'qb-core'
if GetResourceState(coreName) ~= 'started' then
error('The imported file from the chosen framework isn\'t starting')
return
end
local Core = {}
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
TriggerEvent('bl_bridge:client:playerLoaded')
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
TriggerEvent('bl_bridge:client:playerUnloaded')
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(job)
TriggerEvent('bl_bridge:client:jobUpdated', { name = job.name, label = job.label, onDuty = job.onduty, type = job.type, isBoss = job.isboss, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } })
end)
RegisterNetEvent('QBCore:Client:OnGangUpdate', function(gang)
TriggerEvent('bl_bridge:client:gangUpdated', { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } })
end)
local shared = exports[coreName]:GetCoreObject()
local coreFunctionsOverride = {
Functions = {
playerData = {
originalMethod = 'GetPlayerData',
modifier = {
executeFunc = true,
effect = function(originalFun)
while not LocalPlayer.state.isLoggedIn do
Wait(1000)
end
local data = originalFun()
local job = data.job
local gang = data.gang
local charinfo = data.charinfo
local year, month, day = charinfo.birthdate:match("(%d+)-(%d+)-(%d+)")
return {
cid = data.citizenid,
money = data.money or 0,
inventory = type(data.items) == 'string' and json.decode(data.items) or data.items,
job = { name = job.name, label = job.label, onDuty = job.onduty, isBoss = job.isboss, type = job.type, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } },
gang = { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } },
firstName = charinfo.firstname or 'Unknown',
lastName = charinfo.lastname or 'Unknown',
phone = charinfo.phone or '0000000',
gender = charinfo.gender == 1 and 'female' or 'male',
dob = ('%s/%s/%s'):format(month, day, year) -- DD/MM/YYYY
}
end
}
},
},
}
function Core.getPlayerData()
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
return wrappedPlayer.playerData
end
function Core.playerLoaded()
return LocalPlayer.state.isLoggedIn
end
return Core

View file

@ -0,0 +1,69 @@
local coreName = 'qbx_core'
if GetResourceState(coreName) ~= 'started' then
error('The imported file from the chosen framework isn\'t starting')
return
end
local Core = {}
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
TriggerEvent('bl_bridge:client:playerLoaded')
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
TriggerEvent('bl_bridge:client:playerUnloaded')
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(job)
TriggerEvent('bl_bridge:client:jobUpdated', { name = job.name, label = job.label, onDuty = job.onduty, type = job.type, isBoss = job.isboss, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } })
end)
RegisterNetEvent('QBCore:Client:OnGangUpdate', function(gang)
TriggerEvent('bl_bridge:client:gangUpdated', { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } })
end)
local shared = exports[coreName]
local coreFunctionsOverride = {
playerData = {
originalMethod = 'GetPlayerData',
modifier = {
executeFunc = true,
effect = function(originalFun)
while not LocalPlayer.state.isLoggedIn do
Wait(1000)
end
local data = originalFun()
local job = data.job
local gang = data.gang
local charinfo = data.charinfo
local year, month, day = charinfo.birthdate:match("(%d+)-(%d+)-(%d+)")
return {
cid = data.citizenid,
money = data.money or 0,
inventory = type(data.items) == 'string' and json.decode(data.items) or data.items,
job = { name = job.name, label = job.label, onDuty = job.onduty, isBoss = job.isboss, type = job.type, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } },
gang = { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } },
firstName = charinfo.firstname or 'Unknown',
lastName = charinfo.lastname or 'Unknown',
phone = charinfo.phone or '0000000',
gender = charinfo.gender == 1 and 'female' or 'male',
dob = ('%s/%s/%s'):format(month, day, year) -- DD/MM/YYYY
}
end
}
},
}
function Core.getPlayerData()
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
return wrappedPlayer.playerData
end
function Core.playerLoaded()
return LocalPlayer.state.isLoggedIn
end
return Core

View file

@ -0,0 +1,75 @@
local inventory = {}
local invFramework = GetFramework('inventory')
local Utils = require'utils'
local isOx = invFramework == 'ox_inventory'
local isOrigen = invFramework == 'origen_inventory'
local isQS = invFramework == 'qs-inventory'
-- function inventory.items()
-- local inventoryItems = isOx and exports.ox_inventory:Items() or core.getPlayerData().items or {}
-- return inventoryItems
-- end
function inventory.playerItems()
local playerData = {}
if isOx then
playerData = exports.ox_inventory:GetPlayerItems()
elseif isOrigen then
playerData = exports.origen_inventory:GetInventory()
elseif isQS then
playerData = exports['qs-inventory']:getUserInventory()
else
local core = Framework.core
if not core then
Utils.waitFor(function()
if Framework.core then return true end
end)
end
playerData = core.getPlayerData().inventory
end
for _, itemData in pairs(playerData) do
local count = itemData.count
if count then
itemData.amount = count
itemData.count = nil
end
end
return playerData
end
function inventory.openInventory(invType, invId)
if isOx then
exports.ox_inventory:openInventory(invType, invType == 'stash' and invId or {type = invId})
elseif isOrigen then
exports.origen_inventory:openInventory(invType, invId)
elseif invFramework == 'qb-inventory' or isQS then
local inventoryData = Utils.await('bl_bridge:validInventory', 10, invType, invId)
if not inventoryData then return end
TriggerServerEvent('inventory:server:OpenInventory', invType, invId, inventoryData)
end
end
function inventory.hasItem(itemName, itemCount)
itemCount = itemCount or 1
local playerData = inventory.playerItems()
local notify = Framework.notify
if type(itemName) ~= 'string' then
notify({
title = 'item isn\'t string'
})
return
end
for _, itemData in pairs(playerData) do
local name, amount in itemData
if itemName == name and itemCount <= amount then
return true
end
end
return false
end
return inventory

View file

@ -0,0 +1,10 @@
---@diagnostic disable: lowercase-global
---@param data NotificationParams Notification data
function notify(data)
local title, type, duration in data
if type == 'inform' then type = 'info' end
exports.es_extended:getSharedObject().ShowNotification(title, type, duration)
end
return notify

View file

@ -0,0 +1,8 @@
---@diagnostic disable: lowercase-global
---@param data NotificationParams Notification data
function notify(data)
exports.ox_lib:notify(data)
end
return notify

View file

@ -0,0 +1,10 @@
---@diagnostic disable: lowercase-global
---@param data NotificationParams Notification data
function notify(data)
local title, type, duration in data
if type == 'inform' then type = 'info' end
TriggerEvent('QBCore:Notify', title, type, duration)
end
return notify

View file

@ -0,0 +1,28 @@
local Progressbar = {}
function Progressbar.showProgress(data)
return exports.ox_lib:progressBar({
duration = data.duration,
label = data.label,
useWhileDead = data.useWhileDead,
canCancel = data.canCancel,
disable = data.disableControl,
anim = data.animation,
prop = {
model = data.prop?.model,
bone = data.prop?.bone,
pos = data.prop?.pos,
rot = data.prop?.rot
},
})
end
function Progressbar.cancelProgress()
exports.ox_lib:cancelProgress()
end
function Progressbar.isProgressActive()
return exports.ox_lib:progressActive()
end
return Progressbar

View file

@ -0,0 +1,52 @@
local Progressbar = {}
Progressbar.state = false
function Progressbar.showProgress(data)
local prop, animation, disableControl in data
local promise = promise.new()
disableControl = disableControl or {}
exports['progressbar']:Progress({
name = 'progress',
duration = data.duration,
label = data.label,
useWhileDead = data.useWhileDead,
canCancel = data.canCancel,
controlDisables = {
disableMovement = disableControl.move ~= false,
disableCarMovement = disableControl.car ~= false,
disableMouse = disableControl.mouse ~= false,
disableCombat = disableControl.combat ~= false,
},
animation = animation and {
animDict = animation.dict,
anim = animation.clip,
flags = animation.flag
},
prop = prop and {
model = prop.model,
bone = prop.bone,
coords = prop.pos,
rotation = prop.rot
},
}, function(cancelled)
promise:resolve(not cancelled)
end)
local success = Citizen.Await(promise)
return success
end
function Progressbar.cancelProgress()
TriggerEvent("progressbar:client:cancel")
end
function Progressbar.isProgressActive()
return Progressbar.state
end
RegisterNetEvent('progressbar:setstatus', function (state)
Progressbar.state = state
end)
return Progressbar

View file

@ -0,0 +1,28 @@
local Radial = {}
function Radial.addOptions(optionId, data)
local id = require'utils'.await('UUID', false, 8)
local lib = exports.ox_lib
local title, icon, items in data
lib:registerRadial({
id = id,
items = items
})
lib:addRadialItem({
{
id = optionId,
label = title or 'Unknown',
icon = icon or 'hand',
menu = id
},
})
end
function Radial.removeOption(onExit)
end
return Radial

View file

@ -0,0 +1,74 @@
local menuName = 'qb-radialmenu'
if GetResourceState(menuName) ~= 'started' then
error(menuName..' isn\'t starting')
return
end
local qb_radial = exports[menuName]
local Radial = {}
local Utils = require 'utils'
local eventIndex = 0
local storedEvents = {}
local overRideData = {
title = {
originalMethod = 'label',
},
icon = {
originalMethod = 'icon',
},
id = {
originalMethod = 'menu',
},
shouldClose = {
originalMethod = 'keepOpen',
modifier = {
executeFunc = true,
effect = function(value)
return type(value) ~= 'boolean' and true or not value
end
}
},
event = {
originalMethod = 'onSelect',
modifier = {
executeFunc = true,
effect = function(value)
local eventName = ("bl_bridge:client:radialId%s"):format(eventIndex)
eventIndex+= 1
return {eventName = eventName, eventId = AddEventHandler(eventName, value)}
end
}
},
}
function Radial.addOptions(optionId, data)
local id = Utils.await('UUID', false, 8)
local title, icon, items in data
items = Utils.retreiveNumberIndexedData(items, overRideData)
for _,v in ipairs(items) do
v.type = 'client'
if v.event then
local eventName, eventId in v.event
local menuId = v.menu or #storedEvents+1
storedEvents[menuId] = eventId
v.menu = menuId
v.event = eventName
end
end
qb_radial:AddOption({
id = optionId,
title = title or 'Unknown',
icon = icon or 'hand',
items = items
}, id)
end
function Radial.removeOption(onExit)
end
return Radial

View file

@ -0,0 +1,177 @@
local target = exports.ox_target
local Target = {}
-- for options is exactly the same as https://overextended.dev/ox_target
-- Example
-- add up here
local funcs = {
{
name = "addBoxZone",
originalname = "addBoxZone",
args = function(data)
for _, value in ipairs(data.options) do
value.distance = value.distance or data.distance
end -- a simple adjust
return {
coords = data.coords,
size = data.size,
rotation = data.rotation,
debug = data.debug,
drawSprite = data.drawSprite,
options = data.options
}
end
},
{
name = "addLocalEntity",
originalname = "addLocalEntity",
args = function(data)
for _, value in ipairs(data.options) do
value.distance = value.distance or data.distance
end -- a simple adjust
return table.unpack({data.entity, data.options})
end
},
{
name = "addModel",
originalname = "addModel",
args = function(data)
return table.unpack({data.models, data.options})
end
},
{
name = "addCircleZone",
originalname = "addSphereZone",
args = function(data)
for _, value in ipairs(data.options) do
value.distance = value.distance or data.distance
end -- a simple adjust
return {
coords = data.coords,
radius = data.radius,
rotation = data.rotation,
debug = data.debug,
drawSprite = data.drawSprite,
options = data.options
}
end
},
{
name = "addEntity",
originalname = "addEntity",
args = function(data)
local options, distance, entity in data
for _, value in ipairs(options) do
value.distance = value.distance or distance
end -- a simple adjust
local entities = {}
for k,v in ipairs(type(entity) == 'table' and entity or {entity}) do
entities[k] = DoesEntityExist(v) and NetworkGetEntityIsNetworked(v) and NetworkGetNetworkIdFromEntity(v)
end
return table.unpack({entities, options})
end
},
{
name = "removeZone",
originalname = "removeZone",
args = function(data)
return data
end
},
{
name = "removeModel",
originalname = "removeModel",
args = function(data)
return table.unpack({data.models, data.names})
end
},
{
name = "removeLocalEntity",
originalname = "removeLocalEntity",
args = function(data)
return table.unpack({data.entity, data.names})
end
},
{
name = "removeEntity",
originalname = "removeEntity",
args = function(data)
local names, entity in data
local entities = {}
for k,v in ipairs(type(entity) == 'table' and entity or {entity}) do
entities[k] = DoesEntityExist(v) and NetworkGetEntityIsNetworked(v) and NetworkGetNetworkIdFromEntity(v)
end
return table.unpack({entities, names})
end
},
}
for _, exportData in ipairs(funcs) do
Target[exportData.name] = function(data)
local originalName = exportData.originalname or exportData.name
return target[originalName]("bruh", exportData.args(data)) -- already return id
end
end
-- for options is exactly the same as https://overextended.dev/ox_target
-- Example
--[[ local id = Target.addBoxZone({
coords = vector3(428, -973.44, 30.71),
size = vector3(2, 2, 2),
rotation = 90,
distance = 5.0,
debug = true,
options = {
{
label = "W",
icon = "fa-solid fa-scissors",
onSelect = function()
print("frist")
end
},
{
label = "Destroy",
icon = "fa-regular fa-eye",
onSelect = function()
print("second")
end
}
}
}
)
print(id)
Target.removeZone(id)
Target.addCircleZone({
coords = vector3(428, -973.44, 30.71),
radius = 2,
rotation = 90,
distance = 5.0,
debug = true,
options = {
{
label = "W",
icon = "fa-solid fa-scissors",
onSelect = function()
print("frist")
end
},
{
label = "Destroy",
icon = "fa-regular fa-eye",
onSelect = function()
print("second")
end
}
}
}
)
]]
return Target

View file

@ -0,0 +1,204 @@
local targetName = 'qb-target'
-- Check resource state
if GetResourceState(targetName) ~= 'started' then
error(targetName .. ' isn\'t started')
return
end
local target = exports[targetName]
local Utils = require'utils'
local retreiveNumberIndexedData = Utils.retreiveNumberIndexedData
local Target = {}
local OverrideData = {
label = { originalMethod = 'label' },
type = {
originalMethod = { 'event', 'serverEvent' },
modifier = {
executeFunc = true,
effect = function(value, originalMethod)
return originalMethod == 'event' and 'client' or originalMethod == 'serverEvent' and 'server'
end
}
},
event = {
originalMethod = { 'event', 'serverEvent' }
},
icon = {
originalMethod = 'icon',
},
targeticon = {
originalMethod = 'targeticon',
},
item = {
originalMethod = 'items'
},
action = {
originalMethod = 'onSelect',
},
canInteract = {
originalMethod = 'canInteract',
},
job = {
originalMethod = 'groups',
},
gang = {
originalMethod = 'groups',
}
}
-- alot of them have exclusive args
-- add up here
local funcs = {
{
name = "addBoxZone",
originalname = "AddBoxZone",
args = function(data, id)
local length, width = table.unpack(data.size)
return { id, data.coords, length, width, {
name = id,
heading = data.rotation,
debugPoly = data.debug,
} }
end
},
{
name = "addCircleZone",
originalname = "AddCircleZone",
args = function(data, id)
return { id, data.coords, data.radius, {
name = id,
heading = data.rotation,
debugPoly = data.debug,
} }
end
},
{
name = "addModel",
originalname = "AddTargetModel",
args = function(data)
return {data.models}
end
},
{
name = "addEntity",
originalname = "AddTargetEntity",
args = function(data)
return {data.entity}
end
},
{
name = "addLocalEntity",
originalname = "AddTargetEntity",
args = function(data)
return {data.entity}
end
},
{
name = "removeZone",
originalname = "RemoveZone",
args = function(data)
return data
end
},
{
name = "removeEntity",
originalname = "RemoveTargetEntity",
args = function(data)
return data
end
},
{
name = "removeLocalEntity",
originalname = "RemoveTargetEntity",
args = function(data)
return data
end
},
}
-- dynamic way of creating funcs for the target, i will make it global in the future
for _, exportData in ipairs(funcs) do
Target[exportData.name] = function(data)
local id = Utils.await('UUID', false, 8)
local originalName = exportData.originalname or exportData.name
local args = exportData.args(data, id)
if type(data) == "table" and type(data.options) == "table" then
if not data.options[1] then
data.options = { data.options }
end
args[#args + 1] = {
options = retreiveNumberIndexedData(data.options, OverrideData),
distance = data.distance
}
end
if type(args) == "table" then
target[originalName]("bruh", table.unpack(args))
else
target[originalName]("bruh", args)
end
return id
end
end
-- for options is exactly the same as https://overextended.dev/ox_target
-- Example
--[[ local id = Target.addBoxZone({
coords = vector3(428, -973.44, 30.71),
size = vector3(2, 2, 2),
rotation = 90,
distance = 5.0,
debug = true,
options = {
{
label = "W",
icon = "fa-solid fa-scissors",
onSelect = function()
print("frist")
end
},
{
label = "Destroy",
icon = "fa-regular fa-eye",
onSelect = function()
print("second")
end
}
}
}
)
local id2 = Target.addCircleZone({
coords = vector3(428, -973.44, 30.71),
radius = 2,
rotation = 90,
distance = 5.0,
debug = true,
options = {
{
label = "W",
icon = "fa-solid fa-scissors",
serverEvent = 'dwadaw',
},
{
label = "Destroy",
icon = "fa-regular fa-eye",
onSelect = function()
print("second")
end
}
}
}
)
]]
return Target

View file

@ -0,0 +1,23 @@
---@diagnostic disable: lowercase-global
local esx_textui = exports['esx_textui']
local open = false
local textui = {}
---@param text string
---@param position? TextUIOptions
function textui.showTextUI(text, position)
esx_textui:TextUI(text)
open = true
end
function textui.hideTextUI()
open = false
esx_textui:HideUI()
end
---@return boolean
function textui.isTextUIOpen()
return open
end
return textui

View file

@ -0,0 +1,19 @@
---@diagnostic disable: lowercase-global
local textui = {}
---@param text string
function textui.showTextUI(text, position)
exports.ox_lib:showTextUI(text, position and {position = ('%s-center'):format(position)})
end
function textui.hideTextUI()
exports.ox_lib:hideTextUI()
end
---@return boolean
function textui.isTextUIOpen()
return exports.ox_lib:isTextUIOpen()
end
return textui

View file

@ -0,0 +1,24 @@
---@diagnostic disable: lowercase-global
local textui_fw = 'qb-core'
local qb_textui = exports[textui_fw]
local open = false
local textui = {}
---@param text string
---@param position? TextUIOptions
function textui.showTextUI(text, position)
qb_textui:DrawText(text, position or 'right')
open = true
end
function textui.hideTextUI()
open = false
qb_textui:HideText()
end
---@return boolean
function textui.isTextUIOpen()
return open
end
return textui

View file

@ -0,0 +1,20 @@
fx_version "cerulean"
use_experimental_fxv2_oal 'yes'
lua54 'yes'
game 'gta5'
version '1.6.0'
dependencies {
'/onesync',
}
shared_scripts {
'require.lua',
'init.lua',
}
files {
'utils.lua',
'client/**/*.lua',
'imports/client.lua',
}

View file

@ -0,0 +1,8 @@
local bl_bridge = exports.bl_bridge
Framework = setmetatable({}, {
__index = function(self, index)
self[index] = bl_bridge[index]()
return self[index]
end
})

View file

@ -0,0 +1,8 @@
local bl_bridge = exports.bl_bridge
Framework = setmetatable({}, {
__index = function(self, index)
self[index] = bl_bridge[index]()
return self[index]
end
})

View file

@ -0,0 +1,159 @@
local DEFAULT_FRAMEWORK = 'ox'
Framework = setmetatable({}, {
__newindex = function(self, name, fn)
exports(name, function() return fn end)
rawset(self, name, fn)
end
})
local context = IsDuplicityVersion() and 'server' or 'client'
local requireLua = require -- when importing ox_core chunk, this gets overrides by ox_lib require, which loses stored data
local Utils = requireLua'utils'
local function format(str)
if not string.find(str, "'") then return str end
return str:gsub("'", "")
end
Config = {
convars = {
core = format(GetConvar('bl:framework', DEFAULT_FRAMEWORK)),
inventory = format(GetConvar('bl:inventory', DEFAULT_FRAMEWORK)),
context = format(GetConvar('bl:context', DEFAULT_FRAMEWORK)),
target = format(GetConvar('bl:target', DEFAULT_FRAMEWORK)),
progressbar = format(GetConvar('bl:progressbar', DEFAULT_FRAMEWORK)),
radial = format(GetConvar('bl:radial', DEFAULT_FRAMEWORK)),
notify = format(GetConvar('bl:notify', DEFAULT_FRAMEWORK)),
textui = format(GetConvar('bl:textui', DEFAULT_FRAMEWORK)),
},
resources = {
inventory = {
ox = 'ox_inventory',
qb = 'qb-inventory',
ps = 'ps-inventory',
esx = 'es_extended',
origen = 'origen_inventory',
qs = 'qs-inventory'
},
core = {
nd = 'ND_Core',
qb = 'qb-core',
ox = 'ox_core',
qbx = 'qbx_core',
esx = 'es_extended'
},
context = {
qb = 'qb-menu',
ox = 'ox_lib'
},
progressbar = {
qb = 'progressbar',
ox = 'ox_lib'
},
radial = {
qb = 'qb-radialmenu',
ox = 'ox_lib'
},
target = {
qb = 'qb-target',
ox = 'ox_target',
},
notify = {
qb = 'none',
ox = 'ox_lib',
esx = 'none',
},
textui = {
ox = 'ox_lib',
qb = 'none',
esx = 'esx_textui',
}
},
client = {
dir = 'client',
moduleNames = {
"core",
"context",
"target",
"radial",
"notify",
"inventory",
"progressbar",
'textui',
},
all = {
inventory = true
},
},
server = {
dir = 'server',
moduleNames = {
"inventory",
"core",
"notify",
},
alternative = {
inventory = {
ps = 'qb'
}
},
}
}
---@param module string Module name
---@return string?
function GetFramework(module)
local moduleConfig = Config.resources[module]
if not moduleConfig then return end
return moduleConfig[Config.convars[module]]
end
exports('getFramework', GetFramework)
local function loadModule(dir, moduleName, framework, prefix)
local fomartedModule = ("%s.%s.%s"):format(dir, moduleName, framework)
local success, module = pcall(requireLua, fomartedModule)
if type(module) ~= "string" or not string.find(module, 'not found') then
if success then
Framework[moduleName] = module
print(("[%s] Loaded module %s"):format(prefix, moduleName))
else
error(("Error loading module %s: %s"):format(moduleName, module))
end
end
end
local modulesConfig = Config[context]
if context == 'server' then
Utils.register('UUID', function(_, num)
return Utils.UUID(num)
end)
end
for _, moduleName in ipairs(modulesConfig.moduleNames) do
local framework = Config.convars[moduleName]
if framework ~= 'none' then
local hasAlternative = modulesConfig.alternative and modulesConfig.alternative[moduleName]
local moduleForAll = modulesConfig.all and modulesConfig.all[moduleName] and 'all' or framework
local alternative = hasAlternative and hasAlternative[moduleForAll] or moduleForAll
local resourceName = Config.resources[moduleName] and Config.resources[moduleName][framework]
if not resourceName then
return error('there is no '..framework.. ' on module '..moduleName.. '!, please make sure you configured your convars on cfg!')
elseif resourceName == 'none' or GetResourceState(resourceName) == 'started' then
loadModule(modulesConfig.dir, moduleName, alternative, framework)
else
ExecuteCommand('ensure '..resourceName)
if Utils.waitFor(function()
if GetResourceState(resourceName) == 'started' then
return true
end
end, ('resource %s is not starting'):format(resourceName), 2000) then
loadModule(modulesConfig.dir, moduleName, alternative, framework)
end
end
end
end

View file

@ -0,0 +1,147 @@
--https://github.com/overextended/ox_lib/blob/master/imports/table/shared.lua
local loaded = {}
local _require = require
package = {
path = './?.lua;./?/init.lua',
preload = {},
loaded = setmetatable({}, {
__index = loaded,
__newindex = noop,
__metatable = false,
})
}
---@param modName string
---@return string
---@return string
local function getModuleInfo(modName)
local resource = modName:match('^@(.-)/.+') --[[@as string?]]
if resource then
return resource, modName:sub(#resource + 3)
end
local idx = 4 -- call stack depth (kept slightly lower than expected depth "just in case")
while true do
local src = debug.getinfo(idx, 'S')?.source
if not src then
return cache.resource, modName
end
resource = src:match('^@@([^/]+)/.+')
if resource and not src:find('^@@ox_lib/imports/require') then
return resource, modName
end
idx += 1
end
end
local tempData = {}
---@param name string
---@param path string
---@return string? filename
---@return string? errmsg
---@diagnostic disable-next-line: duplicate-set-field
function package.searchpath(name, path)
local resource, modName = getModuleInfo(name:gsub('%.', '/'))
local tried = {}
for template in path:gmatch('[^;]+') do
local fileName = template:gsub('^%./', ''):gsub('?', modName:gsub('%.', '/') or modName)
local file = LoadResourceFile(resource, fileName)
if file then
tempData[1] = file
tempData[2] = resource
return fileName
end
tried[#tried + 1] = ("no file '@%s/%s'"):format(resource, fileName)
end
return nil, table.concat(tried, "\n\t")
end
---Attempts to load a module at the given path relative to the resource root directory.\
---Returns a function to load the module chunk, or a string containing all tested paths.
---@param modName string
---@param env? table
local function loadModule(modName, env)
local fileName, err = package.searchpath(modName, package.path)
if fileName then
local file = tempData[1]
local resource = tempData[2]
table.wipe(tempData)
return assert(load(file, ('@@%s/%s'):format(resource, fileName), 't', env or _ENV))
end
return nil, err or 'unknown error'
end
---@alias PackageSearcher
---| fun(modName: string): function loader
---| fun(modName: string): nil, string errmsg
---@type PackageSearcher[]
package.searchers = {
function(modName)
local ok, result = pcall(_require, modName)
if ok then return result end
return ok, result
end,
function(modName)
if package.preload[modName] ~= nil then
return package.preload[modName]
end
return nil, ("no field package.preload['%s']"):format(modName)
end,
function(modName) return loadModule(modName) end,
}
---Loads the given module, returns any value returned by the seacher (`true` when `nil`).\
---Passing `@resourceName.modName` loads a module from a remote resource.
---@param modName string
---@return unknown
function require(modName)
if type(modName) ~= 'string' then
error(("module name must be a string (received '%s')"):format(modName), 3)
end
local module = loaded[modName]
if module == '__loading' then
error(("^1circular-dependency occurred when loading module '%s'^0"):format(modName), 2)
end
if module ~= nil then return module end
loaded[modName] = '__loading'
local err = {}
for i = 1, #package.searchers do
local result, errMsg = package.searchers[i](modName)
if result then
if type(result) == 'function' then result = result() end
loaded[modName] = result or result == nil
return loaded[modName]
end
err[#err + 1] = errMsg
end
error(("%s"):format(table.concat(err, "\n\t")))
end

View file

@ -0,0 +1,139 @@
local Core = {}
local shared = exports["es_extended"]:getSharedObject()
local Utils = require 'utils'
local merge = Utils.table_merge
RegisterNetEvent('esx:playerLoaded', function(...)
TriggerEvent('bl_bridge:server:playerLoaded', source, ...)
end)
AddEventHandler("esx:playerLoaded", function(playerId, xPlayer)
TriggerEvent('bl_bridge:server:playerLoaded', playerId, xPlayer)
end)
AddEventHandler('esx:setAccountMoney', function(player, accountName, money)
TriggerEvent('bl_bridge:server:updateMoney', player, accountName == 'money' and 'cash' or accountName, money, 'set')
end)
AddEventHandler('esx:removeAccountMoney', function(source, accountName, money)
TriggerEvent('bl_bridge:server:updateMoney', source, accountName == 'money' and 'cash' or accountName, money, 'remove')
end)
AddEventHandler('esx:addAccountMoney', function(source, accountName, money)
TriggerEvent('bl_bridge:server:updateMoney', source, accountName == 'money' and 'cash' or accountName, money, 'add')
end)
local inventoryFunctions = Framework.inventory
local coreFunctionsOverride = {
getBalance = {
originalMethod = 'getAccount',
modifier = {
effect = function(originalFun, type)
return originalFun(type == 'cash' and 'money' or type).money
end
}
},
removeBalance = {
originalMethod = 'removeAccountMoney',
modifier = {
effect = function(originalFun, type, amount)
return originalFun(type == 'cash' and 'money' or type, amount)
end
}
},
setBalance = {
originalMethod = 'setAccountMoney',
modifier = {
effect = function(originalFun, type, amount)
return originalFun(type == 'cash' and 'money' or type, amount)
end
}
},
addBalance = {
originalMethod = 'addAccountMoney',
modifier = {
effect = function(originalFun, type, amount)
return originalFun(type == 'cash' and 'money' or type, amount)
end
}
},
setJob = {
originalMethod = 'setJob',
},
job = {
originalMethod = 'getJob',
modifier = {
executeFunc = true,
effect = function(data)
local job = data()
return {name = job.name, label = job.label, onDuty = true, isBoss = false, grade = {name = job.grade, label = job.grade_label, salary = job.grade_salary}}
end
}
},
charinfo = {
originalMethod = 'variables',
modifier = {
executeFunc = true,
effect = function(data)
return {firstname = data.firstName, lastname = data.lastName}
end
}
},
name = {
originalMethod = 'getName',
modifier = {
executeFunc = true,
}
},
id = {
originalMethod = 'identifier',
modifier = {
executeFunc = true,
effect = function(str)
return str
end
}
},
gender = {
originalMethod = 'variables',
modifier = {
executeFunc = true,
effect = function(data)
return data.sex == 'm' and 'male' or 'female'
end
}
},
dob = {
originalMethod = 'variables',
modifier = {
executeFunc = true,
effect = function(data)
local dob = data.dateofbirth
if type(dob) ~= 'string' then return end
local month, day, year = dob:match("(%d+)/(%d+)/(%d+)")
return ('%s/%s/%s'):format(month, day, year)
end
}
},
}
local totalFunctionsOverride = inventoryFunctions and merge(inventoryFunctions.methods, coreFunctionsOverride) or coreFunctionsOverride
function Core.CommandAdd(name, permission, cb, suggestion, flags)
shared.RegisterCommand(name, permission, cb, flags.allowConsole, suggestion)
end
Core.RegisterUsableItem = inventoryFunctions?.registerUsableItem or function(name, cb)
shared.RegisterUsableItem(name, cb)
end
function Core.GetPlayer(src)
local player = shared.GetPlayerFromId(src)
if not player then return end
local wrappedPlayer = Utils.retreiveStringIndexedData(player, totalFunctionsOverride, src)
return wrappedPlayer
end
Core.Players = shared.Players
return Core

View file

@ -0,0 +1,134 @@
local Core = {}
local shared = exports.ND_Core
local Utils = require 'utils'
local retreiveStringIndexedData = Utils.retreiveStringIndexedData
local merge = Utils.table_merge
local inventoryFunctions = Framework.inventory
AddEventHandler("ND:characterLoaded", function(character)
TriggerEvent('bl_bridge:server:playerLoaded', character.source, character)
end)
AddEventHandler("ND:moneyChange", function(source, account, amount, action, reason)
TriggerEvent('bl_bridge:server:updateMoney', source, account, amount, action)
end)
local playerFunctionsOverride = {
getBalance = {
originalMethod = 'getData',
modifier = {
executeFunc = true,
effect = function(data, type)
local balance = data(type)
return balance
end
}
},
removeBalance = {
originalMethod = 'deductMoney',
},
addBalance = {
originalMethod = 'addMoney',
},
setBalance = {
originalMethod = 'setMetadata',
modifier = {
effect = function(originalFun, type, amount)
return originalFun(type, amount)
end
}
},
setJob = {
originalMethod = 'setJob',
},
job = {
originalMethod = 'getJob',
modifier = {
executeFunc = true,
effect = function(originalFun)
local _, jobInfo = originalFun()
return {name = jobInfo.name, label = jobInfo.label, onDuty = jobInfo.isJob, isBoss = true, grade = {name = jobInfo.rank, label = jobInfo.rankName, salary = 0}}
end
}
},
charinfo = {
originalMethod = 'getData',
modifier = {
executeFunc = true,
effect = function(data)
return {firstname = data('firstname'), lastname = data('lastname')}
end
}
},
name = {
originalMethod = 'getData',
modifier = {
executeFunc = true,
effect = function(data)
return data('fullname')
end
}
},
id = {
originalMethod = 'getData',
modifier = {
executeFunc = true,
effect = function(data)
return data('id')
end
}
},
gender = {
originalMethod = 'getData',
modifier = {
executeFunc = true,
effect = function(data)
return string.lower(data('gender'))
end
}
},
dob = {
originalMethod = 'getData',
modifier = {
executeFunc = true,
effect = function(data)
local year, month, day = data('dob'):match("(%d+)-(%d+)-(%d+)")
return ('%s/%s/%s'):format(month, day, year) -- DD/MM/YYYY
end
}
},
}
function Core.players()
local data = {}
for k, v in ipairs(shared.getPlayers()) do
local jobInfo = v.jobInfo
data[k] = {
job = {name = jobInfo.name, label = jobInfo.label, onDuty = jobInfo.isJob, isBoss = true, grade = {name = jobInfo.rank, label = jobInfo.rankName, salary = 0}},
charinfo = { firstname = v.firstname, lastname = v.lastname }
}
end
return data
end
function Core.CommandAdd(name, permission, cb, suggestion, flags)
RegisterCommand(name, cb, permission)
end
Core.RegisterUsableItem = inventoryFunctions?.registerUsableItem
local totalFunctionsOverride = inventoryFunctions and merge(inventoryFunctions.methods, playerFunctionsOverride) or playerFunctionsOverride
function Core.GetPlayer(src)
local player = shared:getPlayer(src)
if not player then return end
local wrappedPlayer = retreiveStringIndexedData(player, totalFunctionsOverride, src)
return wrappedPlayer
end
function Core.hasPerms(...)
return false
end
return Core

View file

@ -0,0 +1,243 @@
assert(GetFramework('inventory') == 'ox_inventory', 'Needs ox_inventory')
local Core = {}
local Utils = require 'utils'
local Ox = require '@ox_core/lib/init'
local retreiveStringIndexedData = Utils.retreiveStringIndexedData
local merge = Utils.table_merge
local inventoryFunctions = Framework.inventory
local ox_inv = exports.ox_inventory
AddEventHandler('ox:playerLoaded', function(playerId, ...)
TriggerEvent('bl_bridge:server:playerLoaded', playerId, ...) -- TODO: sync event data across other framworks
end)
AddEventHandler('ox:playerLogout', function(playerId, ...)
TriggerEvent('bl_bridge:client:playerUnloaded', playerId, ...) -- TODO: sync event data across other framworks
end)
ox_inv:registerHook('swapItems', function(payload)
local toInv = payload.toInventory
local fromInv = payload.fromInventory
if toInv == fromInv then return end -- swap in same inv, means the amount will stay the same
local count = payload.count
if type(toInv) == 'number' and payload.toType == 'player' then
TriggerEvent('bl_bridge:server:updateMoney', toInv, 'cash', count, 'add')
end
if type(fromInv) == 'number' and payload.fromType == 'player' then
TriggerEvent('bl_bridge:server:updateMoney', fromInv, 'cash', count, 'remove')
end
return true
end, {
itemFilter = {
money = true,
},
})
ox_inv:registerHook('createItem', function(payload)
if type(payload.inventoryId) ~= 'number' then return end
TriggerEvent('bl_bridge:server:updateMoney', payload.inventoryId, 'cash', payload.count, 'add')
return true
end, {
itemFilter = {
money = true,
},
})
local group = {
originalMethod = 'get',
modifier = {
passSource = true,
executeFunc = true,
effect = function(get, source)
local activeGroup = get('activeGroup')
if not activeGroup then return end
local job = Ox.GetGroup(activeGroup)
if type(job) ~= 'table' then return end
local grade = Ox.GetPlayer(source).getGroup(activeGroup)
return {name = job.name, label = job.label, onDuty = true, isBoss = job.accountRoles[tostring(grade)] == 'owner', type = job.type, grade = { name = grade, label = job.grades[grade], salary = 0 } }
end
}
}
local playerFunctionsOverride = {
getBalance = {
originalMethod = 'getAccount',
modifier = {
passSource = true,
---@param getAccount function OxAccount
---@param source number
---@param moneyType MoneyType
effect = function(getAccount, source, moneyType)
return moneyType == 'cash' and ox_inv:GetItemCount(source, 'money') or (getAccount()?.get('balance') or 0)
end,
}
},
removeBalance = {
originalMethod = 'getAccount',
modifier = {
passSource = true,
---@param getAccount function OxAccount
---@param source number
---@param moneyType MoneyType
---@param amount number
effect = function(getAccount, source, moneyType, amount)
if moneyType == 'bank' then
getAccount()?.removeBalance({
amount = amount
})
else
ox_inv:RemoveItem(source, 'money', amount)
end
end,
}
},
addBalance = {
originalMethod = 'getAccount',
modifier = {
passSource = true,
---@param getAccount function OxAccount
---@param source number
---@param moneyType MoneyType
---@param amount number
effect = function(getAccount, source, moneyType, amount)
if moneyType == 'bank' then
getAccount()?.addBalance({
amount = amount
})
else
ox_inv:AddItem(source, 'money', amount)
end
end,
}
},
setBalance = {
originalMethod = 'getAccount',
modifier = {
passSource = true,
---@param getAccount function OxAccount
---@param source number
---@param moneyType MoneyType
---@param amount number|string
effect = function(getAccount, source, moneyType, amount)
---@diagnostic disable-next-line: cast-local-type
amount = tonumber(amount)
if not amount then return end
local currentAmount = moneyType == 'cash' and ox_inv:GetItemCount(source, 'money') or (getAccount()?.get('balance') or 0)
if currentAmount == amount then return end
if currentAmount > amount then
if moneyType == 'cash' then
ox_inv:RemoveItem(source, 'money', currentAmount - amount)
else
getAccount()?.removeBalance({
amount = amount
})
end
else
if moneyType == 'cash' then
ox_inv:AddItem(source, 'money', amount - currentAmount)
else
getAccount()?.addBalance({
amount = amount
})
end
end
end
}
},
setJob = {
originalMethod = 'setGroup',
modifier = {
passSource = true,
---@param setGroup function
---@param source number
---@param job string
---@param grade number
effect = function(setGroup, source, job, grade)
setGroup(job, grade)
Ox.GetPlayer(source).setActiveGroup(job)
end
}
},
job = group, -- future TODO: make job and gang as groups
gang = group,
charinfo = {
originalMethod = 'get',
modifier = {
---@param get function
---@return CharInfo
effect = function(get)
return { firstname = get('firstName'), lastname = get('lastName') }
end
}
},
name = {
originalMethod = 'get',
modifier = {
---@param get function
---@return string --fullname
effect = function(get)
return ('%s %s'):format(get('firstName'), get('lastName'))
end
}
},
id = {
originalMethod = 'charId',
},
gender = {
originalMethod = 'get',
modifier = {
---@param get function
---@return string --gender
effect = function(get)
return get('gender')
end
}
},
dob = {
originalMethod = 'get',
modifier = {
---@param get function
---@return string --DD/MM/YYYY
effect = function(get)
return get('dateOfBirth')
end
}
},
}
function Core.players()
return Ox.Players
end
function Core.CommandAdd(name, permission, cb, suggestion, flags)
print('?') -- todo
end
Core.RegisterUsableItem = inventoryFunctions?.registerUsableItem or function()
print('how dare you use ox_core without ox_inventory? get a brain!')
end
local totalFunctionsOverride = inventoryFunctions and merge(inventoryFunctions.methods, playerFunctionsOverride) or
playerFunctionsOverride
function Core.GetPlayer(src)
local player = Ox.GetPlayer(src)
if not player then return end
return retreiveStringIndexedData(player, totalFunctionsOverride, src)
end
function Core.hasPerms(...)
return Ox.Functions.HasPermission(...)
end
return Core

View file

@ -0,0 +1,151 @@
local Core = {}
local shared = exports['qb-core']:GetCoreObject()
local Utils = require 'utils'
local retreiveStringIndexedData = Utils.retreiveStringIndexedData
local merge = Utils.table_merge
local inventoryFunctions = Framework.inventory
RegisterNetEvent('QBCore:Server:OnPlayerLoaded', function(...)
TriggerEvent('bl_bridge:server:playerLoaded', source, ...)
end)
AddEventHandler('QBCore:Server:OnMoneyChange', function(src, moneyType, amount, operation, reason)
TriggerEvent('bl_bridge:server:updateMoney', src, moneyType, amount, operation)
end)
local playerFunctionsOverride = {
Functions = {
getBalance = {
originalMethod = 'GetMoney',
},
removeBalance = {
originalMethod = 'RemoveMoney',
},
addBalance = {
originalMethod = 'AddMoney',
},
setBalance = {
originalMethod = 'SetMoney',
},
setJob = {
originalMethod = 'SetJob',
},
},
PlayerData = {
job = {
originalMethod = 'job',
modifier = {
executeFunc = true,
---@param data table
---@return GroupData
effect = function(data)
local job = data
return {name = job.name, label = job.label, onDuty = job.onduty, isBoss = job.isboss, type = job.type, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } }
end
}
},
gang = {
originalMethod = 'gang',
modifier = {
executeFunc = true,
---@param data table
---@return GroupData
effect = function(data)
local gang = data
return {name = gang.name, label = gang.label, isBoss = gang.isboss, grade = {name = gang.grade.level, label = gang.grade.label}}
end
}
},
charinfo = {
originalMethod = 'charinfo',
modifier = {
executeFunc = true,
---@param data table
---@return CharInfo
effect = function(data)
return {firstname = data.firstname, lastname = data.lastname}
end
}
},
name = {
originalMethod = 'name',
},
id = {
originalMethod = 'citizenid',
},
gender = {
originalMethod = 'charinfo',
modifier = {
executeFunc = true,
---@param data {gender: number}
---@return string
effect = function(data)
local gender = data.gender
gender = gender == 1 and 'female' or 'male'
return gender
end
}
},
dob = {
originalMethod = 'charinfo',
modifier = {
executeFunc = true,
---@param data {birthdate: string}
---@return string
effect = function(data)
local year, month, day = data.birthdate:match("(%d+)-(%d+)-(%d+)")
return ('%s/%s/%s'):format(month, day, year) -- DD/MM/YYYY
end
}
},
items = {
originalMethod = 'items',
},
}
}
function Core.players()
local data = {}
for k,v in ipairs(shared.Players) do
local playerData = v.PlayerData
local job = playerData.job
local gang = playerData.gang
local charinfo = playerData.charinfo
data[k] = {
job = {name = job.name, label = job.label, onDuty = job.onduty, type = job.type, isBoss = job.isboss, grade = {name = job.grade.level, label = job.grade.name, salary = job.payment}},
gang = {name = gang.name, label = gang.label, isBoss = gang.isboss, grade = {name = gang.grade.level, label = gang.grade.label}},
charinfo = {firstname = charinfo.firstname, lastname = charinfo.lastname}
}
end
return data
end
function Core.CommandAdd(name, permission, cb, suggestion, flags)
if type(name) == 'table' then
for _,command in ipairs(name) do
shared.Commands.Add(command, suggestion.help, suggestion.arguments, flags.argsrequired, cb, permission)
end
return
end
shared.Commands.Add(name, suggestion.help, suggestion.arguments, flags.argsrequired, cb, permission)
end
Core.RegisterUsableItem = inventoryFunctions and inventoryFunctions.registerUsableItem or function(name, cb)
shared.Functions.CreateUseableItem(name, function(source, item)
cb(source, item and item.slot, item and item.info)
end)
end
local totalFunctionsOverride = inventoryFunctions and merge(inventoryFunctions.methods, playerFunctionsOverride) or playerFunctionsOverride
function Core.GetPlayer(src)
local player = shared.Functions.GetPlayer(src)
if not player then return end
return retreiveStringIndexedData(player, totalFunctionsOverride, src)
end
function Core.hasPerms(...)
return shared.Functions.HasPermission(...)
end
return Core

View file

@ -0,0 +1,134 @@
local Core = {}
local Utils = require 'utils'
local retreiveStringIndexedData = Utils.retreiveStringIndexedData
local merge = Utils.table_merge
local inventoryFunctions = Framework.inventory
RegisterNetEvent('QBCore:Server:OnPlayerLoaded', function(...)
TriggerEvent('bl_bridge:server:playerLoaded', source, ...)
end)
AddEventHandler('QBCore:Server:OnMoneyChange', function(src, moneyType, amount, operation, reason)
TriggerEvent('bl_bridge:server:updateMoney', src, moneyType, amount, operation)
end)
local playerFunctionsOverride = {
Functions = {
getBalance = {
originalMethod = 'GetMoney',
},
removeBalance = {
originalMethod = 'RemoveMoney',
},
addBalance = {
originalMethod = 'AddMoney',
},
setBalance = {
originalMethod = 'SetMoney',
},
setJob = {
originalMethod = 'SetJob',
},
},
PlayerData = {
job = {
originalMethod = 'job',
modifier = {
executeFunc = true,
effect = function(originalFun)
local job = originalFun
return {name = job.name, label = job.label, onDuty = job.onduty, isBoss = job.isboss, type = job.type, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } }
end
}
},
gang = {
originalMethod = 'gang',
modifier = {
executeFunc = true,
effect = function(data)
local gang = data
return {name = gang.name, label = gang.label, isBoss = gang.isboss, grade = {name = gang.grade.level, label = gang.grade.label}}
end
}
},
charinfo = {
originalMethod = 'charinfo',
modifier = {
executeFunc = true,
effect = function(data)
return {firstname = data.firstname, lastname = data.lastname}
end
}
},
name = {
originalMethod = 'name',
},
id = {
originalMethod = 'citizenid',
},
gender = {
originalMethod = 'charinfo',
modifier = {
executeFunc = true,
effect = function(data)
local gender = data.gender
gender = gender == 1 and 'female' or 'male'
return gender
end
}
},
dob = {
originalMethod = 'charinfo',
modifier = {
executeFunc = true,
effect = function(data)
local year, month, day = data.birthdate:match("(%d+)-(%d+)-(%d+)")
return ('%s/%s/%s'):format(month, day, year) -- DD/MM/YYYY
end
}
},
items = {
originalMethod = 'items',
},
}
}
function Core.players()
local data = {}
for k,v in ipairs(exports.qbx_core:GetQBPlayers()) do
local playerData = v.PlayerData
local job = playerData.job
local gang = playerData.gang
local charinfo = playerData.charinfo
data[k] = {
job = {name = job.name, label = job.label, onDuty = job.onduty, type = job.type, isBoss = job.isboss, grade = {name = job.grade.level, label = job.grade.name, salary = job.payment}},
gang = {name = gang.name, label = gang.label, isBoss = gang.isboss, grade = {name = gang.grade.level, label = gang.grade.label}},
charinfo = {firstname = charinfo.firstname, lastname = charinfo.lastname}
}
end
return data
end
function Core.CommandAdd(name, permission, cb, suggestion, flags)
RegisterCommand(name, cb, permission)
end
Core.RegisterUsableItem = inventoryFunctions?.registerUsableItem or function(name, cb)
exports.qbx_core:CreateUseableItem(name, function(source, item)
cb(source, item and item.slot, item and item.info)
end)
end
local totalFunctionsOverride = inventoryFunctions and merge(inventoryFunctions.methods, playerFunctionsOverride) or playerFunctionsOverride
function Core.GetPlayer(src)
local player = exports.qbx_core:GetPlayer(src)
if not player then return end
return retreiveStringIndexedData(player, totalFunctionsOverride, src)
end
function Core.hasPerms(...)
return exports.qbx_core:HasPermission(...)
end
return Core

View file

@ -0,0 +1,29 @@
local overrideFunction = {}
overrideFunction.methods = {
addItem = {
originalMethod = 'addInventoryItem',
},
removeItem = {
originalMethod = 'removeInventoryItem',
},
getItem = {
originalMethod = 'getInventoryItem',
},
setMetaData = { -- not exist :()
},
canCarryItem = {
originalMethod = 'canCarryItem',
},
items = {
originalMethod = 'getInventory',
modifier = {
effect = function(originalFun)
return originalFun.items
end
}
},
}
return overrideFunction

View file

@ -0,0 +1,67 @@
local retreiveExportsData = require 'utils'.retreiveExportsData
local overrideFunction = {}
local origen_inventory = exports.origen_inventory
overrideFunction.methods = retreiveExportsData(origen_inventory, {
addItem = {
originalMethod = 'addItem',
modifier = {
passSource = true,
}
},
removeItem = {
originalMethod = 'removeItem',
modifier = {
passSource = true,
effect = function(originalFun, source, name, count, slot)
return originalFun(source, name, count, nil, slot)
end,
}
},
setMetaData = {
originalMethod = 'setMetadata',
modifier = {
passSource = true,
}
},
canCarryItem = {
originalMethod = 'canCarryItem',
modifier = {
passSource = true,
}
},
getItem = {
originalMethod = 'getItem',
modifier = {
passSource = true,
}
},
items = {
originalMethod = 'getItems',
modifier = {
executeFunc = true,
passSource = true,
}
},
})
function overrideFunction.registerUsableItem(name, cb)
exports.origen_inventory:CreateUseableItem(name, function(source, item)
cb(source, item and item.slot, item and item.info)
end)
end
function overrideFunction.registerInventory(id, data)
local type, name, items in data
if type == 'shop' and origen_inventory.registerShop then
origen_inventory:registerShop(id, {
name = name or 'Shop',
inventory = items or {},
})
elseif type == 'stash' then
local maxWeight, slots in data
origen_inventory:registerStash(id, name or 'Stash', slots or 10, maxWeight or 20000)
end
end
return overrideFunction

View file

@ -0,0 +1,73 @@
local retreiveExportsData = require 'utils'.retreiveExportsData
local overrideFunction = {}
local ox_inventory = exports.ox_inventory
overrideFunction.methods = retreiveExportsData(ox_inventory, {
addItem = {
originalMethod = 'AddItem',
modifier = {
passSource = true,
}
},
removeItem = {
originalMethod = 'RemoveItem',
modifier = {
passSource = true,
effect = function(originalFun, source, name, count, slot)
return originalFun(source, name, count, nil, slot)
end,
}
},
setMetaData = {
originalMethod = 'SetMetadata',
modifier = {
passSource = true,
}
},
canCarryItem = {
originalMethod = 'CanCarryItem',
modifier = {
passSource = true,
}
},
getItem = {
originalMethod = 'GetSlotWithItem',
modifier = {
passSource = true,
}
},
items = {
originalMethod = 'GetInventoryItems',
modifier = {
executeFunc = true,
passSource = true,
}
},
})
local registeredItems = {}
AddEventHandler('ox_inventory:usedItem', function(playerId, itemName, slotId, metadata)
local itemEffect = registeredItems[itemName]
if not itemEffect then return end
itemEffect(playerId, slotId, metadata)
end)
function overrideFunction.registerUsableItem(name, cb)
registeredItems[name] = cb
end
function overrideFunction.registerInventory(id, data)
local type, name, items in data
if type == 'shop' then
ox_inventory:RegisterShop(id, {
name = name or 'Shop',
inventory = items or {},
})
elseif type == 'stash' then
local maxWeight, slots in data
ox_inventory:RegisterStash(id, name or 'Stash', slots or 10, maxWeight or 20000)
end
end
return overrideFunction

View file

@ -0,0 +1,118 @@
local utils = require 'utils'
local retreiveExportsData = utils.retreiveExportsData
local overrideFunction = {}
local registeredInventories = {}
local inventoryName = GetFramework('inventory')
local inventory = exports[inventoryName]
overrideFunction.methods = retreiveExportsData(inventory, {
addItem = {
originalMethod = 'AddItem',
modifier = {
passSource = true,
effect = function(originalFun, src, name, amount, metadata, slot)
TriggerClientEvent('inventory:client:ItemBox', src, name, "add", amount)
TriggerClientEvent('qb-inventory:client:ItemBox', src, name, "add", amount)
return originalFun(src, name, amount, slot, metadata)
end
}
},
removeItem = {
originalMethod = 'RemoveItem',
modifier = {
passSource = true,
effect = function(originalFun, src, name, amount, slot)
TriggerClientEvent('inventory:client:ItemBox', src, name, "remove", amount)
TriggerClientEvent('qb-inventory:client:ItemBox', src, name, "remove", amount)
return originalFun(src, name, amount, slot)
end
}
},
setMetaData = {
originalMethod = 'SetItemData',
modifier = {
passSource = true,
effect = function(originalFun, src, slot, data)
local item = inventory:GetItemBySlot(src, slot)
if not item then return end
if type(data) ~= 'table' then return end
originalFun(src, item.name, 'info', data)
end
}
},
canCarryItem = {
originalMethod = inventoryName == 'qb-inventory' and inventory.CanAddItem and 'CanAddItem' or 'HasItem',
modifier = {
passSource = true,
}
},
getItem = {
originalMethod = 'GetItemByName',
modifier = {
passSource = true,
effect = function(originalFun, src, itemName)
local data = originalFun(src, itemName)
if not data then
return false, 'Item not exist or you don\'t have it'
end
return {
label = data.label,
name = data.name,
weight = data.weight,
slot = data.slot,
close = data.shouldClose,
stack = not data.unique,
metadata = data.info ~= '' and data.info or {},
count = data.amount or 1
}
end
}
},
})
function overrideFunction.registerInventory(id, data)
local type, name, items, slots, maxWeight in data
for k,v in ipairs(items or {}) do
v.amount = v.amount or 1
v.slot = k
end
registeredInventories[('%s-%s'):format(type, id)] = {
label = name,
items = items,
slots = slots or #items,
maxweight = maxWeight
}
if type == 'shop' and inventory.CreateShop then
inventory:CreateShop({
name = name,
label = name,
slots = slots or #items,
items = items
})
end
end
utils.register('bl_bridge:validInventory', function(src, invType, invId)
local inventoryData = registeredInventories[('%s-%s'):format(invType, invId)]
if not inventoryData then return end
local isShop = invType == 'shop'
if isShop and inventory.OpenShop then
return inventory:OpenShop(src, inventoryData.label)
elseif not isShop and inventory.OpenInventory then
return inventory:OpenInventory(src, inventoryData.label, {
label = inventoryData.label,
slots = inventoryData.slots,
maxweight = inventoryData.maxweight,
})
end
return inventoryData
end)
return overrideFunction

View file

@ -0,0 +1,93 @@
local utils = require 'utils'
local retreiveExportsData = utils.retreiveExportsData
local overrideFunction = {}
local registeredInventories = {}
local qs_inventory = exports['qs-inventory']
overrideFunction.methods = retreiveExportsData(qs_inventory, {
addItem = {
originalMethod = 'AddItem',
modifier = {
passSource = true,
effect = function(originalFun, src, name, amount, metadata, slot)
return originalFun(src, name, amount, slot, metadata)
end
}
},
removeItem = {
originalMethod = 'RemoveItem',
modifier = {
passSource = true,
}
},
setMetaData = {
originalMethod = 'SetItemMetadata',
modifier = {
passSource = true,
}
},
canCarryItem = {
originalMethod = 'CanCarryItem',
modifier = {
passSource = true,
}
},
getItem = {
originalMethod = 'GetItemByName',
modifier = {
passSource = true, -- Src doesn't actually seem to be passed to originalFunc
effect = function(originalFunc, src, itemName)
local data = originalFunc(src, itemName)
if not data then
return false, 'Item does not exist or you don\'t have it'
end
return {
label = data.label,
name = data.name,
weight = data.weight,
slot = data.slot,
close = data.shouldClose,
stack = not data.unique,
metadata = data.info ~= '' and data.info or {},
count = data.amount or 1
}
end
}
},
items = {
originalMethod = 'GetInventory',
modifier = {
passSource = true,
}
},
})
function overrideFunction.registerInventory(id, data)
local type, name, items, slots, maxWeight in data
for k,v in ipairs(items) do
v.amount = v.amount or 10
v.slot = k
end
registeredInventories[('%s-%s'):format(type, id)] = {
label = name,
items = items,
slots = slots or #items,
maxweight = maxWeight
}
end
function overrideFunction.registerUsableItem(name, cb)
qs_inventory:CreateUsableItem(name, function(source, item)
cb(source, item and item.slot, item and item.info)
end)
end
utils.register('bl_bridge:validInventory', function(_, invType, invId)
local inventory = registeredInventories[('%s-%s'):format(invType, invId)]
if not inventory then return end
return inventory
end)
return overrideFunction

View file

@ -0,0 +1,11 @@
---@diagnostic disable: lowercase-global
---@param source number Source of player
---@param data NotificationParams Notification data
function notify(source, data)
local title, type, duration in data
if type == 'inform' then type = 'info' end
TriggerClientEvent('esx:showNotification', source, title, type, duration)
end
return notify

View file

@ -0,0 +1,9 @@
---@diagnostic disable: lowercase-global
---@param source number Source of player
---@param data NotificationParams Notification data
local function notify(source, data)
TriggerClientEvent('ox_lib:notify', source, data)
end
return notify

View file

@ -0,0 +1,11 @@
---@diagnostic disable: lowercase-global
---@param source number Source of player
---@param data NotificationParams Notification data
function notify(source, data)
local title, type, duration in data
if type == 'inform' then type = 'info' end
TriggerClientEvent('QBCore:Notify', source, title, type, duration)
end
return notify

View file

@ -0,0 +1,290 @@
local Utils = {}
local function retreiveExportsData(export, override)
local newMethods = {}
for k, v in pairs(override) do
local method = export[v.originalMethod]
if method then
v.selfEffect = function(...)
return method(export, ...)
end
newMethods[k] = v
end
end
return newMethods
end
local function retreiveStringIndexedData(wrappedData, functionsOverride, src)
local newMethods = {}
local function modifyMethods(data, method, modification)
if type(modification) ~= 'table' then return end
local selfEffect = modification.selfEffect
local originalMethod = selfEffect or modification.originalMethod
local ref = selfEffect or data[originalMethod]
local modifier = modification.modifier
if ref and originalMethod then
local lastEffect
if modifier then
local executeFunc, effect, passSource = modifier.executeFunc, modifier.effect, modifier.passSource
if passSource and executeFunc then
assert(src, 'source not exist')
lastEffect = effect and effect(ref, src) or ref(src)
elseif executeFunc then
lastEffect = effect and effect(ref) or ref
else
lastEffect = function(...)
assert(not passSource or src, 'source not exist')
if passSource and src and effect then
return effect(ref, src, ...)
elseif effect then
return effect(ref, ...)
else
return ref(src, ...)
end
end
end
else
lastEffect = ref
end
newMethods[method] = lastEffect
end
end
local function processTable(tableToProcess, overrides)
for method, modification in pairs(overrides) do
if type(modification) == 'table' and not modification.originalMethod and not modification.add then
processTable(tableToProcess[method], modification)
else
modifyMethods(tableToProcess, method, modification)
end
end
end
processTable(wrappedData, functionsOverride)
return newMethods
end
local function retreiveNumberIndexedData(playerTable, functionsOverride)
local newMethods = {}
local function modifyMethods(data, method, modification)
for dataIndex, dataValue in ipairs(data) do
local originalMethods = type(modification.originalMethod) == 'table' and modification.originalMethod or
{ modification.originalMethod }
local originalMethodRef
local originalMethod
for _, method in ipairs(originalMethods) do
originalMethod = method
originalMethodRef = originalMethod and dataValue[method]
if originalMethodRef then
break
end
end
local hasKeys = modification.hasKeys
if hasKeys then
local modifier = modification.modifier
if modifier and modifier.effect then
newMethods[dataIndex][method] = modifier.effect(dataValue)
end
end
if originalMethodRef then
local modifier = modification.modifier
newMethods[dataIndex] = newMethods[dataIndex] or {}
local effect
if modifier then
if modifier.executeFunc then
effect = modifier.effect(originalMethodRef, originalMethod)
else
effect = function(...)
return modifier.effect(originalMethodRef, ...)
end
end
else
effect = originalMethodRef
end
newMethods[dataIndex][method] = effect
end
end
end
local function processTable(tableToProcess, overrides)
for _, value in ipairs(tableToProcess) do
for method, modification in pairs(overrides) do
if type(modification) == 'table' and not modification.originalMethod then
processTable(value[method], modification)
else
modifyMethods(tableToProcess, method, modification)
end
end
end
end
processTable(playerTable, functionsOverride)
return newMethods
end
local function UUID(num)
num = type(num) == 'number' and num or 5
local template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
local uuid = string.gsub(template, '[xy]', function(c)
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
return string.format('%x', v)
end)
local timestamp = os.time()
local uuidWithTime = string.format("%s-%s", uuid, timestamp)
if num > 0 and num <= #uuidWithTime then
uuidWithTime = string.sub(uuidWithTime, 1, num)
end
return uuidWithTime
end
local context = IsDuplicityVersion() and 'server' or 'client'
--https://github.com/overextended/ox_lib/blob/master/imports/waitFor/shared.lua
function Utils.waitFor(cb, errMessage, timeout)
local value = cb()
if value ~= nil then return value end
if timeout or timeout == nil then
if type(timeout) ~= 'number' then timeout = 1000 end
end
local start = timeout and GetGameTimer()
while value == nil do
Wait(0)
local elapsed = timeout and GetGameTimer() - start
if elapsed and elapsed > timeout then
return error(('%s (waited %.1fms)'):format(errMessage or 'failed to resolve callback', elapsed), 2)
end
value = cb()
end
return value
end
--https://github.com/overextended/ox_lib/blob/master/imports/callback/client.lua - thanks
--https://github.com/overextended/ox_lib/blob/master/imports/callback/server.lua
if context == 'client' then
local pendingCallbacks = {}
local timers = {}
local cbEvent = '__ox_cb_%s'
local resource = GetCurrentResourceName()
RegisterNetEvent(cbEvent:format(resource), function(key, ...)
local cb = pendingCallbacks[key]
pendingCallbacks[key] = nil
return cb and cb(...)
end)
local function eventTimer(event, delay)
if delay and type(delay) == 'number' and delay > 0 then
local time = GetGameTimer()
if (timers[event] or 0) > time then
return false
end
timers[event] = time + delay
end
return true
end
local function triggerServerCallback(_, event, delay, cb, ...)
if not eventTimer(event, delay) then return end
local key
repeat
key = ('%s:%s'):format(event, math.random(0, 100000))
until not pendingCallbacks[key]
TriggerServerEvent(cbEvent:format(event), resource, key, ...)
---@type promise | false
local promise = not cb and promise.new()
pendingCallbacks[key] = function(response, ...)
response = { response, ... }
if promise then
return promise:resolve(response)
end
if cb then
cb(table.unpack(response))
end
end
if promise then
SetTimeout(300000, function() promise:reject(("callback event '%s' timed out"):format(key)) end)
return table.unpack(Citizen.Await(promise))
end
end
function Utils.await(event, delay, ...)
return triggerServerCallback(nil, event, delay, false, ...)
end
else
local cbEvent = '__ox_cb_%s'
local function callbackResponse(success, result, ...)
if not success then
if result then
return print(('^1SCRIPT ERROR: %s^0\n%s'):format(result,
Citizen.InvokeNative(`FORMAT_STACK_TRACE` & 0xFFFFFFFF, nil, 0, Citizen.ResultAsString()) or ''))
end
return false
end
return result, ...
end
function Utils.register(name, cb)
RegisterNetEvent(cbEvent:format(name), function(resource, key, ...)
TriggerClientEvent(cbEvent:format(resource), source, key, callbackResponse(pcall(cb, source, ...)))
end)
end
end
local function table_merge(t1, t2, addDuplicateNumbers)
if addDuplicateNumbers == nil then addDuplicateNumbers = true end
for k, v in pairs(t2) do
local type1 = type(t1[k])
local type2 = type(v)
if type1 == 'table' and type2 == 'table' then
table_merge(t1[k], v, addDuplicateNumbers)
elseif addDuplicateNumbers and (type1 == 'number' and type2 == 'number') then
t1[k] += v
else
t1[k] = v
end
end
return t1
end
exports('UUID', UUID)
Utils.table_merge = table_merge
Utils.retreiveStringIndexedData = retreiveStringIndexedData
Utils.retreiveExportsData = retreiveExportsData
Utils.retreiveNumberIndexedData = retreiveNumberIndexedData
Utils.UUID = UUID
return Utils

BIN
resources/[tools]/bl_idcard/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -0,0 +1 @@
.vscode

View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey 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;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
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
state 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 3 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, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU 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. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View file

@ -0,0 +1,8 @@
---@class IDInfo
---@field id string
---@field firstName string
---@field lastName string
---@field dob string
---@field sex string
---@field idType string
---@field imageURL string

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,23 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,700;1,700&display=swap" rel="stylesheet">
<link href="https://fonts.cdnfonts.com/css/acterumsignaturepersonaluse" rel="stylesheet">
<title>Byte Labs Template</title>
<script type="module" crossorigin src="./index.js"></script>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div id="app"></div>
</body>
</html>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View file

@ -0,0 +1,14 @@
local Events = {}
Events.Receive = {
loaded = 'idcard:loaded',
resolveBaseUrl = 'idcard:resolveBaseUrl',
}
Events.Send = {
requestBaseUrl = 'idcard:requestBaseUrl',
cardData = 'idcard:data',
config = 'idcard:config',
}
return Events

View file

@ -0,0 +1,94 @@
local utils = require "client.utils"
local events = require "client.events"
local config = require "shared.config"
local callback = lib.callback
local Send, Receive = events.Send, events.Receive
local isCardOpen = false
local cardObject = 0
---@param data IDInfo
local function openCardPopup(data)
isCardOpen = true
utils.SendNUIEvent(Send.cardData, data)
end
local function clearPed()
local anim = config.animation
local ped = cache.ped
if DoesEntityExist(cardObject) then
SetEntityAsMissionEntity(cardObject, true, true)
DeleteEntity(cardObject)
cardObject = 0
end
if IsEntityPlayingAnim(ped, anim.dict, anim.clip, 3) then
StopAnimTask(ped, anim.dict, anim.clip, 1.0)
end
end
local function closeCardPopup()
isCardOpen = false
clearPed()
utils.SendNUIEvent(Send.cardData, nil)
end
---@param data IDInfo
RegisterNetEvent('bl_idcard:open', function(data)
openCardPopup(data)
local popupConfig = config.popup
if popupConfig.autoclose ~= 0 then
SetTimeout(popupConfig.autoclose, function()
closeCardPopup()
end)
end
end)
RegisterNUICallback(Receive.loaded, function(_, cb)
cb(1)
utils.SendNUIEvent(Send.config, config.idTypes)
end)
callback.register('bl_idcard:use', function(itemName)
if isCardOpen then return end
local configType = config.items[itemName]
local ped = cache.ped
local prop = configType.prop
if prop then
local playerCoords = GetEntityCoords(ped)
cardObject = CreateObject(prop, playerCoords.x, playerCoords.y, playerCoords.z + 0.2, true, true, true)
local bone = GetPedBoneIndex(ped, 57005)
AttachEntityToEntity(cardObject, ped, bone, 0.1000, 0.0200, -0.0300, -90.000, 170.000, 78.999, true, true, false, true, 1, true)
SetModelAsNoLongerNeeded(cardObject)
end
if not cache.vehicle then
local anim = config.animation
if anim then
lib.requestAnimDict(anim.dict)
TaskPlayAnim(ped, anim.dict, anim.clip, 1.0, 1.0, 10000, 63, 0.0, false, false, false)
end
end
SetTimeout(3000, function()
clearPed()
end)
local target = utils.GetPlayerLookingAt()
if not target then
Framework.notify({
title = "Nobody around",
description = "Look at who you want to show it to."
})
return cache.serverId
end
return target
end)
callback.register('bl_idcard:cb:getMugShot', utils.GetMugShot)
RegisterCommand('closeidcard', closeCardPopup, false)
RegisterKeyMapping('closeidcard', 'Close ID Card Popup', 'keyboard', config.popup.key)

View file

@ -0,0 +1,58 @@
local Utils = {}
local events = require "client.events"
local promiseId = nil
--- Used to send NUI events to the UI
--- @param action string
--- @param data any
function Utils.SendNUIEvent(action, data)
SendNUIMessage({
action = action,
data = data
})
end
RegisterNUICallback(events.Receive.resolveBaseUrl, function(url, cb)
if not promiseId then return end
promiseId:resolve(url)
promiseId = nil
cb(1)
end)
function Utils.GetMugShot()
if promiseId then return end
local ped = cache.ped
local oldMask = GetPedDrawableVariation(ped, 1)
local hasMask = oldMask ~= 0
if hasMask then
SetPedComponentVariation(ped, 1, 0, 0, 2)
end
local headShotHandle = RegisterPedheadshotTransparent(ped) or RegisterPedheadshot_3(ped)
if not lib.waitFor(function()
if IsPedheadshotReady(headShotHandle) and IsPedheadshotValid(headShotHandle) then return true end
end, 'couldn\'t load mugshot', 10000) then return end
local headShotTxd = GetPedheadshotTxdString(headShotHandle)
Utils.SendNUIEvent(events.Send.requestBaseUrl, headShotTxd)
UnregisterPedheadshot(headShotHandle)
if hasMask then
SetPedComponentVariation(ped, 1, oldMask, GetPedTextureVariation(ped, 1), 2)
end
promiseId = promise.new()
return Citizen.Await(promiseId)
end
function Utils.GetPlayerLookingAt()
local config = require "shared.config"
local playerId, entity = lib.getClosestPlayer(GetEntityCoords(cache.ped), config.range)
if not playerId or not entity or not IsPedAPlayer(entity) then return end
return GetPlayerServerId(playerId)
end
return Utils

View file

@ -0,0 +1,33 @@
fx_version 'cerulean'
game "gta5"
author "Byte Labs"
version '1.5.0'
description 'Byte Labs ID Card'
repository 'https://github.com/Byte-Labs-Project/bl_idcard'
lua54 'yes'
dependency 'bl_bridge'
ui_page 'web/build/index.html'
-- ui_page 'http://localhost:3000/' --for dev
shared_script '@ox_lib/init.lua'
server_script {
'@bl_bridge/imports/server.lua',
'server/init.lua'
}
client_script {
'@bl_bridge/imports/client.lua',
'client/init.lua',
}
files {
'web/mugshots/*.png',
'web/build/**',
'client/**',
'shared/**'
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

View file

@ -0,0 +1,94 @@
# Byte Labs - ID Card
A customisable system with an immaculate ID card design for your FiveM server.
![Preview](preview.png)
Website: [Byte Labs](https://byte-labs.net)
Discord: [Byte Labs](https://discord.gg/fqsqSjZfxE)
![Preview](https://imgur.com/F1ZFwiG.png)
![Preview](https://imgur.com/qMzVLK4.png)
![Preview](https://imgur.com/maPFyoC.png)
![Preview](https://imgur.com/c3Ir9Ds.png)
## Features
- Customisable ID card design with a clean and modern look
## Dependencies
- [bl_bridge](https://github.com/Byte-Labs-Project/bl_bridge)
- [ox_lib](https://github.com/overextended/ox_lib)
## Installation
1. Download
2. Extract the `bl_idcard` folder to your resources directory
3. Add `ensure bl_idcard` to your server.cfg after bl_bridge
4. Follow [Docs](https://docs.byte-labs.net/bl_idcard) Instructions
4. Configure the `config.lua` to your liking
## Items
### OX Inventory
```lua
["id_card"] = {
label = "ID Card",
weight = 0,
stack = false,
close = false,
description = "A card containing all your information to identify yourself",
},
["driver_license"] = {
label = "Drivers License",
weight = 0,
stack = false,
close = false,
description = "Permit to show you can drive a vehicle",
},
["weaponlicense"] = {
label = "Weapon License",
weight = 0,
stack = false,
close = true,
description = "Weapon License",
},
```
### QB / QS / PS Inventory
```lua
['id_card'] = {
name = 'id_card',
label = 'ID Card',
weight = 0,
type = 'item',
description = 'A card containing all your information to identify yourself',
unique = true,
useable = true,
image = 'id_card.png',
combinable = nil,
},
['driver_license'] = {
name = 'driver_license',
label = 'Drivers License',
weight = 0,
type = 'item',
description = 'Permit to show you can drive a vehicle',
unique = true,
useable = true,
image = 'driver_license.png',
combinable = nil,
},
['weaponlicense'] = {
name = 'weaponlicense',
label = 'Weapon License',
weight = 0,
type = 'item',
description = 'Weapon License',
unique = true,
useable = true,
image = 'weaponlicense.png',
combinable = nil,
},
```

View file

@ -0,0 +1,29 @@
local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
local resourcePath = GetResourcePath(cache.resource)
local imagePath = '/web/mugshots'
local function base64Decode(data)
data = data:gsub('[^'..b..'=]', '')
return (data:gsub('.', function(x)
if x == '=' then return '' end
local r, f = '', (b:find(x) - 1)
for i = 6, 1, -1 do r = r .. (f % 2^i - f % 2^(i-1) > 0 and '1' or '0') end
return r
end):gsub('%d%d%d%d%d%d%d%d', function(x)
return string.char(tonumber(x, 2))
end))
end
local function saveBase64AsPng(base64String, imageName)
local updatedPath = resourcePath:match("resources/.*")
local base64Data = base64String:gsub("^data:image/png;base64,", "")
local decodedData = base64Decode(base64Data)
local file = io.open(('%s/%s/%s.png'):format(updatedPath, imagePath, imageName), "wb")
if file then
file:write(decodedData)
file:close()
return true
end
end
return saveBase64AsPng

View file

@ -0,0 +1,105 @@
local config = require "shared.config"
local callback = lib.callback
local core = Framework.core
local unSavedMugshots = {}
local function decodeBase(mugshot, itemImage)
local decodeBase64 = require'server.decoder'
decodeBase64(mugshot, itemImage)
return itemImage
end
---comment
---@param source number
---@param licenses string | table The key in Config.items
local function createLicense(source, licenses)
if type(licenses) == 'string' then
licenses = {licenses}
end
local mugshot = callback.await('bl_idcard:cb:getMugShot', source)
if not mugshot then
print('Mugshot for license creation not found. Source: ' .. source .. ' | ' .. GetPlayerName(source))
return
end
local player = core.GetPlayer(source)
local itemImage = decodeBase(mugshot, ('%s_mugshot'):format(player.id))
unSavedMugshots[itemImage] = mugshot
local playerCharInfo = player.charinfo
local charInfo = {
id = player.id,
dob = player.dob,
firstName = playerCharInfo.firstname,
lastName = playerCharInfo.lastname,
sex = player.gender,
imageURL = itemImage
}
for _, license in ipairs(licenses) do
local configType = config.items[license]
if configType then
local idType = configType.genderIdType and configType.genderIdType[charInfo.sex] or configType.idType
charInfo.idType = idType
player.addItem(license, 1, charInfo)
return charInfo
else
print('License type not found in config: ' .. license)
end
end
end
exports('createLicense', createLicense)
lib.addCommand('giveidcard', {
help = 'Gives an item to a player',
params = {
{
name = 'target',
type = 'playerId',
help = 'Target player\'s server id',
},
{
name = 'license',
type = 'string',
help = 'License Name: [id_card, driver_license]',
},
},
restricted = not config.Debug and 'group.admin'
}, function(source, args, raw)
createLicense(args.target, args.license)
end)
CreateThread(function()
local items = config.items
for k, v in pairs(items) do
core.RegisterUsableItem(k, function(source, slotId, metadata)
local idType = metadata?.idType
local player
if not idType then
player = core.GetPlayer(source)
player.removeItem(k, 1)
metadata = createLicense(source, k)
end
local target = callback.await('bl_idcard:use', source, k)
if target and metadata then
local base64Code = metadata.imageURL
if base64Code and base64Code:find("data:image/png;base64") then
player = player or core.GetPlayer(source)
local itemImage = decodeBase(base64Code, ('%s_mugshot'):format(player.id))
metadata.imageURL = itemImage
unSavedMugshots[itemImage] = base64Code
player.setMetaData(slotId, metadata)
end
metadata.imageURL = unSavedMugshots[metadata.imageURL] or metadata.imageURL
TriggerClientEvent('bl_idcard:open', target, metadata)
end
end)
end
end)

View file

@ -0,0 +1,108 @@
return {
Debug = true,
items = {
['id_card'] = {
prop = `prop_franklin_dl`,
genderIdType = {
female = 'female_id',
male = 'male_id'
}
},
['driver_license'] = {
prop = `prop_franklin_dl`,
idType = 'driver_license'
},
['weaponlicense'] = {
prop = `prop_franklin_dl`,
idType = 'weapon_license'
},
},
range = 2.0, -- Range to show the ped looking at
popup = {
autoclose = 5000, -- 0 to disable
key = 'back', -- key to close the popup
},
animation = {
dict = 'paper_1_rcm_alt1-9',
clip = 'player_one_dual-9',
},
idTypes = {
driver_license = {
type = 'driver_license',
title = 'SAN ANDREAS',
titleColour = '#bdbdbd',
label = 'DRIVER LICENSE',
stamp = true,
profileStamp = false,
signature = true,
bgColour = '#000',
bgColourSecondary = '#000',
textColour = '#FFF',
},
weapon_license = {
type = 'weapon_license',
title = 'SAN ANDREAS',
titleColour = '#ff4538',
label = 'WEAPON LICENSE',
stamp = true,
profileStamp = false,
signature = true,
bgColour = '#460000',
bgColourSecondary = '#E90000',
textColour = '#FFF',
},
female_id = {
type = 'female_id',
title = 'SAN ANDREAS',
titleColour = '#F97C81',
label = 'ID CARD',
stamp = true,
profileStamp = true,
signature = true,
bgColour = '#f1e6db',
bgColourSecondary = '#ff75bc',
textColour = '#323443',
},
male_id = {
type = 'male_id',
title = 'SAN ANDREAS',
titleColour = '#89B1FF',
label = 'ID CARD',
stamp = true,
profileStamp = true,
signature = true,
bgColour = '#E5FCFF',
bgColourSecondary = '#6FCBE9',
textColour = '#323443',
},
}
}

View file

@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View file

@ -0,0 +1,13 @@
{
"tabWidth": 4,
"useTabs": false,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",
"proseWrap": "always",
"semi": true,
"printWidth": 80,
"endOfLine": "auto"
}

View file

@ -0,0 +1,47 @@
# Svelte + TS + Vite
This template should help get you started developing with Svelte and TypeScript in Vite.
## Recommended IDE Setup
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
## Need an official Svelte framework?
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
## Technical considerations
**Why use this over SvelteKit?**
- It brings its own routing solution which might not be preferable for some users.
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
**Why include `.vscode/extensions.json`?**
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
**Why enable `allowJs` in the TS template?**
While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds: not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant.
**Why is HMR not preserving my local component state?**
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
```ts
// store.ts
// An extremely simple external store
import { writable } from 'svelte/store'
export default writable(0)
```

View file

@ -0,0 +1,21 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,700;1,700&display=swap" rel="stylesheet">
<link href="https://fonts.cdnfonts.com/css/acterumsignaturepersonaluse" rel="stylesheet">
<title>Byte Labs Template</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

View file

@ -0,0 +1,27 @@
{
"name": "web",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^2.4.2",
"@tsconfig/svelte": "^5.0.0",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.30",
"svelte": "^4.0.5",
"svelte-check": "^3.4.6",
"tailwindcss": "^3.3.3",
"tslib": "^2.6.0",
"typescript": "^5.0.2",
"vite": "^4.4.9"
},
"dependencies": {
"path": "^0.12.7"
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
import tailwind from 'tailwindcss';
import autoprefixer from 'autoprefixer';
import tailwindConfig from './tailwind.config.js';
export default {
plugins: [tailwind(tailwindConfig), autoprefixer],
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View file

@ -0,0 +1,49 @@
<script lang="ts">
import { CONFIG, ID_INFO, IS_BROWSER } from './stores/stores';
import { InitialiseListen } from '@utils/listeners';
import Card from '@components/Card.svelte';
import { onMount } from 'svelte';
import { SendEvent } from '@utils/eventsHandlers';
import { Send } from '@enums/events';
CONFIG.set({
fallbackResourceName: 'bl_idcard',
allowEscapeKey: false,
});
InitialiseListen();
onMount(() => {
SendEvent(Send.loaded);
});
</script>
{#if $ID_INFO}
<main>
<Card />
</main>
{/if}
{#if import.meta.env.DEV}
{#if $IS_BROWSER}
{#await import('./providers/Debug.svelte') then { default: Debug }}
<Debug />
{/await}
{/if}
{/if}
<style>
main {
position: absolute;
left: 0;
top: 0;
z-index: 100;
user-select: none;
box-sizing: border-box;
padding: 0;
margin: 0;
height: 100vh;
width: 100vw;
}
</style>

View file

@ -0,0 +1,42 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
* {
margin: 0;
padding: 0;
font-smooth: auto;
}
*:focus {
outline: none;
}
:root {
font-size: 62.5%;
--text: '#323443';
--title: '#F97C81';
--bg: '#8685ef';
--bg-secondary: '#8685ef';
color: var(--text);
}
html, body {
height: 100vh;
width: 100vw;
font-size: 1.6rem;
overflow: hidden;
}
.signature {
font-family: 'ActerumSignaturePersonalUse', sans-serif;
}
.roboto-condensed-bold {
font-family: "Roboto Condensed", sans-serif;
font-optical-sizing: auto;
font-weight: 700;
font-style: normal;
}

View file

@ -0,0 +1,173 @@
<script lang="ts">
import { ID_INFO, ID_TYPE } from '@stores/stores';
import Pattern from './svgs/Pattern.svelte';
import PfpOverlay from './svgs/PfpOverlay.svelte';
import Stamp from './svgs/Stamp.svelte';
import Backdrop from './svgs/Backdrop.svelte';
let { id, firstName, lastName, dob, sex, imageURL } = $ID_INFO;
let { title, label, stamp, profileStamp, signature } = $ID_TYPE;
</script>
<div
class="aspect-ratio h-[20vh] bg absolute top-1/4 right-1/4 rounded-[2vh] overflow-hidden grid place-items-center py-[0vh]"
>
<Backdrop />
<Pattern />
<div class="w-full h-full flex flex-col z-10">
<span class="flex flex-col items-center justify-between gap-0">
<h1
class="uppercase text-txt-secondary font-bold tracking-[0.25vh] text-[2.5vh] grid place-items-center whitespace-nowrap"
>
{title}
<h1
class="absolute text-txt-secondary text brightness-75 -z-10 whitespace-nowrap"
>
{title}
</h1>
</h1>
<h1
class="uppercase txt-primary opacity-80 font-bold text-[1.5vh] whitespace-nowrap leading-[1vh]"
>
{label}
</h1>
</span>
<!-- <div class="w-full h-[0.2vh] bg-black/20" /> -->
<PfpOverlay />
<div
class="grid place-items-center w-[10vh] h-[10vh] left-[0.5vw] rounded-full overflow-hidden absolute top-1/2 -translate-y-1/2"
>
<div
style="background-image: url({imageURL});"
class="w-full h-full bg-center bg-contain bg-no-repeat grid place-items-center z-10"
/>
<div
style="background-image: url({imageURL});"
class="w-1/2 h-1/2 rounded-full bg-center bg-contain bg-no-repeat grid place-items-center z-0 absolute blur-[1vh]"
/>
</div>
<div
class="flex flex-row w-[18vh] h-full items-start justify-between uppercase roboto-condensed-bold overflow-visible absolute right-[2vh] top-[5.5vh]"
>
<div class="flex flex-col items-start justify-center gap-[1vh]">
<span class="flex flex-col gap-0 items-start justify-center">
<h1 class="text-[1.2vh] text-txt-primary opacity-80">ID</h1>
<h1 class="text-[1.5vh] text-txt-primary leading-[1vh]">
{id}
</h1>
</span>
<span class="flex flex-col gap-0 items-start justify-center">
<h1 class="text-[1.2vh] text-txt-primary opacity-80">
LASTNAME
</h1>
<h1 class="text-[1.75vh] text-txt-primary leading-[1vh]">
{lastName}
</h1>
</span>
<span class="flex flex-col gap-0 items-start justify-center">
<h1 class="text-[1.2vh] text-txt-primary opacity-80">
FIRSTNAME
</h1>
<h1 class="text-[1.75vh] text-txt-primary leading-[1vh]">
{firstName}
</h1>
</span>
</div>
<div class="flex flex-col items-start justify-center gap-[1vh]">
<span class="flex flex-col gap-0 items-start justify-center">
<h1 class="text-[1.2vh] text-txt-primary opacity-80">
EXP
</h1>
<h1 class="text-[1.5vh] text-txt-primary leading-[1vh]">
12/12/2030
</h1>
</span>
<span class="flex flex-col gap-0 items-start justify-center">
<h1 class="text-[1.2vh] text-txt-primary opacity-80">DOB</h1>
<h1 class="text-[1.5vh] text-txt-primary leading-[1vh]">
{dob}
</h1>
</span>
<span class="flex flex-col gap-0 items-start justify-center">
<h1 class="text-[1.2vh] text-txt-primary opacity-80">
SEX
</h1>
<h1 class="text-[1.5vh] text-txt-primary leading-[1vh]">
{sex.split('')[0]}
</h1>
</span>
</div>
</div>
{#if profileStamp}
<div
class="absolute grid place-items-center w-[4vh] h-[4vh] right-[0.75vh] bottom-[0.75vh] rounded-full overflow-hidden"
>
<img
src={imageURL}
class="w-full h-full object-cover z-10 absolute opacity-60 hue-rotate-[210deg]"
alt={firstName + lastName}
/>
<img
src="./profileGradient.png"
class="w-full h-full object-cover z-0 absolute"
alt={firstName + lastName}
/>
</div>
{/if}
{#if stamp}
<div
class="absolute w-[12.5vh] h-[12.5vh] right-[5vh] bottom-[2vh]"
>
<Stamp />
</div>
{/if}
{#if signature}
<h1
class="text-[4vh] left-[1vh] signature text-txt-primary underline decoration-[0.135vh] underline-offset-[-0.5vh] absolute translate-y-[20%] bottom-[0.5vh] opacity-80 z-50"
>
{firstName}
{lastName}
</h1>
{/if}
</div>
</div>
<style>
.aspect-ratio {
aspect-ratio: 1.59259259259;
}
.bg {
background: var(--bg);
background: linear-gradient(
120deg,
var(--bg) 0%,
var(--bg-secondary) 100%
);
}
.text {
text-shadow:
0.1vh 0.1vh 0.1vh var(--title),
0.2vh 0.2vh 0.1vh var(--title),
0.15vh 0.15vh 0.1vh var(--title);
}
</style>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 920 KiB

View file

@ -0,0 +1,38 @@
<svg viewBox="0 0 600 375" class="w-full h-full fill-none absolute opacity-50" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.05" d="M805.914 295.313L233.835 -355.644L-14.9988 573.018L805.914 295.313Z" stroke="white"/>
<path opacity="0.08" d="M800.244 274.817L212.177 -327.589L17.9975 585.953L800.244 274.817Z" stroke="white"/>
<path opacity="0.11" d="M793.41 255.176L192.821 -298.839L51.0157 596.483L793.41 255.176Z" stroke="white"/>
<path opacity="0.13" d="M785.489 236.455L175.781 -269.555L83.8992 604.643L785.489 236.455Z" stroke="white"/>
<path opacity="0.16" d="M776.557 218.713L161.057 -239.9L116.491 610.477L776.557 218.713Z" stroke="white"/>
<path opacity="0.19" d="M766.694 202L148.638 -210.038V614.037L766.694 202Z" stroke="white"/>
<path opacity="0.22" d="M755.983 186.365L138.502 -180.123L180.193 615.391L755.983 186.365Z" stroke="white"/>
<path opacity="0.25" d="M744.511 171.851L130.62 -150.313L211.017 614.61L744.511 171.851Z" stroke="white"/>
<path opacity="0.27" d="M732.366 158.492L124.952 -120.759L240.975 611.777L732.366 158.492Z" stroke="white"/>
<path opacity="0.3" d="M719.638 146.316L121.449 -91.6119L269.939 606.98L719.638 146.316Z" stroke="white"/>
<path opacity="0.33" d="M706.412 135.348L120.046 -63.013L297.784 600.316L706.412 135.348Z" stroke="white"/>
<path opacity="0.36" d="M692.787 125.604L120.681 -35.1007L324.403 591.893L692.787 125.604Z" stroke="white"/>
<path opacity="0.39" d="M678.851 117.095L123.274 -8.00867L349.687 581.819L678.851 117.095Z" stroke="white"/>
<path opacity="0.41" d="M664.692 109.825L127.736 18.1369L373.535 570.212L664.692 109.825Z" stroke="white"/>
<path opacity="0.44" d="M650.408 103.793L133.98 43.2179L395.866 557.197L650.408 103.793Z" stroke="white"/>
<path opacity="0.47" d="M636.081 98.991L141.9 67.1198L416.592 542.9L636.081 98.991Z" stroke="white"/>
<path opacity="0.5" d="M621.807 95.4044L151.394 89.7385L435.649 527.452L621.807 95.4044Z" stroke="white"/>
<path opacity="0.53" d="M607.669 93.015L162.345 110.978L452.972 510.993L607.669 93.015Z" stroke="white"/>
<path opacity="0.55" d="M593.755 91.796L174.635 130.75L468.513 493.658L593.755 91.796Z" stroke="white"/>
<path opacity="0.58" d="M580.148 91.7167L188.142 148.974L482.229 475.591L580.148 91.7167Z" stroke="white"/>
<path opacity="0.61" d="M566.923 92.7422L202.73 165.581L494.085 456.935L566.923 92.7422Z" stroke="white"/>
<path opacity="0.64" d="M554.163 94.8292L218.273 180.508L504.063 437.835L554.163 94.8292Z" stroke="white"/>
<path opacity="0.66" d="M541.939 97.9313L234.632 193.705L512.151 418.435L541.939 97.9313Z" stroke="white"/>
<path opacity="0.69" d="M530.323 101.995L251.671 205.127L518.347 398.878L530.323 101.995Z" stroke="white"/>
<path opacity="0.72" d="M519.38 106.97L269.246 214.746L522.66 379.314L519.38 106.97Z" stroke="white"/>
<path opacity="0.75" d="M509.171 112.791L287.216 222.536L525.106 359.881L509.171 112.791Z" stroke="white"/>
<path opacity="0.78" d="M499.755 119.396L305.439 228.485L525.716 340.722L499.755 119.396Z" stroke="white"/>
<path opacity="0.8" d="M491.183 126.717L323.769 232.592L524.524 321.974L491.183 126.717Z" stroke="white"/>
<path opacity="0.83" d="M483.506 134.683L342.069 234.864L521.581 303.772L483.506 134.683Z" stroke="white"/>
<path opacity="0.86" d="M476.764 143.22L360.192 235.316L516.94 286.246L476.764 143.22Z" stroke="white"/>
<path opacity="0.89" d="M470.995 152.25L378.001 233.975L510.667 269.523L470.995 152.25Z" stroke="white"/>
<path opacity="0.92" d="M466.233 161.697L395.362 230.881L502.837 253.726L466.233 161.697Z" stroke="white"/>
<path opacity="0.94" d="M462.5 171.478L412.135 226.077L493.528 238.968L462.5 171.478Z" stroke="white"/>
<path opacity="0.97" d="M459.819 181.511L428.193 219.618L482.83 225.36L459.819 181.511Z" stroke="white"/>
<path d="M458.205 191.714L443.411 211.569L470.843 213.006L458.205 191.714Z" stroke="white"/>
</svg>

After

Width:  |  Height:  |  Size: 3.9 KiB

View file

@ -0,0 +1,115 @@
<svg viewBox="0 0 423 375" class="w-[25vh] absolute" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.05" d="M270.311 -10.4165L337.473 223.804L168.213 399.077L-68.2084 340.131L-135.37 105.91L33.8896 -69.3632L270.311 -10.4165Z" stroke="url(#paint0_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.1" d="M256.68 -7.98644L328.553 213.214L172.924 386.057L-54.5775 337.7L-126.45 116.5L29.1788 -56.3435L256.68 -7.98644Z" stroke="url(#paint1_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.14" d="M243.433 -4.82802L319.194 203.322L176.811 373.007L-41.3322 334.542L-117.093 126.392L25.2901 -43.2927L243.433 -4.82802Z" stroke="url(#paint2_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.19" d="M230.605 -0.966155L309.435 194.144L179.88 359.967L-28.5053 330.68L-107.335 135.57L22.2204 -30.2529L230.605 -0.966155Z" stroke="url(#paint3_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.23" d="M218.23 3.57367L299.317 185.696L182.137 346.979L-16.1281 326.141L-97.2143 144.018L19.965 -17.265L218.23 3.57367Z" stroke="url(#paint4_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.28" d="M206.337 8.7644L288.874 177.991L183.588 334.084L-4.2351 320.95L-86.7726 151.723L18.5133 -4.36962L206.337 8.7644Z" stroke="url(#paint5_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.32" d="M194.956 14.5773L278.149 171.042L184.244 321.321L7.14546 315.137L-76.0482 158.672L17.857 8.39276L194.956 14.5773Z" stroke="url(#paint6_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.37" d="M184.117 20.9834L267.183 164.857L184.117 308.731L17.9859 308.731L-65.0798 164.857L17.9858 20.9833L184.117 20.9834Z" stroke="url(#paint7_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.41" d="M173.846 27.9509L256.013 159.446L183.218 296.352L28.257 301.763L-53.9101 170.268L18.8841 33.3622L173.846 27.9509Z" stroke="url(#paint8_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.46" d="M164.168 35.448L244.681 154.813L181.564 284.222L37.9344 294.265L-42.5785 174.9L20.5383 45.4914L164.168 35.448Z" stroke="url(#paint9_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.5" d="M155.107 43.4425L233.227 150.965L179.17 272.38L46.9927 286.272L-31.127 178.749L22.9303 57.3348L155.107 43.4425Z" stroke="url(#paint10_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.55" d="M146.689 51.8993L221.695 147.902L176.057 260.861L55.4129 277.816L-19.5929 181.813L26.0452 68.8547L146.689 51.8993Z" stroke="url(#paint11_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.59" d="M138.93 60.7823L210.122 145.625L172.242 249.7L63.1701 268.932L-8.02137 184.089L29.8588 80.0145L138.93 60.7823Z" stroke="url(#paint12_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.64" d="M131.853 70.0571L198.551 144.133L167.749 238.933L70.2485 259.657L3.55029 185.581L34.3527 90.7814L131.853 70.0571Z" stroke="url(#paint13_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.68" d="M125.473 79.6856L187.022 143.421L162.6 228.592L76.6284 250.027L15.0793 186.292L39.5017 101.121L125.473 79.6856Z" stroke="url(#paint14_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.73" d="M119.807 89.6321L175.576 143.487L156.82 218.712L82.2956 240.082L26.5266 186.227L45.2823 111.002L119.807 89.6321Z" stroke="url(#paint15_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.77" d="M114.867 99.8563L164.251 144.322L150.435 209.322L87.2347 229.857L37.8508 185.392L51.6671 120.391L114.867 99.8563Z" stroke="url(#paint16_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.82" d="M110.667 110.321L153.088 145.917L143.472 200.452L91.4347 219.392L49.0133 183.797L58.6294 129.261L110.667 110.321Z" stroke="url(#paint17_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.86" d="M107.216 120.987L142.126 148.261L135.96 192.132L94.8845 208.728L59.9743 181.453L66.1399 137.582L107.216 120.987Z" stroke="url(#paint18_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.91" d="M104.523 131.813L131.404 151.343L127.931 184.387L97.5772 197.901L70.6966 178.371L74.1697 145.327L104.523 131.813Z" stroke="url(#paint19_linear_2381_81)" stroke-opacity="0.5"/>
<path opacity="0.95" d="M102.596 142.761L120.96 155.147L119.415 177.244L99.5061 186.954L81.1422 174.568L82.6874 152.471L102.596 142.761Z" stroke="url(#paint20_linear_2381_81)" stroke-opacity="0.5"/>
<path d="M101.437 153.788L110.83 159.657L110.443 170.726L100.664 175.925L91.2718 170.056L91.6583 158.987L101.437 153.788Z" stroke="url(#paint21_linear_2381_81)" stroke-opacity="0.5"/>
<defs>
<linearGradient id="paint0_linear_2381_81" x1="270.311" y1="-10.4165" x2="-68.2084" y2="340.131" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint1_linear_2381_81" x1="256.68" y1="-7.98645" x2="-54.5775" y2="337.7" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint2_linear_2381_81" x1="243.433" y1="-4.82803" x2="-41.3322" y2="334.542" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint3_linear_2381_81" x1="230.605" y1="-0.966151" x2="-28.5053" y2="330.68" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint4_linear_2381_81" x1="218.23" y1="3.57367" x2="-16.1281" y2="326.141" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint5_linear_2381_81" x1="206.337" y1="8.76441" x2="-4.23508" y2="320.95" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint6_linear_2381_81" x1="194.956" y1="14.5773" x2="7.14548" y2="315.137" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint7_linear_2381_81" x1="184.117" y1="20.9834" x2="17.986" y2="308.731" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint8_linear_2381_81" x1="173.846" y1="27.9509" x2="28.257" y2="301.763" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint9_linear_2381_81" x1="164.168" y1="35.448" x2="37.9344" y2="294.265" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint10_linear_2381_81" x1="155.107" y1="43.4425" x2="46.9927" y2="286.272" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint11_linear_2381_81" x1="146.689" y1="51.8993" x2="55.4129" y2="277.816" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint12_linear_2381_81" x1="138.93" y1="60.7823" x2="63.1701" y2="268.932" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint13_linear_2381_81" x1="131.853" y1="70.0571" x2="70.2485" y2="259.657" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint14_linear_2381_81" x1="125.473" y1="79.6856" x2="76.6284" y2="250.027" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint15_linear_2381_81" x1="119.807" y1="89.6321" x2="82.2956" y2="240.082" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint16_linear_2381_81" x1="114.867" y1="99.8563" x2="87.2347" y2="229.857" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint17_linear_2381_81" x1="110.667" y1="110.321" x2="91.4347" y2="219.392" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint18_linear_2381_81" x1="107.216" y1="120.987" x2="94.8845" y2="208.728" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint19_linear_2381_81" x1="104.523" y1="131.813" x2="97.5772" y2="197.901" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint20_linear_2381_81" x1="102.596" y1="142.761" x2="99.5061" y2="186.954" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
<linearGradient id="paint21_linear_2381_81" x1="101.437" y1="153.788" x2="100.664" y2="175.925" gradientUnits="userSpaceOnUse">
<stop stop-color="#1F89DB"/>
<stop offset="1" stop-color="#F42A8B"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 9.4 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 909 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 76 KiB

View file

@ -0,0 +1,11 @@
export enum Receive {
cardData = 'idcard:data',
config = 'idcard:config',
requestBaseUrl = 'idcard:requestBaseUrl',
}
export enum Send {
resolveBaseUrl = 'idcard:resolveBaseUrl',
close = 'idcard:close',
loaded = 'idcard:loaded',
}

View file

@ -0,0 +1,8 @@
import './app.css'
import App from './App.svelte'
const app = new App({
target: document.getElementById('app'),
})
export default app

View file

@ -0,0 +1,115 @@
<script lang="ts">
import DebugImage from '@utils/debug/DebugImage.svelte';
import { InitialiseDebugSenders } from '@utils/debug/init';
import { InitialiseDebugReceivers } from '@utils/debug/receivers';
import SendDebuggers from '@utils/debug/senders';
import { onMount } from 'svelte';
onMount(() => {
InitialiseDebugSenders();
InitialiseDebugReceivers();
});
let menuOpen: boolean = false;
</script>
<div class="w-fit h-fit flex flex-col z-[9999999]">
<button
class="px-[1vw] py-[0.5vw] w-fit h-fit z-[9999999] bg-accent"
on:click={() => (menuOpen = !menuOpen)}
>
Debug
</button>
{#if menuOpen}
<ol
class="flex flex-col gap-2 bg-primary z-[9999999] max-w-[25vw] h-full px-[0.5vw] py-[0.5vw]"
>
{#each SendDebuggers as { label, actions }}
<li
class="flex flex-col gap-1 border-l-[2px] border-[color:var(--accent)] px-[0.25vw]"
>
<span class="w-full">{label}</span>
{#each actions as action}
<div class="flex flex-row flex-wrap gap-[0.5vw]">
{#if action.type === 'text'}
<span
class="w-full px-[0.5vw] py-[0.25vw] flex flex-col gap-[0.2vw] bg-accent items-start"
>
<p class="">{action.label}</p>
<input
type="text"
class="h-full w-full text-[color:var(--text-secondary)] px-[0.25vw]"
bind:value={action.value}
/>
<button
class="px-[0.5vw] py-[0.25vw] w-[5vw] bg-primary"
on:click={() => {
// @ts-ignore
action.action(action.value);
}}
>
Apply
</button>
</span>
{:else if action.type === 'checkbox'}
<span
class="w-full px-[0.5vw] py-[0.25vw] flex flex-row gap-[0.2vw] bg-accent items-center"
>
<p>{action.label}</p>
<input
type="checkbox"
class="h-full aspect-square"
bind:checked={action.value}
on:input={(e) => {
// @ts-ignore
action.action(action.value);
}}
/>
</span>
{:else if action.type === 'slider'}
<span
class="w-full px-[0.5vw] py-[0.25vw] flex flex-col gap-[0.2vw] bg-accent items-start"
>
<p>{action.label}</p>
<input
type="range"
class="w-full"
min={action.min || 0}
max={action.max || 100}
step={action.step || 1}
bind:value={action.value}
on:input={() => {
// @ts-ignore
action.action(action.value);
}}
/>
</span>
{:else}
<button
on:click={() => {
// @ts-ignore
action.action();
}}
class="w-full px-[0.5vw] py-[0.25vw] bg-accent"
>
{action.label}
</button>
{/if}
</div>
{/each}
</li>
{/each}
</ol>
{/if}
<div
class="absolute w-screen bg-cover bg-no-repeat bg-center h-screen top-0 left-0 dev-image grid place-items-center"
>
<DebugImage />
</div>
</div>

View file

@ -0,0 +1,37 @@
<script lang="ts">
import { Receive, Send } from '@enums/events';
import { VISIBLE, CONFIG } from '@stores/stores';
import { ReceiveEvent, SendEvent } from '@utils/eventsHandlers';
import { onMount } from 'svelte';
onMount(() => {
if (!$CONFIG.allowEscapeKey) return;
const keyHandler = (e: KeyboardEvent) => {
if ($VISIBLE && ['Escape'].includes(e.code)) {
SendEvent(Send.close);
}
};
window.addEventListener('keydown', keyHandler);
return () => window.removeEventListener('keydown', keyHandler);
});
</script>
<main>
<slot />
</main>
<style>
main {
position: absolute;
left: 0;
top: 0;
z-index: 100;
user-select: none;
box-sizing: border-box;
padding: 0;
margin: 0;
height: 100vh;
width: 100vw;
}
</style>

View file

@ -0,0 +1,42 @@
import { TIDInfo, TIDType, TIDTypes } from '@typings/id';
import { IsEnvBrowser } from '@utils/eventsHandlers';
import { get, writable } from 'svelte/store';
export const CONFIG = writable<any>({
/** Fallback resource name for when the resource name cannot be found. */
fallbackResourceName: 'debug',
/** Whether the escape key should make visibility false. */
allowEscapeKey: true,
});
/**
* The name of the resource. This is used for the resource manifest.
* @type {Writable<string>}
*/
export const RESOURCE_NAME = writable<string>(
(window as any).GetParentResourceName
? (window as any).GetParentResourceName()
: get(CONFIG).DEBUG_RESOURCE_NAME,
);
/**
* Whether the current environment is the browser or the client.
* @type {Writable<boolean>}
*/
export const IS_BROWSER = writable<boolean>(!(window as any).invokeNative);
/**
* Whether the debug menu is visible or not.
* @type {Writable<boolean>}
*/
export const VISIBLE = writable<boolean>(false);
export const ID_INFO = writable<TIDInfo>(null);
export const ID_TYPES = writable<TIDTypes>(null);
export const ID_TYPE = writable<TIDType>(null);

View file

@ -0,0 +1,54 @@
export interface NuiMessage<T = any> {
action: string
data: T
}
export interface DebugEvent<T = any> {
action: string
data: T
}
export interface DebugEventCallback<T = any> {
action: string
handler?: (data: T) => unknown
}
export interface CommonActionProperties {
label: string
action: (...args: any[]) => any
delay?: number
}
export type ButtonAction = CommonActionProperties & {
type?: 'button'
}
export type CheckboxAction = CommonActionProperties & {
type: 'checkbox'
value?: boolean
}
export type SliderAction = CommonActionProperties & {
type: 'slider'
max?: number
min?: number
step?: number
value?: number
}
export type TextAction = CommonActionProperties & {
type: 'text'
placeholder?: string
value?: any
}
export type DebugAction =
| ButtonAction
| CheckboxAction
| SliderAction
| TextAction
export interface DebugItem {
label: string
actions?: DebugAction[]
}

View file

@ -0,0 +1,30 @@
export type TIDInfo = {
id: string;
firstName: string;
lastName: string;
dob: string;
sex: string;
idType: string;
imageURL: string;
}
export type TIDType = {
type : string;
title: string;
label: string;
titleColour: string;
stamp: boolean;
profileStamp: boolean;
signature: boolean;
bgColour: string;
bgColourSecondary: string;
textColour: string;
}
export type TIDTypes = {
[key: string]: TIDType;
}

View file

@ -0,0 +1,4 @@
export interface Config {
fallbackResourceName: string;
allowEscapeKey: boolean;
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 2.1 MiB

View file

@ -0,0 +1,124 @@
import { DebugAction } from '@typings/events'
import { toggleVisible } from './visibility'
import { ID_INFO, ID_TYPES } from '@stores/stores'
import { DebugEventSend } from '@utils/eventsHandlers'
import { Receive } from '@enums/events'
import { TIDTypes } from '@typings/id'
/**
* The initial debug actions to run on startup
*/
const InitDebug: DebugAction[] = [
{
label: 'Visible',
action: ()=> toggleVisible(true),
delay: 500,
},
{
label: 'Init Info',
action: ()=> {
DebugEventSend(Receive.cardData, {
id: '123456',
dob: '01/01/1970',
firstName: 'John',
lastName: 'Doe',
sex: 'M',
idType: 'weapon_license',
imageURL: 'https://imgur.com/2nL5VV8.png'
})
},
delay: 1,
},
{
label: 'ID Configs',
action: () => {
const types: TIDTypes = {
driver_license: {
type: 'driver_license',
title: 'SAN ANDREAS',
titleColour: '#bdbdbd',
label: 'DRIVER LICENSE',
stamp: true,
profileStamp: false,
signature: true,
bgColour: '#000',
bgColourSecondary: '#000',
textColour: '#FFF',
},
weapon_license: {
type: 'weapon_license',
title: 'SAN ANDREAS',
titleColour: '#ff4538',
label: 'WEAPON LICENSE',
stamp: true,
profileStamp: false,
signature: true,
bgColour: '#460000',
bgColourSecondary: '#E90000',
textColour: '#FFF',
},
female_id: {
type: 'female_id',
title: 'SAN ANDREAS',
titleColour: '#F97C81',
label: 'ID CARD',
stamp: true,
profileStamp: true,
signature: true,
bgColour: '#f1e6db',
bgColourSecondary: '#ff75bc',
textColour: '#323443',
},
male_id: {
type: 'male_id',
title: 'SAN ANDREAS',
titleColour: '#89B1FF',
label: 'ID CARD',
stamp: true,
profileStamp: true,
signature: true,
bgColour: '#E5FCFF',
bgColourSecondary: '#6FCBE9',
textColour: '#323443',
},
}
DebugEventSend<TIDTypes>(Receive.config, types)
}
}
]
export default InitDebug
export function InitialiseDebugSenders(): void {
for (const debug of InitDebug) {
setTimeout(() => {
debug.action()
}, debug.delay || 0)
}
}

View file

@ -0,0 +1,44 @@
import { Send } from "@enums/events"
import { DebugEventCallback } from "@typings/events"
import { DebugEventReceive } from "@utils/eventsHandlers"
/**
* These Receivers will emulate what the client receives from the UI.
* The purpose of this is to test the UI without having to run the client.
* You are supposed to pretend to process the data you receive here and return.
*/
const ReceiveDebuggers: DebugEventCallback[] = [
{
action: Send.close,
handler: () => {
console.log('closed')
},
},
{
action: 'debug',
handler: (data: string) => {
const init = 'Emulates an NUICallback times. Process the data here.'
if (typeof data !== 'string') {
return `${init} \n The data is not a string.`
}
const reverse = data.split('').reverse().join('')
const message = `${init} \n The reverse of %c${data} %cis %c${reverse}`
return message
},
},
]
export default ReceiveDebuggers
/**
* Initialise the debug receivers
*/
export function InitialiseDebugReceivers(): void {
for (const debug of ReceiveDebuggers) {
DebugEventReceive(debug.action, debug.handler)
}
}

View file

@ -0,0 +1,25 @@
import { DebugItem } from '@typings/events'
import { toggleVisible } from './visibility'
import { Send } from '@enums/events'
import { DebugEventSend, SendEvent } from '@utils/eventsHandlers'
/**
* The debug actions that will show up in the debug menu.
*/
const SendDebuggers: DebugItem[] = [
{
label: 'Visibility',
actions: [
{
label: 'True',
action: () => toggleVisible(true),
},
{
label: 'False',
action: () => toggleVisible(false),
},
],
},
]
export default SendDebuggers

View file

@ -0,0 +1,8 @@
import { Receive } from '@enums/events'
import { DebugEventSend } from '@utils/eventsHandlers'
/**
* The debug response for the visibility debug action.
*/
export function toggleVisible(visible: boolean): void {
DebugEventSend(Receive.visible, visible)
}

View file

@ -0,0 +1,153 @@
import { get } from 'svelte/store';
import { IS_BROWSER, RESOURCE_NAME } from '../stores/stores';
import type { DebugEvent, NuiMessage } from '../typings/events';
import { onDestroy, onMount } from 'svelte';
const isBrower = get(IS_BROWSER);
const resourceName = get(RESOURCE_NAME);
const debugEventListeners: DebugEvent[] = [];
/**
* Get the current environment. Whether it's the browser or the client
*/
export const IsEnvBrowser = (): boolean => !(window as any).invokeNative;
/**
* Send an event to the Client
* @param eventName The name of the event to send
* @param data The data to send with the event
* @returns {Promise<T>} The callback response from the Client
**/
export async function SendEvent<T = any, P = any>(
eventName: string,
data: T = {} as T,
): Promise<P> {
if (isBrower == true) {
const debugReturn = await DebugEventCallback<T>(eventName, data);
return Promise.resolve(debugReturn);
}
const options = {
method: 'post',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify(data),
};
const resp: Response = await fetch(
`https://${resourceName}/${eventName}`,
options,
);
return await resp.json();
}
/**
* Listen for an event from the Client
* @param action The name of the event to listen for
* @param handler The callback to run when the event is received
* @returns {void}
**/
export function ReceiveEvent<T = unknown>(
action: string,
handler: (data: T) => void,
) {
const eventListener = (event: MessageEvent<NuiMessage<T>>) => {
const { action: eventAction, data } = event.data;
eventAction === action && handler(data);
};
// Add the event listener on mount and remove it on unmount
onMount(() => window.addEventListener('message', eventListener));
onDestroy(() => window.removeEventListener('message', eventListener));
}
/**
* Listen for an event from the Client
* YOU NEED TO BE SURE TO REMOVE THE LISTENER WHEN YOU'RE DONE WITH IT
* @param action The name of the event to listen for
* @param handler The callback to run when the event is received
* @returns {function}
**/
export function TempReceiveEvent<T = unknown>(
action: string,
handler: (data: T) => void,
): {removeListener: () => void} {
const eventListener = (event: MessageEvent<NuiMessage<T>>) => {
const { action: eventAction, data } = event.data;
eventAction === action && handler(data);
};
function removeListener() {
window.removeEventListener('message', eventListener);
}
// Add the event listener on mount and remove it on unmount
window.addEventListener('message', eventListener)
return {removeListener};
}
/**
* Emulate an event sent from the Client
* @param action The name of the event to send
* @param data The data to send with the event
* @param timer The time to wait before sending the event (in ms)
* @returns {void}
**/
export async function DebugEventSend<P>(action: string, data?: P, timer = 0) {
if (!isBrower) return;
setTimeout(() => {
const event = new MessageEvent('message', {
data: { action, data },
});
window.dispatchEvent(event);
}, timer);
}
/**
* Emulate an NUICallback in the Client
* @param action The name of the event to listen for
* @param handler The callback to run when the event is received
* @returns {void}
**/
export async function DebugEventReceive<T>(
action: string,
handler?: (data: T) => unknown,
) {
if (!isBrower) return;
if (debugEventListeners[action] !== undefined) {
console.log(
`%c[DEBUG] %c${action} %cevent already has a debug receiver.`,
'color: red; font-weight: bold;',
'color: green',
'', // Empty CSS style string to reset the color
);
return;
}
debugEventListeners[action] = handler;
}
/**
* Emulate an NUICallback in the Client
* @private
* @param action The name of the event to listen for
* @param data The data to send with the event
* @returns {Promise<T>} The callback response from the Client
*/
export async function DebugEventCallback<T>(action: string, data?: T) {
if (!isBrower) return;
const handler = debugEventListeners[action];
if (handler === undefined) {
console.log(`[DEBUG] ${action} event does not have a debugger.`);
return {};
}
const result = await handler(data);
return result;
}

View file

@ -0,0 +1,77 @@
import { Receive, Send } from "@enums/events"
import { DebugEventCallback } from "@typings/events"
import { ReceiveEvent, SendEvent } from "./eventsHandlers"
import { convertImage } from "./txdToBase64"
import { TIDInfo, TIDTypes } from "@typings/id"
import { ID_INFO, ID_TYPE, ID_TYPES } from "@stores/stores"
import { get } from "svelte/store"
const AlwaysListened: DebugEventCallback[] = [
{
action: Receive.cardData,
handler: (data: TIDInfo) => {
if (!data) {
ID_INFO.set(null);
return;
}
const idType = data.idType
if (!idType) {
console.error('No ID Type found in card types config.');
return;
};
const idTypes = get(ID_TYPES);
data.imageURL = data.imageURL.includes("data:image/png;base64") ? data.imageURL : 'nui://bl_idcard/web/mugshots/' + data.imageURL + '.png'
if (!idTypes) {
console.error('No ID Types config.');
return;
}
const idTypeConfig = idTypes[idType];
if (!idTypeConfig) {
console.error(`No ID Type config for ${idType}.`);
return;
}
const docStyles = document.documentElement.style;
// set css variables
docStyles.setProperty('--text', idTypeConfig.textColour);
docStyles.setProperty('--title', idTypeConfig.titleColour);
docStyles.setProperty('--bg', idTypeConfig.bgColour);
docStyles.setProperty('--bg-secondary', idTypeConfig.bgColourSecondary);
ID_TYPE.set(idTypeConfig);
ID_INFO.set(data);
}
},
{
action: Receive.requestBaseUrl,
handler: async (txd: string) => {
const baseUrl = await convertImage(txd);
SendEvent(Send.resolveBaseUrl, baseUrl);
}
},
{
action: Receive.config,
handler: (data: TIDTypes) => {
ID_TYPES.set(data);
}
}
]
export default AlwaysListened
export function InitialiseListen() {
for (const debug of AlwaysListened) {
ReceiveEvent(debug.action, debug.handler);
}
}

View file

@ -0,0 +1,29 @@
export async function convertImage( //https://github.com/BaziForYou/MugShotBase64
txd: string,
outputFormat: string = 'image/png'
): Promise<string> {
return new Promise<string>((resolve, reject) => {
const img = new Image();
img.crossOrigin = 'Anonymous';
img.onload = async () => {
try {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
if (!ctx) {
throw new Error('Failed to get 2D context.');
}
canvas.height = img.naturalHeight;
canvas.width = img.naturalWidth;
ctx.drawImage(img, 0, 0);
resolve(canvas.toDataURL(outputFormat));
canvas.remove();
} catch (error) {
reject(error);
} finally {
img.remove();
}
};
img.onerror = () => reject(new Error('Failed to load image.'));
img.src = `https://nui-img/${txd}/${txd}`;
});
}

Some files were not shown because too many files have changed in this diff Show more