ed
This commit is contained in:
parent
875c8448e1
commit
c81ae4bb6d
219 changed files with 8036 additions and 7 deletions
2
resources/[tools]/bl_bridge/.gitattributes
vendored
Normal file
2
resources/[tools]/bl_bridge/.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
674
resources/[tools]/bl_bridge/LICENSE
Normal file
674
resources/[tools]/bl_bridge/LICENSE
Normal 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>.
|
43
resources/[tools]/bl_bridge/README.md
Normal file
43
resources/[tools]/bl_bridge/README.md
Normal 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',
|
||||
```
|
||||
|
49
resources/[tools]/bl_bridge/_types.lua
Normal file
49
resources/[tools]/bl_bridge/_types.lua
Normal 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;
|
27
resources/[tools]/bl_bridge/client/context/ox.lua
Normal file
27
resources/[tools]/bl_bridge/client/context/ox.lua
Normal 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
|
66
resources/[tools]/bl_bridge/client/context/qb.lua
Normal file
66
resources/[tools]/bl_bridge/client/context/qb.lua
Normal 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
|
63
resources/[tools]/bl_bridge/client/core/esx.lua
Normal file
63
resources/[tools]/bl_bridge/client/core/esx.lua
Normal 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
|
74
resources/[tools]/bl_bridge/client/core/nd.lua
Normal file
74
resources/[tools]/bl_bridge/client/core/nd.lua
Normal 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
|
69
resources/[tools]/bl_bridge/client/core/ox.lua
Normal file
69
resources/[tools]/bl_bridge/client/core/ox.lua
Normal 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
|
71
resources/[tools]/bl_bridge/client/core/qb.lua
Normal file
71
resources/[tools]/bl_bridge/client/core/qb.lua
Normal 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
|
69
resources/[tools]/bl_bridge/client/core/qbx.lua
Normal file
69
resources/[tools]/bl_bridge/client/core/qbx.lua
Normal 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
|
75
resources/[tools]/bl_bridge/client/inventory/all.lua
Normal file
75
resources/[tools]/bl_bridge/client/inventory/all.lua
Normal 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
|
10
resources/[tools]/bl_bridge/client/notify/esx.lua
Normal file
10
resources/[tools]/bl_bridge/client/notify/esx.lua
Normal 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
|
8
resources/[tools]/bl_bridge/client/notify/ox.lua
Normal file
8
resources/[tools]/bl_bridge/client/notify/ox.lua
Normal 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
|
10
resources/[tools]/bl_bridge/client/notify/qb.lua
Normal file
10
resources/[tools]/bl_bridge/client/notify/qb.lua
Normal 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
|
28
resources/[tools]/bl_bridge/client/progressbar/ox.lua
Normal file
28
resources/[tools]/bl_bridge/client/progressbar/ox.lua
Normal 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
|
52
resources/[tools]/bl_bridge/client/progressbar/qb.lua
Normal file
52
resources/[tools]/bl_bridge/client/progressbar/qb.lua
Normal 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
|
28
resources/[tools]/bl_bridge/client/radial/ox.lua
Normal file
28
resources/[tools]/bl_bridge/client/radial/ox.lua
Normal 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
|
74
resources/[tools]/bl_bridge/client/radial/qb.lua
Normal file
74
resources/[tools]/bl_bridge/client/radial/qb.lua
Normal 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
|
177
resources/[tools]/bl_bridge/client/target/ox.lua
Normal file
177
resources/[tools]/bl_bridge/client/target/ox.lua
Normal 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
|
204
resources/[tools]/bl_bridge/client/target/qb.lua
Normal file
204
resources/[tools]/bl_bridge/client/target/qb.lua
Normal 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
|
23
resources/[tools]/bl_bridge/client/textui/esx.lua
Normal file
23
resources/[tools]/bl_bridge/client/textui/esx.lua
Normal 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
|
19
resources/[tools]/bl_bridge/client/textui/ox.lua
Normal file
19
resources/[tools]/bl_bridge/client/textui/ox.lua
Normal 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
|
24
resources/[tools]/bl_bridge/client/textui/qb.lua
Normal file
24
resources/[tools]/bl_bridge/client/textui/qb.lua
Normal 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
|
20
resources/[tools]/bl_bridge/fxmanifest.lua
Normal file
20
resources/[tools]/bl_bridge/fxmanifest.lua
Normal 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',
|
||||
}
|
8
resources/[tools]/bl_bridge/imports/client.lua
Normal file
8
resources/[tools]/bl_bridge/imports/client.lua
Normal 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
|
||||
})
|
8
resources/[tools]/bl_bridge/imports/server.lua
Normal file
8
resources/[tools]/bl_bridge/imports/server.lua
Normal 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
|
||||
})
|
159
resources/[tools]/bl_bridge/init.lua
Normal file
159
resources/[tools]/bl_bridge/init.lua
Normal 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
|
147
resources/[tools]/bl_bridge/require.lua
Normal file
147
resources/[tools]/bl_bridge/require.lua
Normal 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
|
139
resources/[tools]/bl_bridge/server/core/esx.lua
Normal file
139
resources/[tools]/bl_bridge/server/core/esx.lua
Normal 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
|
134
resources/[tools]/bl_bridge/server/core/nd.lua
Normal file
134
resources/[tools]/bl_bridge/server/core/nd.lua
Normal 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
|
243
resources/[tools]/bl_bridge/server/core/ox.lua
Normal file
243
resources/[tools]/bl_bridge/server/core/ox.lua
Normal 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
|
151
resources/[tools]/bl_bridge/server/core/qb.lua
Normal file
151
resources/[tools]/bl_bridge/server/core/qb.lua
Normal 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
|
134
resources/[tools]/bl_bridge/server/core/qbx.lua
Normal file
134
resources/[tools]/bl_bridge/server/core/qbx.lua
Normal 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
|
29
resources/[tools]/bl_bridge/server/inventory/esx.lua
Normal file
29
resources/[tools]/bl_bridge/server/inventory/esx.lua
Normal 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
|
67
resources/[tools]/bl_bridge/server/inventory/origen.lua
Normal file
67
resources/[tools]/bl_bridge/server/inventory/origen.lua
Normal 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
|
73
resources/[tools]/bl_bridge/server/inventory/ox.lua
Normal file
73
resources/[tools]/bl_bridge/server/inventory/ox.lua
Normal 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
|
118
resources/[tools]/bl_bridge/server/inventory/qb.lua
Normal file
118
resources/[tools]/bl_bridge/server/inventory/qb.lua
Normal 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
|
93
resources/[tools]/bl_bridge/server/inventory/qs.lua
Normal file
93
resources/[tools]/bl_bridge/server/inventory/qs.lua
Normal 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
|
11
resources/[tools]/bl_bridge/server/notify/esx.lua
Normal file
11
resources/[tools]/bl_bridge/server/notify/esx.lua
Normal 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
|
9
resources/[tools]/bl_bridge/server/notify/ox.lua
Normal file
9
resources/[tools]/bl_bridge/server/notify/ox.lua
Normal 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
|
11
resources/[tools]/bl_bridge/server/notify/qb.lua
Normal file
11
resources/[tools]/bl_bridge/server/notify/qb.lua
Normal 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
|
290
resources/[tools]/bl_bridge/utils.lua
Normal file
290
resources/[tools]/bl_bridge/utils.lua
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue