From b8411cc92c871c37e66056a55e3f925a87507fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20N=27gadi?= Date: Sun, 13 Aug 2017 17:16:29 +0200 Subject: [PATCH 01/64] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..b092e439 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# fxserver-esx_shops +FXServer ESX Shops From 3afa93d090a56fccc6ee69a3a8b88f0aba3a5899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20N=27gadi?= Date: Sun, 13 Aug 2017 17:17:23 +0200 Subject: [PATCH 02/64] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index b092e439..1bfeb057 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ # fxserver-esx_shops FXServer ESX Shops + +[INSTALLATION] + +1) CD in your resources/[esx] folder +2) Clone the repository +``` +git clone https://github.com/FXServer-ESX/fxserver-esx_shops esx_shops +``` +3) Import esx_shops.sql in your database +4) Add this in your server.cfg : + +``` +start esx_shops +``` From 7080f8b5b68af8da55cb24f4bf7ca8128495d738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20N=27gadi?= Date: Sun, 13 Aug 2017 17:21:04 +0200 Subject: [PATCH 03/64] Add files --- LICENSE.txt | 674 ++++++++++++++++++++++++++++++++++++++++++++++++ __resource.lua | 12 + client/main.lua | 163 ++++++++++++ config.lua | 49 ++++ esx_shops.sql | 20 ++ server/main.lua | 69 +++++ 6 files changed, 987 insertions(+) create mode 100644 LICENSE.txt create mode 100644 __resource.lua create mode 100644 client/main.lua create mode 100644 config.lua create mode 100644 esx_shops.sql create mode 100644 server/main.lua diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..30ace6a8 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + 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 . + +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: + + {project} Copyright (C) {year} {fullname} + 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 +. + + 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 +. \ No newline at end of file diff --git a/__resource.lua b/__resource.lua new file mode 100644 index 00000000..47caca54 --- /dev/null +++ b/__resource.lua @@ -0,0 +1,12 @@ +description 'ESX Mecano Job' + +client_scripts { + 'config.lua', + 'client/main.lua' +} + +server_scripts { + '@mysql-async/lib/MySQL.lua', + 'config.lua', + 'server/main.lua' +} \ No newline at end of file diff --git a/client/main.lua b/client/main.lua new file mode 100644 index 00000000..fe65c57f --- /dev/null +++ b/client/main.lua @@ -0,0 +1,163 @@ +ESX = nil +local HasAlreadyEnteredMarker = false +local LastZone = nil +local CurrentAction = nil +local CurrentActionMsg = '' +local CurrentActionData = {} + +Citizen.CreateThread(function() + while ESX == nil do + TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + Citizen.Wait(0) + end +end) + +AddEventHandler('onClientMapStart', function() + + ESX.TriggerServerCallback('esx_shop:requestDBItems', function(ShopItems) + for k,v in pairs(ShopItems) do + Config.Zones[k].Items = v + end + end) + +end) + +function OpenShopMenu(zone) + + local elements = {} + + for i=1, #Config.Zones[zone].Items, 1 do + + local item = Config.Zones[zone].Items[i] + + table.insert(elements, { + label = item.label .. ' - $' .. item.price .. ' ', + realLabel = item.label, + value = item.name, + price = item.price + }) + + end + + + ESX.UI.Menu.CloseAll() + + ESX.UI.Menu.Open( + 'default', GetCurrentResourceName(), 'shop', + { + title = 'Magasin', + elements = elements + }, + function(data, menu) + TriggerServerEvent('esx_shop:buyItem', data.current.value, data.current.price) + end, + function(data, menu) + + menu.close() + + CurrentAction = 'shop_menu' + CurrentActionMsg = 'Appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.' + CurrentActionData = {zone = zone} + end + ) +end + +AddEventHandler('esx_shop:hasEnteredMarker', function(zone) + + CurrentAction = 'shop_menu' + CurrentActionMsg = 'Appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.' + CurrentActionData = {zone = zone} + +end) + +AddEventHandler('esx_shop:hasExitedMarker', function(zone) + + CurrentAction = nil + ESX.UI.Menu.CloseAll() + +end) + +-- Create Blips +Citizen.CreateThread(function() + for k,v in pairs(Config.Zones) do + for i = 1, #v.Pos, 1 do + local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z) + SetBlipSprite (blip, 52) + SetBlipDisplay(blip, 4) + SetBlipScale (blip, 1.0) + SetBlipColour (blip, 2) + SetBlipAsShortRange(blip, true) + BeginTextCommandSetBlipName("STRING") + AddTextComponentString("Magasins") + EndTextCommandSetBlipName(blip) + end + end +end) + +-- Display markers +Citizen.CreateThread(function() + while true do + Wait(0) + local coords = GetEntityCoords(GetPlayerPed(-1)) + for k,v in pairs(Config.Zones) do + for i = 1, #v.Pos, 1 do + if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then + DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false) + end + end + end + end +end) + +-- Enter / Exit marker events +Citizen.CreateThread(function() + while true do + Wait(0) + local coords = GetEntityCoords(GetPlayerPed(-1)) + local isInMarker = false + local currentZone = nil + + for k,v in pairs(Config.Zones) do + for i = 1, #v.Pos, 1 do + if(GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.Size.x) then + isInMarker = true + ShopItems = v.Items + currentZone = k + LastZone = k + end + end + end + if isInMarker and not HasAlreadyEnteredMarker then + HasAlreadyEnteredMarker = true + TriggerEvent('esx_shop:hasEnteredMarker', currentZone) + end + if not isInMarker and HasAlreadyEnteredMarker then + HasAlreadyEnteredMarker = false + TriggerEvent('esx_shop:hasExitedMarker', LastZone) + end + end +end) + +-- Key Controls +Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + if CurrentAction ~= nil then + + SetTextComponentFormat('STRING') + AddTextComponentString(CurrentActionMsg) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) + + if IsControlJustReleased(0, 38) then + + if CurrentAction == 'shop_menu' then + OpenShopMenu(CurrentActionData.zone) + end + + CurrentAction = nil + + end + + end + end +end) \ No newline at end of file diff --git a/config.lua b/config.lua new file mode 100644 index 00000000..6c7dd251 --- /dev/null +++ b/config.lua @@ -0,0 +1,49 @@ +Config = {} + +Config.DrawDistance = 100 +Config.Size = {x = 1.5, y = 1.5, z = 1.5} +Config.Color = {r = 0, g = 128, b = 255} +Config.Type = 1 + +Config.Zones = { + + TwentyFourSeven = { + Items = {}, + Pos = { + {x = 373.875, y = 325.896, z = 102.566}, + {x = 2557.458, y = 382.282, z = 107.622}, + {x = -3038.939, y = 585.954, z = 6.908}, + {x = -3241.927, y = 1001.462, z = 11.830}, + {x = 547.431, y = 2671.710, z = 41.156}, + {x = 1961.464, y = 3740.672, z = 31.343}, + {x = 2678.916, y = 3280.671, z = 54.241}, + {x = 1729.216, y = 6414.131, z = 34.037} + } + }, + + RobsLiquor = { + Items = {}, + Pos = { + {x = 1135.808, y = -982.281, z = 45.415}, + {x = -1222.915, y = -906.983, z = 11.326}, + {x = -1487.553, y = -379.107, z = 39.163}, + {x = -2968.243, y = 390.910, z = 14.043}, + {x = 1166.024, y = 2708.930, z = 37.157}, + {x = 1392.562, y = 3604.684, z = 33.980}, + {x = 127.830, y = -1284.796, z = 29.280}, --StripClub + {x = -1393.409, y = -606.624, z = 30.319}, --Tequila la + {x = -559.906, y = 287.093, z = 82.176} --Bahamamas + } + }, + + LTDgasoline = { + Items = {}, + Pos = { + {x = -48.519, y = -1757.514, z = 28.421}, + {x = 1163.373, y = -323.801, z = 68.205}, + {x = -707.501, y = -914.260, z = 18.215}, + {x = -1820.523, y = 792.518, z = 137.118}, + {x = 1698.388, y = 4924.404, z = 41.063} + } + } +} \ No newline at end of file diff --git a/esx_shops.sql b/esx_shops.sql new file mode 100644 index 00000000..b9f72161 --- /dev/null +++ b/esx_shops.sql @@ -0,0 +1,20 @@ +USE `essentialmode`; + +CREATE TABLE `shops` ( + + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `item` varchar(255) NOT NULL, + `price` int(11) NOT NULL, + + PRIMARY KEY (`id`) +); + +INSERT INTO `shops` (name, item, price) VALUES + ('TwentyFourSeven','bread',30), + ('TwentyFourSeven','water',15), + ('RobsLiquor','bread',30), + ('RobsLiquor','water',15), + ('LTDgasoline','bread',30), + ('LTDgasoline','water',15) +; \ No newline at end of file diff --git a/server/main.lua b/server/main.lua new file mode 100644 index 00000000..9d80efbe --- /dev/null +++ b/server/main.lua @@ -0,0 +1,69 @@ +ESX = nil +local ItemsLabels = {} + +TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + +AddEventHandler('onMySQLReady', function() + + MySQL.Async.fetchAll( + 'SELECT * FROM items', + {}, + function(result) + + for i=1, #result, 1 do + ItemsLabels[result[i].name] = result[i].label + end-- + + end + ) + +end) + +ESX.RegisterServerCallback('esx_shop:requestDBItems', function(source, cb) + + MySQL.Async.fetchAll( + 'SELECT * FROM shops', + {}, + function(result) + + local shopItems = {} + + for i=1, #result, 1 do + + if shopItems[result[i].name] == nil then + shopItems[result[i].name] = {} + end + + table.insert(shopItems[result[i].name], { + name = result[i].item, + price = result[i].price, + label = ItemsLabels[result[i].item] + }) + + end + + cb(shopItems) + + end + ) + +end) + +RegisterServerEvent('esx_shop:buyItem') +AddEventHandler('esx_shop:buyItem', function(itemName, price) + + local _source = source + local xPlayer = ESX.GetPlayerFromId(source) + + if xPlayer.get('money') >= price then + + xPlayer.removeMoney(price) + xPlayer.addInventoryItem(itemName, 1) + + TriggerClientEvent('esx:showNotification', _source, 'Vous avez acheté ~b~1x ' .. ItemsLabels[itemName]) + + else + TriggerClientEvent('esx:showNotification', _source, 'Vous n\'avez ~r~pas assez~s~ d\'argent.') + end + +end) From 8ac2871af9875f78178ba36523caa45024689d62 Mon Sep 17 00:00:00 2001 From: nearbyplayer Date: Tue, 15 Aug 2017 21:38:47 -0400 Subject: [PATCH 04/64] Multi-language support --- __resource.lua | 10 ++++++++-- client/main.lua | 42 +++++++++++++++++++++--------------------- config.lua | 5 +++-- locales/en.lua | 9 +++++++++ locales/fr.lua | 9 +++++++++ server/main.lua | 12 ++++++------ 6 files changed, 56 insertions(+), 31 deletions(-) create mode 100644 locales/en.lua create mode 100644 locales/fr.lua diff --git a/__resource.lua b/__resource.lua index 47caca54..539fbeb3 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,12 +1,18 @@ -description 'ESX Mecano Job' +description 'ESX Shops' client_scripts { + '@es_extended/locale.lua', + 'locales/en.lua', + 'locales/fr.lua', 'config.lua', 'client/main.lua' } server_scripts { + '@es_extended/locale.lua', + 'locales/en.lua', + 'locales/fr.lua', '@mysql-async/lib/MySQL.lua', 'config.lua', 'server/main.lua' -} \ No newline at end of file +} diff --git a/client/main.lua b/client/main.lua index fe65c57f..733a499c 100644 --- a/client/main.lua +++ b/client/main.lua @@ -4,7 +4,7 @@ local LastZone = nil local CurrentAction = nil local CurrentActionMsg = '' local CurrentActionData = {} - + Citizen.CreateThread(function() while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) @@ -13,7 +13,7 @@ Citizen.CreateThread(function() end) AddEventHandler('onClientMapStart', function() - + ESX.TriggerServerCallback('esx_shop:requestDBItems', function(ShopItems) for k,v in pairs(ShopItems) do Config.Zones[k].Items = v @@ -45,27 +45,27 @@ function OpenShopMenu(zone) ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'shop', { - title = 'Magasin', + title = _U('shop'), elements = elements }, - function(data, menu) + function(data, menu) TriggerServerEvent('esx_shop:buyItem', data.current.value, data.current.price) end, function(data, menu) - + menu.close() - + CurrentAction = 'shop_menu' - CurrentActionMsg = 'Appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.' + CurrentActionMsg = _U('press_menu') CurrentActionData = {zone = zone} end ) end AddEventHandler('esx_shop:hasEnteredMarker', function(zone) - + CurrentAction = 'shop_menu' - CurrentActionMsg = 'Appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.' + CurrentActionMsg = _U('press_menu') CurrentActionData = {zone = zone} end) @@ -88,7 +88,7 @@ Citizen.CreateThread(function() SetBlipColour (blip, 2) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") - AddTextComponentString("Magasins") + AddTextComponentString(_U('shops')) EndTextCommandSetBlipName(blip) end end @@ -96,15 +96,15 @@ end) -- Display markers Citizen.CreateThread(function() - while true do + while true do Wait(0) - local coords = GetEntityCoords(GetPlayerPed(-1)) + local coords = GetEntityCoords(GetPlayerPed(-1)) for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false) end - end + end end end end) @@ -143,21 +143,21 @@ Citizen.CreateThread(function() while true do Citizen.Wait(0) if CurrentAction ~= nil then - + SetTextComponentFormat('STRING') AddTextComponentString(CurrentActionMsg) DisplayHelpTextFromStringLabel(0, 0, 1, -1) - - if IsControlJustReleased(0, 38) then - + + if IsControlJustReleased(0, 38) then + if CurrentAction == 'shop_menu' then OpenShopMenu(CurrentActionData.zone) end - - CurrentAction = nil - + + CurrentAction = nil + end end end -end) \ No newline at end of file +end) diff --git a/config.lua b/config.lua index 6c7dd251..8fbe526e 100644 --- a/config.lua +++ b/config.lua @@ -4,6 +4,7 @@ Config.DrawDistance = 100 Config.Size = {x = 1.5, y = 1.5, z = 1.5} Config.Color = {r = 0, g = 128, b = 255} Config.Type = 1 +Config.Locale = 'fr' Config.Zones = { @@ -35,7 +36,7 @@ Config.Zones = { {x = -559.906, y = 287.093, z = 82.176} --Bahamamas } }, - + LTDgasoline = { Items = {}, Pos = { @@ -46,4 +47,4 @@ Config.Zones = { {x = 1698.388, y = 4924.404, z = 41.063} } } -} \ No newline at end of file +} diff --git a/locales/en.lua b/locales/en.lua new file mode 100644 index 00000000..35ff8cd0 --- /dev/null +++ b/locales/en.lua @@ -0,0 +1,9 @@ +Locales['en'] = { + + ['shop'] = 'shop', + ['shops'] = 'shops', + ['press_menu'] = 'press ~INPUT_CONTEXT~ to access the store.', + ['bought'] = 'you bought ~b~1x ', + ['not_enough'] = 'you do not ~r~have enough~s~ money.' + +} diff --git a/locales/fr.lua b/locales/fr.lua new file mode 100644 index 00000000..14e9ca67 --- /dev/null +++ b/locales/fr.lua @@ -0,0 +1,9 @@ +Locales['fr'] = { + + ['shop'] = 'magasin', + ['shops'] = 'magasins', + ['press_menu'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.', + ['bought'] = 'vous avez acheté ~b~1x ', + ['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent.', + +} diff --git a/server/main.lua b/server/main.lua index 9d80efbe..4ef9dfcb 100644 --- a/server/main.lua +++ b/server/main.lua @@ -9,10 +9,10 @@ AddEventHandler('onMySQLReady', function() 'SELECT * FROM items', {}, function(result) - + for i=1, #result, 1 do ItemsLabels[result[i].name] = result[i].label - end-- + end-- end ) @@ -25,7 +25,7 @@ ESX.RegisterServerCallback('esx_shop:requestDBItems', function(source, cb) 'SELECT * FROM shops', {}, function(result) - + local shopItems = {} for i=1, #result, 1 do @@ -51,7 +51,7 @@ end) RegisterServerEvent('esx_shop:buyItem') AddEventHandler('esx_shop:buyItem', function(itemName, price) - + local _source = source local xPlayer = ESX.GetPlayerFromId(source) @@ -60,10 +60,10 @@ AddEventHandler('esx_shop:buyItem', function(itemName, price) xPlayer.removeMoney(price) xPlayer.addInventoryItem(itemName, 1) - TriggerClientEvent('esx:showNotification', _source, 'Vous avez acheté ~b~1x ' .. ItemsLabels[itemName]) + TriggerClientEvent('esx:showNotification', _source, _U('bought') .. ItemsLabels[itemName]) else - TriggerClientEvent('esx:showNotification', _source, 'Vous n\'avez ~r~pas assez~s~ d\'argent.') + TriggerClientEvent('esx:showNotification', _source, _U('not_enough')) end end) From c521b15ed6e40ca370610e15661a036f734975f9 Mon Sep 17 00:00:00 2001 From: TakumiBR <31086346+TakumiBR@users.noreply.github.com> Date: Thu, 17 Aug 2017 08:27:27 -0700 Subject: [PATCH 05/64] Multi-language support Brazilian Portuguese translation. --- __resource.lua | 2 ++ locales/br.lua | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 locales/br.lua diff --git a/__resource.lua b/__resource.lua index 539fbeb3..def8a634 100644 --- a/__resource.lua +++ b/__resource.lua @@ -2,6 +2,7 @@ description 'ESX Shops' client_scripts { '@es_extended/locale.lua', + 'locales/br.lua', 'locales/en.lua', 'locales/fr.lua', 'config.lua', @@ -10,6 +11,7 @@ client_scripts { server_scripts { '@es_extended/locale.lua', + 'locales/br.lua', 'locales/en.lua', 'locales/fr.lua', '@mysql-async/lib/MySQL.lua', diff --git a/locales/br.lua b/locales/br.lua new file mode 100644 index 00000000..a24a0645 --- /dev/null +++ b/locales/br.lua @@ -0,0 +1,9 @@ +Locales['br'] = { + + ['shop'] = 'Comprar', + ['shops'] = 'Lojas', + ['press_menu'] = 'Pressione ~INPUT_CONTEXT~ para acessar a loja.', + ['bought'] = 'você comprou ~b~1x ', + ['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~.' + +} From c51909fed7bb9ef03320c0235bc77de758bf7143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20N=27gadi?= Date: Thu, 24 Aug 2017 10:06:47 +0200 Subject: [PATCH 06/64] Fix marker positions --- config.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.lua b/config.lua index 8fbe526e..43d7bbed 100644 --- a/config.lua +++ b/config.lua @@ -31,9 +31,9 @@ Config.Zones = { {x = -2968.243, y = 390.910, z = 14.043}, {x = 1166.024, y = 2708.930, z = 37.157}, {x = 1392.562, y = 3604.684, z = 33.980}, - {x = 127.830, y = -1284.796, z = 29.280}, --StripClub - {x = -1393.409, y = -606.624, z = 30.319}, --Tequila la - {x = -559.906, y = 287.093, z = 82.176} --Bahamamas + {x = 127.830, y = -1284.796, z = 28.280}, --StripClub + {x = -1393.409, y = -606.624, z = 29.319}, --Tequila la + {x = -559.906, y = 287.093, z = 81.176} --Bahamamas } }, From 26c2a684b2ad8ad16ad9b290b0cbe75dae284ad7 Mon Sep 17 00:00:00 2001 From: ultratm Date: Sat, 26 Aug 2017 12:16:45 +0200 Subject: [PATCH 07/64] Add German Language --- __resource.lua | 2 ++ locales/de.lua | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 locales/de.lua diff --git a/__resource.lua b/__resource.lua index def8a634..c38cbe63 100644 --- a/__resource.lua +++ b/__resource.lua @@ -2,6 +2,7 @@ description 'ESX Shops' client_scripts { '@es_extended/locale.lua', + 'locales/de.lua', 'locales/br.lua', 'locales/en.lua', 'locales/fr.lua', @@ -11,6 +12,7 @@ client_scripts { server_scripts { '@es_extended/locale.lua', + 'locales/de.lua', 'locales/br.lua', 'locales/en.lua', 'locales/fr.lua', diff --git a/locales/de.lua b/locales/de.lua new file mode 100644 index 00000000..c34fd81c --- /dev/null +++ b/locales/de.lua @@ -0,0 +1,9 @@ +Locales['de'] = { + + ['shop'] = 'Geschäft', + ['shops'] = 'Geschäfte', + ['press_menu'] = 'Drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', + ['bought'] = 'du kaufst ~b~1x ', + ['not_enough'] = 'du ~r~hast nicht~s~ genug Geld.' + +} From da69a6327f4d851862dd9ee55bd17cb4135b83f5 Mon Sep 17 00:00:00 2001 From: Coro Veneno Date: Tue, 12 Sep 2017 22:45:54 +0200 Subject: [PATCH 08/64] Create es.lua Added Spanish Language Multi-Language --- locales/es.lua | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 locales/es.lua diff --git a/locales/es.lua b/locales/es.lua new file mode 100644 index 00000000..d25088fd --- /dev/null +++ b/locales/es.lua @@ -0,0 +1,9 @@ +Locales['es'] = { + + ['shop'] = 'Tienda', + ['shops'] = 'Tiendas', + ['press_menu'] = 'Presiona ~INPUT_CONTEXT~ para acceder a la tienda.', + ['bought'] = 'Has comprado ~b~1 ', + ['not_enough'] = 'No tienes ~r~suficiente ~s~ dinero.', + +} From 885049ebcd0521826e2f9fec078e638215d2fd02 Mon Sep 17 00:00:00 2001 From: Coro Veneno Date: Tue, 12 Sep 2017 23:03:58 +0200 Subject: [PATCH 09/64] Update Spanish Language Added Spanish Language --- __resource.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/__resource.lua b/__resource.lua index c38cbe63..75a684e5 100644 --- a/__resource.lua +++ b/__resource.lua @@ -6,6 +6,7 @@ client_scripts { 'locales/br.lua', 'locales/en.lua', 'locales/fr.lua', + 'locales/es.lua', 'config.lua', 'client/main.lua' } @@ -16,6 +17,7 @@ server_scripts { 'locales/br.lua', 'locales/en.lua', 'locales/fr.lua', + 'locales/es.lua', '@mysql-async/lib/MySQL.lua', 'config.lua', 'server/main.lua' From 9f2f7862b18a682755268232645bf812d63bb242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20N=27gadi?= Date: Thu, 14 Sep 2017 23:18:27 +0200 Subject: [PATCH 10/64] Update LICENSE.txt --- LICENSE.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 30ace6a8..36cb0ed1 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -631,8 +631,8 @@ 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} + fxserver-esx_shops + Copyright (C) 2015 Jérémie N'gadi 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 @@ -652,7 +652,7 @@ 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: - {project} Copyright (C) {year} {fullname} + fxserver-esx_shops Copyright (C) 2015 Jérémie N'gadi 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. From f52ba735a3b69135307dd85fc8f9f7803dab6750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20N=27gadi?= Date: Fri, 15 Sep 2017 15:40:36 +0200 Subject: [PATCH 11/64] chore(resource): Add version --- __resource.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/__resource.lua b/__resource.lua index 75a684e5..3678f2ab 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,5 +1,7 @@ description 'ESX Shops' +version '1.0.0' + client_scripts { '@es_extended/locale.lua', 'locales/de.lua', From e02629fa4e7d31164cd4efac918a3ce492d5300b Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Thu, 5 Apr 2018 12:40:58 +0200 Subject: [PATCH 12/64] Fixed having more than you can carry, closes #9 - Translation improvements with formatting - General improvements --- client/main.lua | 23 ++++++++--------------- config.lua | 2 +- locales/en.lua | 11 +++++------ server/main.lua | 36 ++++++++++++++++++------------------ 4 files changed, 32 insertions(+), 40 deletions(-) diff --git a/client/main.lua b/client/main.lua index 733a499c..69db5031 100644 --- a/client/main.lua +++ b/client/main.lua @@ -23,38 +23,31 @@ AddEventHandler('onClientMapStart', function() end) function OpenShopMenu(zone) - local elements = {} - for i=1, #Config.Zones[zone].Items, 1 do - + local item = Config.Zones[zone].Items[i] - table.insert(elements, { - label = item.label .. ' - $' .. item.price .. ' ', + label = item.label .. ' - ' .. item.price .. '$', realLabel = item.label, value = item.name, price = item.price }) - end - ESX.UI.Menu.CloseAll() - ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'shop', { - title = _U('shop'), + title = _U('shop'), + align = 'bottom-right', elements = elements }, function(data, menu) TriggerServerEvent('esx_shop:buyItem', data.current.value, data.current.price) end, function(data, menu) - menu.close() - CurrentAction = 'shop_menu' CurrentActionMsg = _U('press_menu') CurrentActionData = {zone = zone} @@ -97,7 +90,7 @@ end) -- Display markers Citizen.CreateThread(function() while true do - Wait(0) + Citizen.Wait(10) local coords = GetEntityCoords(GetPlayerPed(-1)) for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do @@ -112,7 +105,7 @@ end) -- Enter / Exit marker events Citizen.CreateThread(function() while true do - Wait(0) + Citizen.Wait(10) local coords = GetEntityCoords(GetPlayerPed(-1)) local isInMarker = false local currentZone = nil @@ -141,7 +134,7 @@ end) -- Key Controls Citizen.CreateThread(function() while true do - Citizen.Wait(0) + Citizen.Wait(10) if CurrentAction ~= nil then SetTextComponentFormat('STRING') @@ -160,4 +153,4 @@ Citizen.CreateThread(function() end end -end) +end) \ No newline at end of file diff --git a/config.lua b/config.lua index 43d7bbed..10a1f089 100644 --- a/config.lua +++ b/config.lua @@ -4,7 +4,7 @@ Config.DrawDistance = 100 Config.Size = {x = 1.5, y = 1.5, z = 1.5} Config.Color = {r = 0, g = 128, b = 255} Config.Type = 1 -Config.Locale = 'fr' +Config.Locale = 'en' Config.Zones = { diff --git a/locales/en.lua b/locales/en.lua index 35ff8cd0..f88753a4 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,9 +1,8 @@ Locales['en'] = { - ['shop'] = 'shop', ['shops'] = 'shops', - ['press_menu'] = 'press ~INPUT_CONTEXT~ to access the store.', - ['bought'] = 'you bought ~b~1x ', - ['not_enough'] = 'you do not ~r~have enough~s~ money.' - -} + ['press_menu'] = 'press ~INPUT_CONTEXT~ to access the ~y~store~s~.', + ['bought'] = 'you just bought ~y~1x~s~ ~b~%s~s~ for ~r~$%s~s~', + ['not_enough'] = 'you do not have ~r~enough~s~ money, you\'re ~y~missing~s~ ~r~$%s~s~!', + ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', +} \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index 4ef9dfcb..ffcef5c7 100644 --- a/server/main.lua +++ b/server/main.lua @@ -12,7 +12,7 @@ AddEventHandler('onMySQLReady', function() for i=1, #result, 1 do ItemsLabels[result[i].name] = result[i].label - end-- + end end ) @@ -25,25 +25,19 @@ ESX.RegisterServerCallback('esx_shop:requestDBItems', function(source, cb) 'SELECT * FROM shops', {}, function(result) - local shopItems = {} - for i=1, #result, 1 do - if shopItems[result[i].name] == nil then shopItems[result[i].name] = {} end - + table.insert(shopItems[result[i].name], { name = result[i].item, price = result[i].price, label = ItemsLabels[result[i].item] }) - end - cb(shopItems) - end ) @@ -53,17 +47,23 @@ RegisterServerEvent('esx_shop:buyItem') AddEventHandler('esx_shop:buyItem', function(itemName, price) local _source = source - local xPlayer = ESX.GetPlayerFromId(source) - - if xPlayer.get('money') >= price then - - xPlayer.removeMoney(price) - xPlayer.addInventoryItem(itemName, 1) - - TriggerClientEvent('esx:showNotification', _source, _U('bought') .. ItemsLabels[itemName]) + local xPlayer = ESX.GetPlayerFromId(_source) + local sourceItem = xPlayer.getInventoryItem(itemName) + -- can the player afford this item? + if xPlayer.getMoney() >= price then + + -- can the player carry the said amount of x item? + if sourceItem.limit ~= -1 and (sourceItem.count + 1) > sourceItem.limit then + TriggerClientEvent('esx:showNotification', _source, _U('player_cannot_hold')) + else + xPlayer.removeMoney(price) + xPlayer.addInventoryItem(itemName, 1) + TriggerClientEvent('esx:showNotification', _source, _U('bought', ItemsLabels[itemName], price)) + end else - TriggerClientEvent('esx:showNotification', _source, _U('not_enough')) + local missingMoney = price - xPlayer.getMoney() + TriggerClientEvent('esx:showNotification', _source, _U('not_enough', missingMoney)) end -end) +end) \ No newline at end of file From e9f34c5d31669c184a03b0c8583c846765fdacc4 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 9 Apr 2018 12:30:33 +0200 Subject: [PATCH 13/64] Corrected trigger names --- client/main.lua | 12 ++++++------ server/main.lua | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/client/main.lua b/client/main.lua index 69db5031..5b818efb 100644 --- a/client/main.lua +++ b/client/main.lua @@ -14,7 +14,7 @@ end) AddEventHandler('onClientMapStart', function() - ESX.TriggerServerCallback('esx_shop:requestDBItems', function(ShopItems) + ESX.TriggerServerCallback('esx_shops:requestDBItems', function(ShopItems) for k,v in pairs(ShopItems) do Config.Zones[k].Items = v end @@ -44,7 +44,7 @@ function OpenShopMenu(zone) elements = elements }, function(data, menu) - TriggerServerEvent('esx_shop:buyItem', data.current.value, data.current.price) + TriggerServerEvent('esx_shops:buyItem', data.current.value, data.current.price) end, function(data, menu) menu.close() @@ -55,7 +55,7 @@ function OpenShopMenu(zone) ) end -AddEventHandler('esx_shop:hasEnteredMarker', function(zone) +AddEventHandler('esx_shops:hasEnteredMarker', function(zone) CurrentAction = 'shop_menu' CurrentActionMsg = _U('press_menu') @@ -63,7 +63,7 @@ AddEventHandler('esx_shop:hasEnteredMarker', function(zone) end) -AddEventHandler('esx_shop:hasExitedMarker', function(zone) +AddEventHandler('esx_shops:hasExitedMarker', function(zone) CurrentAction = nil ESX.UI.Menu.CloseAll() @@ -122,11 +122,11 @@ Citizen.CreateThread(function() end if isInMarker and not HasAlreadyEnteredMarker then HasAlreadyEnteredMarker = true - TriggerEvent('esx_shop:hasEnteredMarker', currentZone) + TriggerEvent('esx_shops:hasEnteredMarker', currentZone) end if not isInMarker and HasAlreadyEnteredMarker then HasAlreadyEnteredMarker = false - TriggerEvent('esx_shop:hasExitedMarker', LastZone) + TriggerEvent('esx_shops:hasExitedMarker', LastZone) end end end) diff --git a/server/main.lua b/server/main.lua index ffcef5c7..b3544158 100644 --- a/server/main.lua +++ b/server/main.lua @@ -19,7 +19,7 @@ AddEventHandler('onMySQLReady', function() end) -ESX.RegisterServerCallback('esx_shop:requestDBItems', function(source, cb) +ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb) MySQL.Async.fetchAll( 'SELECT * FROM shops', @@ -43,11 +43,11 @@ ESX.RegisterServerCallback('esx_shop:requestDBItems', function(source, cb) end) -RegisterServerEvent('esx_shop:buyItem') -AddEventHandler('esx_shop:buyItem', function(itemName, price) +RegisterServerEvent('esx_shops:buyItem') +AddEventHandler('esx_shops:buyItem', function(itemName, price) local _source = source - local xPlayer = ESX.GetPlayerFromId(_source) + local xPlayer = ESX.GetPlayerFromId(_source) local sourceItem = xPlayer.getInventoryItem(itemName) -- can the player afford this item? From a86f4232d1717d6a1806703e54343356d995d6af Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 9 Apr 2018 12:33:27 +0200 Subject: [PATCH 14/64] Added missing manifest info, Swedish language --- __resource.lua | 6 +++++- locales/sv.lua | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 locales/sv.lua diff --git a/__resource.lua b/__resource.lua index 3678f2ab..76528017 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,6 +1,8 @@ +resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' + description 'ESX Shops' -version '1.0.0' +version '1.1.0' client_scripts { '@es_extended/locale.lua', @@ -9,6 +11,7 @@ client_scripts { 'locales/en.lua', 'locales/fr.lua', 'locales/es.lua', + 'locales/sv.lua', 'config.lua', 'client/main.lua' } @@ -20,6 +23,7 @@ server_scripts { 'locales/en.lua', 'locales/fr.lua', 'locales/es.lua', + 'locales/sv.lua', '@mysql-async/lib/MySQL.lua', 'config.lua', 'server/main.lua' diff --git a/locales/sv.lua b/locales/sv.lua new file mode 100644 index 00000000..5dfbf64b --- /dev/null +++ b/locales/sv.lua @@ -0,0 +1,8 @@ +Locales['sv'] = { + ['shop'] = 'affär', + ['shops'] = 'affärer', + ['press_menu'] = 'tryck ~INPUT_CONTEXT~ för att ~y~handla prylar~w~.', + ['bought'] = 'du har köpt ~y~1x~w~ ~b~%s~w~ för ~r~$%s~w~', + ['not_enough'] = 'du har inte ~r~tillräckligt~s~ med pengar, det ~y~saknas~w~ ~r~$%s~w~!', + ['player_cannot_hold'] = 'du har ~r~inte~w~ tillräckligt med ~y~utrymme~w~ för att hålla det!', +} \ No newline at end of file From a96e5b9c0ada3cfd257dd8c5b6b2acf339a8f17a Mon Sep 17 00:00:00 2001 From: renildomarcio Date: Tue, 10 Apr 2018 03:08:40 -0300 Subject: [PATCH 15/64] Update br.lua --- locales/br.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/locales/br.lua b/locales/br.lua index a24a0645..902206af 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -5,5 +5,6 @@ Locales['br'] = { ['press_menu'] = 'Pressione ~INPUT_CONTEXT~ para acessar a loja.', ['bought'] = 'você comprou ~b~1x ', ['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~.' + ['player_cannot_hold'] = 'Você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!', } From d43ff45bfa9882dcf2f6bf5ef1f68dc1e7fe08fe Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 30 Apr 2018 17:21:59 +0200 Subject: [PATCH 16/64] Fixed cheating exploit, empty shop bug, broken translation --- client/main.lua | 11 ++++--- config.lua | 79 ++++++++++++++++++++++++------------------------- locales/br.lua | 6 ++-- server/main.lua | 61 +++++++++++++++++++------------------- 4 files changed, 77 insertions(+), 80 deletions(-) diff --git a/client/main.lua b/client/main.lua index 5b818efb..e9392bd1 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,25 +10,24 @@ Citizen.CreateThread(function() TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(0) end -end) - -AddEventHandler('onClientMapStart', function() - + + Citizen.Wait(5000) + ESX.TriggerServerCallback('esx_shops:requestDBItems', function(ShopItems) for k,v in pairs(ShopItems) do Config.Zones[k].Items = v end end) - end) + function OpenShopMenu(zone) local elements = {} for i=1, #Config.Zones[zone].Items, 1 do local item = Config.Zones[zone].Items[i] table.insert(elements, { - label = item.label .. ' - ' .. item.price .. '$', + label = item.label .. ' - $' .. item.price .. '', realLabel = item.label, value = item.name, price = item.price diff --git a/config.lua b/config.lua index 10a1f089..e1d07b2b 100644 --- a/config.lua +++ b/config.lua @@ -1,50 +1,49 @@ -Config = {} - +Config = {} Config.DrawDistance = 100 Config.Size = {x = 1.5, y = 1.5, z = 1.5} Config.Color = {r = 0, g = 128, b = 255} Config.Type = 1 -Config.Locale = 'en' +Config.Locale = 'en' Config.Zones = { - TwentyFourSeven = { - Items = {}, - Pos = { - {x = 373.875, y = 325.896, z = 102.566}, - {x = 2557.458, y = 382.282, z = 107.622}, - {x = -3038.939, y = 585.954, z = 6.908}, - {x = -3241.927, y = 1001.462, z = 11.830}, - {x = 547.431, y = 2671.710, z = 41.156}, - {x = 1961.464, y = 3740.672, z = 31.343}, - {x = 2678.916, y = 3280.671, z = 54.241}, - {x = 1729.216, y = 6414.131, z = 34.037} - } - }, + TwentyFourSeven = { + Items = {}, + Pos = { + {x = 373.875, y = 325.896, z = 102.566}, + {x = 2557.458, y = 382.282, z = 107.622}, + {x = -3038.939, y = 585.954, z = 6.908}, + {x = -3241.927, y = 1001.462, z = 11.830}, + {x = 547.431, y = 2671.710, z = 41.156}, + {x = 1961.464, y = 3740.672, z = 31.343}, + {x = 2678.916, y = 3280.671, z = 54.241}, + {x = 1729.216, y = 6414.131, z = 34.037} + } + }, - RobsLiquor = { - Items = {}, - Pos = { - {x = 1135.808, y = -982.281, z = 45.415}, - {x = -1222.915, y = -906.983, z = 11.326}, - {x = -1487.553, y = -379.107, z = 39.163}, - {x = -2968.243, y = 390.910, z = 14.043}, - {x = 1166.024, y = 2708.930, z = 37.157}, - {x = 1392.562, y = 3604.684, z = 33.980}, - {x = 127.830, y = -1284.796, z = 28.280}, --StripClub - {x = -1393.409, y = -606.624, z = 29.319}, --Tequila la - {x = -559.906, y = 287.093, z = 81.176} --Bahamamas - } - }, + RobsLiquor = { + Items = {}, + Pos = { + {x = 1135.808, y = -982.281, z = 45.415}, + {x = -1222.915, y = -906.983, z = 11.326}, + {x = -1487.553, y = -379.107, z = 39.163}, + {x = -2968.243, y = 390.910, z = 14.043}, + {x = 1166.024, y = 2708.930, z = 37.157}, + {x = 1392.562, y = 3604.684, z = 33.980}, + {x = 127.830, y = -1284.796, z = 28.280}, --StripClub + {x = -1393.409, y = -606.624, z = 29.319}, --Tequila la + {x = -559.906, y = 287.093, z = 81.176} --Bahamamas + } + }, - LTDgasoline = { - Items = {}, - Pos = { - {x = -48.519, y = -1757.514, z = 28.421}, - {x = 1163.373, y = -323.801, z = 68.205}, - {x = -707.501, y = -914.260, z = 18.215}, - {x = -1820.523, y = 792.518, z = 137.118}, - {x = 1698.388, y = 4924.404, z = 41.063} - } - } + LTDgasoline = { + Items = {}, + Pos = { + {x = -48.519, y = -1757.514, z = 28.421}, + {x = 1163.373, y = -323.801, z = 68.205}, + {x = -707.501, y = -914.260, z = 18.215}, + {x = -1820.523, y = 792.518, z = 137.118}, + {x = 1698.388, y = 4924.404, z = 41.063} + } + } } diff --git a/locales/br.lua b/locales/br.lua index 902206af..2d529545 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -1,10 +1,8 @@ Locales['br'] = { - ['shop'] = 'Comprar', ['shops'] = 'Lojas', ['press_menu'] = 'Pressione ~INPUT_CONTEXT~ para acessar a loja.', ['bought'] = 'você comprou ~b~1x ', - ['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~.' - ['player_cannot_hold'] = 'Você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!', - + ['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~.', + ['player_cannot_hold'] = 'Você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!', } diff --git a/server/main.lua b/server/main.lua index b3544158..310a7b1c 100644 --- a/server/main.lua +++ b/server/main.lua @@ -3,52 +3,53 @@ local ItemsLabels = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -AddEventHandler('onMySQLReady', function() - +-- Load item labels +Citizen.CreateThread(function() + Citizen.Wait(5000) + MySQL.Async.fetchAll( - 'SELECT * FROM items', - {}, - function(result) - - for i=1, #result, 1 do - ItemsLabels[result[i].name] = result[i].label - end - + 'SELECT * FROM items', + {}, + function(result) + for i=1, #result, 1 do + ItemsLabels[result[i].name] = result[i].label end - ) - + end) end) ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb) MySQL.Async.fetchAll( - 'SELECT * FROM shops', - {}, - function(result) - local shopItems = {} - for i=1, #result, 1 do - if shopItems[result[i].name] == nil then - shopItems[result[i].name] = {} - end - - table.insert(shopItems[result[i].name], { - name = result[i].item, - price = result[i].price, - label = ItemsLabels[result[i].item] - }) + 'SELECT * FROM shops', + {}, + function(result) + local shopItems = {} + for i=1, #result, 1 do + if shopItems[result[i].name] == nil then + shopItems[result[i].name] = {} end - cb(shopItems) + + table.insert(shopItems[result[i].name], { + name = result[i].item, + price = result[i].price, + label = ItemsLabels[result[i].item] + }) end - ) - + cb(shopItems) + end) end) RegisterServerEvent('esx_shops:buyItem') AddEventHandler('esx_shops:buyItem', function(itemName, price) - local _source = source local xPlayer = ESX.GetPlayerFromId(_source) local sourceItem = xPlayer.getInventoryItem(itemName) + + -- is the player trying to cheat? + if price < 0 then + print('esx_shops: ' .. xPlayer.identifier .. ' attempted to cheat money!') + return + end -- can the player afford this item? if xPlayer.getMoney() >= price then From b4a7a43fa2f5187da61ee7d4aba72317d5704429 Mon Sep 17 00:00:00 2001 From: Samuel Date: Mon, 30 Apr 2018 17:25:28 +0200 Subject: [PATCH 17/64] Update README.md --- README.md | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1bfeb057..2e5ea0aa 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,37 @@ -# fxserver-esx_shops -FXServer ESX Shops +# esx_shops -[INSTALLATION] +## Download & Installation -1) CD in your resources/[esx] folder -2) Clone the repository +### Using [fvm](https://github.com/qlaffont/fvm-installer) ``` -git clone https://github.com/FXServer-ESX/fxserver-esx_shops esx_shops +fvm install --save --folder=esx esx-org/esx_shops ``` -3) Import esx_shops.sql in your database -4) Add this in your server.cfg : + +### Using Git +``` +cd resources +git clone https://github.com/ESX-Org/esx_shops [esx]/esx_shops +``` + +### Manually +- Download https://github.com/ESX-Org/esx_shops/archive/master.zip +- Put it in the `[esx]` directory + +- Import `esx_shops.sql` to your database +- Add this in your `server.cfg`: ``` start esx_shops ``` + +# Legal +### License +esx_shops - shoppin' + +Copyright (C) 2015-2018 Jérémie N'gadi + +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 http://www.gnu.org/licenses/. From df4b505fe78d5cbd5441d30642228df99733ed79 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 11 Jun 2018 22:07:57 +0200 Subject: [PATCH 18/64] Major improvements, added slider --- __resource.lua | 2 +- client/main.lua | 67 ++++++++++++++++++----------- esx_shops.sql | 15 +++---- locales/br.lua | 15 ++++--- locales/de.lua | 16 ++++--- locales/en.lua | 5 ++- locales/es.lua | 16 ++++--- locales/fr.lua | 10 +++-- locales/sv.lua | 11 +++-- server/main.lua | 111 ++++++++++++++++++++++++++++++------------------ 10 files changed, 164 insertions(+), 104 deletions(-) diff --git a/__resource.lua b/__resource.lua index 76528017..ebabdf34 100644 --- a/__resource.lua +++ b/__resource.lua @@ -2,7 +2,7 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' description 'ESX Shops' -version '1.1.0' +version '1.2.0' client_scripts { '@es_extended/locale.lua', diff --git a/client/main.lua b/client/main.lua index e9392bd1..e9c5bfd2 100644 --- a/client/main.lua +++ b/client/main.lua @@ -4,15 +4,17 @@ local LastZone = nil local CurrentAction = nil local CurrentActionMsg = '' local CurrentActionData = {} +local PlayerData = {} Citizen.CreateThread(function() while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(0) end - + Citizen.Wait(5000) - + PlayerData = ESX.GetPlayerData() + ESX.TriggerServerCallback('esx_shops:requestDBItems', function(ShopItems) for k,v in pairs(ShopItems) do Config.Zones[k].Items = v @@ -20,38 +22,55 @@ Citizen.CreateThread(function() end) end) - function OpenShopMenu(zone) + PlayerData = ESX.GetPlayerData() + local elements = {} for i=1, #Config.Zones[zone].Items, 1 do - local item = Config.Zones[zone].Items[i] + table.insert(elements, { - label = item.label .. ' - $' .. item.price .. '', - realLabel = item.label, - value = item.name, - price = item.price + label = item.label .. ' - $' .. item.price .. '', + label_real = item.label, + item = item.item, + price = item.price, + + -- menu properties + value = 1, + type = 'slider', + min = 1, + max = item.limit }) end ESX.UI.Menu.CloseAll() - ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'shop', - { - title = _U('shop'), + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', { + title = _U('shop'), + align = 'bottom-right', + elements = elements + }, function(data, menu) + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', { + title = _U('shop_confirm', data.current.value, data.current.label_real, data.current.price * data.current.value), align = 'bottom-right', - elements = elements - }, - function(data, menu) - TriggerServerEvent('esx_shops:buyItem', data.current.value, data.current.price) - end, - function(data, menu) - menu.close() - CurrentAction = 'shop_menu' - CurrentActionMsg = _U('press_menu') - CurrentActionData = {zone = zone} - end - ) + elements = { + {label = _U('no'), value = 'no'}, + {label = _U('yes'), value = 'yes'} + } + }, function(data2, menu2) + if data2.current.value == 'yes' then + TriggerServerEvent('esx_shops:buyItem', data.current.item, data.current.value, zone) + end + + menu2.close() + end, function(data2, menu2) + menu2.close() + end) + end, function(data, menu) + menu.close() + CurrentAction = 'shop_menu' + CurrentActionMsg = _U('press_menu') + CurrentActionData = {zone = zone} + end) end AddEventHandler('esx_shops:hasEnteredMarker', function(zone) diff --git a/esx_shops.sql b/esx_shops.sql index b9f72161..0952742d 100644 --- a/esx_shops.sql +++ b/esx_shops.sql @@ -1,16 +1,15 @@ USE `essentialmode`; CREATE TABLE `shops` ( - - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `item` varchar(255) NOT NULL, - `price` int(11) NOT NULL, - - PRIMARY KEY (`id`) + `id` int(11) NOT NULL AUTO_INCREMENT, + `store` varchar(100) NOT NULL, + `item` varchar(100) NOT NULL, + `price` int(11) NOT NULL, + + PRIMARY KEY (`id`) ); -INSERT INTO `shops` (name, item, price) VALUES +INSERT INTO `shops` (store, item, price) VALUES ('TwentyFourSeven','bread',30), ('TwentyFourSeven','water',15), ('RobsLiquor','bread',30), diff --git a/locales/br.lua b/locales/br.lua index 2d529545..03d5486a 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -1,8 +1,11 @@ Locales['br'] = { - ['shop'] = 'Comprar', - ['shops'] = 'Lojas', - ['press_menu'] = 'Pressione ~INPUT_CONTEXT~ para acessar a loja.', - ['bought'] = 'você comprou ~b~1x ', - ['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~.', - ['player_cannot_hold'] = 'Você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!', + ['shop'] = 'comprar', + ['shops'] = 'lojas', + ['press_menu'] = 'pressione ~INPUT_CONTEXT~ para acessar a loja.', + ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~: %s', + ['player_cannot_hold'] = 'você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!', + ['shop_confirm'] = 'buy %sx %s for $%s?', + ['no'] = 'no', + ['yes'] = 'yes', } diff --git a/locales/de.lua b/locales/de.lua index c34fd81c..beba2424 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -1,9 +1,11 @@ Locales['de'] = { - - ['shop'] = 'Geschäft', - ['shops'] = 'Geschäfte', - ['press_menu'] = 'Drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', - ['bought'] = 'du kaufst ~b~1x ', - ['not_enough'] = 'du ~r~hast nicht~s~ genug Geld.' - + ['shop'] = 'geschäft', + ['shops'] = 'geschäfte', + ['press_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', + ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['not_enough'] = 'du ~r~hast nicht~s~ genug geld: %s', + ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', + ['shop_confirm'] = 'buy %sx %s for $%s?', + ['no'] = 'no', + ['yes'] = 'yes', } diff --git a/locales/en.lua b/locales/en.lua index f88753a4..1b02063a 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -2,7 +2,10 @@ Locales['en'] = { ['shop'] = 'shop', ['shops'] = 'shops', ['press_menu'] = 'press ~INPUT_CONTEXT~ to access the ~y~store~s~.', - ['bought'] = 'you just bought ~y~1x~s~ ~b~%s~s~ for ~r~$%s~s~', + ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', ['not_enough'] = 'you do not have ~r~enough~s~ money, you\'re ~y~missing~s~ ~r~$%s~s~!', ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', + ['shop_confirm'] = 'buy %sx %s for $%s?', + ['no'] = 'no', + ['yes'] = 'yes', } \ No newline at end of file diff --git a/locales/es.lua b/locales/es.lua index d25088fd..cbabfc9a 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -1,9 +1,11 @@ Locales['es'] = { - - ['shop'] = 'Tienda', - ['shops'] = 'Tiendas', - ['press_menu'] = 'Presiona ~INPUT_CONTEXT~ para acceder a la tienda.', - ['bought'] = 'Has comprado ~b~1 ', - ['not_enough'] = 'No tienes ~r~suficiente ~s~ dinero.', - + ['shop'] = 'tienda', + ['shops'] = 'tiendas', + ['press_menu'] = 'presiona ~INPUT_CONTEXT~ para acceder a la tienda.', + ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['not_enough'] = 'no tienes ~r~suficiente ~s~ dinero: %s', + ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', + ['shop_confirm'] = 'buy %sx %s for $%s?', + ['no'] = 'no', + ['yes'] = 'yes', } diff --git a/locales/fr.lua b/locales/fr.lua index 14e9ca67..96513258 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -1,9 +1,11 @@ Locales['fr'] = { - ['shop'] = 'magasin', ['shops'] = 'magasins', ['press_menu'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.', - ['bought'] = 'vous avez acheté ~b~1x ', - ['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent.', - + ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent: %s', + ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', + ['shop_confirm'] = 'buy %sx %s for $%s?', + ['no'] = 'no', + ['yes'] = 'yes', } diff --git a/locales/sv.lua b/locales/sv.lua index 5dfbf64b..294fb21e 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -1,8 +1,11 @@ Locales['sv'] = { ['shop'] = 'affär', ['shops'] = 'affärer', - ['press_menu'] = 'tryck ~INPUT_CONTEXT~ för att ~y~handla prylar~w~.', - ['bought'] = 'du har köpt ~y~1x~w~ ~b~%s~w~ för ~r~$%s~w~', - ['not_enough'] = 'du har inte ~r~tillräckligt~s~ med pengar, det ~y~saknas~w~ ~r~$%s~w~!', - ['player_cannot_hold'] = 'du har ~r~inte~w~ tillräckligt med ~y~utrymme~w~ för att hålla det!', + ['press_menu'] = 'tryck ~INPUT_CONTEXT~ för att ~y~handla prylar~s~.', + ['bought'] = 'du har köpt ~y~%sx~s~ ~b~%s~s~ för ~r~$%s~s~', + ['not_enough'] = 'du har inte ~r~tillräckligt~s~ med pengar, det ~y~saknas~s~ ~r~$%s~s~!', + ['player_cannot_hold'] = 'du har ~r~inte~s~ tillräckligt med ~y~utrymme~s~ för att hålla det!', + ['shop_confirm'] = 'köpa %sx %s för $%s?', + ['no'] = 'nej', + ['yes'] = 'ja', } \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index 310a7b1c..f7099870 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,70 +1,97 @@ -ESX = nil -local ItemsLabels = {} +ESX = nil +local ShopItems = {} +local hasSqlRun = false TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) --- Load item labels -Citizen.CreateThread(function() - Citizen.Wait(5000) - - MySQL.Async.fetchAll( - 'SELECT * FROM items', - {}, - function(result) - for i=1, #result, 1 do - ItemsLabels[result[i].name] = result[i].label - end - end) +-- Load items +AddEventHandler('onMySQLReady', function() + hasSqlRun = true + LoadShop() end) -ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb) +-- extremely useful when restarting script mid-game +Citizen.CreateThread(function() + Citizen.Wait(20000) -- hopefully enough for connection to the SQL server - MySQL.Async.fetchAll( - 'SELECT * FROM shops', - {}, - function(result) - local shopItems = {} - for i=1, #result, 1 do - if shopItems[result[i].name] == nil then - shopItems[result[i].name] = {} - end - - table.insert(shopItems[result[i].name], { - name = result[i].item, - price = result[i].price, - label = ItemsLabels[result[i].item] - }) + if not hasSqlRun then + LoadShop() + hasSqlRun = true + end +end) + +function LoadShop() + local itemResult = MySQL.Sync.fetchAll('SELECT * FROM items') + local shopResult = MySQL.Sync.fetchAll('SELECT * FROM shops') + + local itemInformation = {} + for i=1, #itemResult, 1 do + if itemInformation[itemResult[i].name] == nil then + itemInformation[itemResult[i].name] = {} end - cb(shopItems) - end) + + itemInformation[itemResult[i].name].label = itemResult[i].label + itemInformation[itemResult[i].name].limit = itemResult[i].limit + end + + for i=1, #shopResult, 1 do + if ShopItems[shopResult[i].store] == nil then + ShopItems[shopResult[i].store] = {} + end + + table.insert(ShopItems[shopResult[i].store], { + label = itemInformation[shopResult[i].item].label, + item = shopResult[i].item, + price = shopResult[i].price, + limit = itemInformation[shopResult[i].item].limit + }) + end +end + +ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb) + if not hasSqlRun then + TriggerClientEvent('esx:showNotification', source, 'The shop database has not been loaded yet, try again in a few moments.') + end + + cb(ShopItems) end) RegisterServerEvent('esx_shops:buyItem') -AddEventHandler('esx_shops:buyItem', function(itemName, price) +AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) local sourceItem = xPlayer.getInventoryItem(itemName) - - -- is the player trying to cheat? - if price < 0 then - print('esx_shops: ' .. xPlayer.identifier .. ' attempted to cheat money!') + + -- is the player trying to exploit? + if amount < 0 then + print('esx_shops: ' .. xPlayer.identifier .. ' attempted to exploit the shop!') return end + -- get price + local price = 0 + local itemLabel = '' + for i=1, #ShopItems[zone], 1 do + if ShopItems[zone][i].item == itemName then + price = ShopItems[zone][i].price + itemLabel = ShopItems[zone][i].label + break + end + end + price = price * amount + -- can the player afford this item? if xPlayer.getMoney() >= price then - -- can the player carry the said amount of x item? - if sourceItem.limit ~= -1 and (sourceItem.count + 1) > sourceItem.limit then + if sourceItem.limit ~= -1 and (sourceItem.count + amount) > sourceItem.limit then TriggerClientEvent('esx:showNotification', _source, _U('player_cannot_hold')) else xPlayer.removeMoney(price) - xPlayer.addInventoryItem(itemName, 1) - TriggerClientEvent('esx:showNotification', _source, _U('bought', ItemsLabels[itemName], price)) + xPlayer.addInventoryItem(itemName, amount) + TriggerClientEvent('esx:showNotification', _source, _U('bought', amount, itemLabel, price)) end else local missingMoney = price - xPlayer.getMoney() TriggerClientEvent('esx:showNotification', _source, _U('not_enough', missingMoney)) end - end) \ No newline at end of file From dffd081ffb3f4e3983810c843eeb0ba437f491bc Mon Sep 17 00:00:00 2001 From: Samuel Date: Mon, 11 Jun 2018 22:09:41 +0200 Subject: [PATCH 19/64] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2e5ea0aa..670b02a1 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ git clone https://github.com/ESX-Org/esx_shops [esx]/esx_shops - Download https://github.com/ESX-Org/esx_shops/archive/master.zip - Put it in the `[esx]` directory +## Installation - Import `esx_shops.sql` to your database - Add this in your `server.cfg`: From a5cef41c5ffc4fc650c5a21e662f2a29c81280fb Mon Sep 17 00:00:00 2001 From: Samuel Date: Mon, 11 Jun 2018 22:11:10 +0200 Subject: [PATCH 20/64] Update __resource.lua --- __resource.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__resource.lua b/__resource.lua index ebabdf34..76528017 100644 --- a/__resource.lua +++ b/__resource.lua @@ -2,7 +2,7 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' description 'ESX Shops' -version '1.2.0' +version '1.1.0' client_scripts { '@es_extended/locale.lua', From 09a282b0cbfc1f2a217be1644d300148008756bf Mon Sep 17 00:00:00 2001 From: AdrineX Date: Tue, 12 Jun 2018 18:17:04 +0300 Subject: [PATCH 21/64] Add Finnish lang.. --- __resource.lua | 2 ++ locales/fi.lua | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 locales/fi.lua diff --git a/__resource.lua b/__resource.lua index 76528017..7c03c770 100644 --- a/__resource.lua +++ b/__resource.lua @@ -9,6 +9,7 @@ client_scripts { 'locales/de.lua', 'locales/br.lua', 'locales/en.lua', + 'locales/fi.lua', 'locales/fr.lua', 'locales/es.lua', 'locales/sv.lua', @@ -21,6 +22,7 @@ server_scripts { 'locales/de.lua', 'locales/br.lua', 'locales/en.lua', + 'locales/fi.lua', 'locales/fr.lua', 'locales/es.lua', 'locales/sv.lua', diff --git a/locales/fi.lua b/locales/fi.lua new file mode 100644 index 00000000..5d3c84c6 --- /dev/null +++ b/locales/fi.lua @@ -0,0 +1,11 @@ +Locales['fi'] = { + ['shop'] = 'kauppa', + ['shops'] = 'kaupat', + ['press_menu'] = 'paina ~INPUT_CONTEXT~ ostaaksesi jotain ~y~kaupasta~s~.', + ['bought'] = 'Sinä ostit juuri ~y~%sx~s~ ~b~%s~s~. Summaksi tuli ~r~$%s~s~', + ['not_enough'] = 'sinulla ei ole ~r~tarpeeksi~s~ rahaa, sinulta ~y~puuttuu~s~ ~r~$%s~s~!', + ['player_cannot_hold'] = 'sinulla ~r~ei ole~s~ tarpeeksi ~y~tilaa~s~ repussasi!', + ['shop_confirm'] = 'osta %sx %s summa olisi $%s?', + ['no'] = 'ei', + ['yes'] = 'kyllä', +} \ No newline at end of file From eda97f33a76599de85ac33f4e387ece0697656d5 Mon Sep 17 00:00:00 2001 From: renildomarcio Date: Mon, 25 Jun 2018 16:35:50 -0300 Subject: [PATCH 22/64] update br.lua update in portuguese translation --- locales/br.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locales/br.lua b/locales/br.lua index 03d5486a..71df11c2 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -2,10 +2,10 @@ Locales['br'] = { ['shop'] = 'comprar', ['shops'] = 'lojas', ['press_menu'] = 'pressione ~INPUT_CONTEXT~ para acessar a loja.', - ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['bought'] = 'você acabou de comprar ~y~%sx~s~ ~b~%s~s~ por ~r~$%s~s~', ['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~: %s', ['player_cannot_hold'] = 'você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!', - ['shop_confirm'] = 'buy %sx %s for $%s?', - ['no'] = 'no', - ['yes'] = 'yes', + ['shop_confirm'] = 'comprou %sx %s por $%s?', + ['no'] = 'não', + ['yes'] = 'sim', } From 88eecdd08bf0401315f0b829b3b44c65515bb307 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sat, 7 Jul 2018 12:52:03 +0200 Subject: [PATCH 23/64] Fixed #19 --- client/main.lua | 8 ++++---- locales/en.lua | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/main.lua b/client/main.lua index e9c5bfd2..935eebaa 100644 --- a/client/main.lua +++ b/client/main.lua @@ -29,6 +29,10 @@ function OpenShopMenu(zone) for i=1, #Config.Zones[zone].Items, 1 do local item = Config.Zones[zone].Items[i] + if item.limit == -1 then + item.limit = 100 + end + table.insert(elements, { label = item.label .. ' - $' .. item.price .. '', label_real = item.label, @@ -74,18 +78,14 @@ function OpenShopMenu(zone) end AddEventHandler('esx_shops:hasEnteredMarker', function(zone) - CurrentAction = 'shop_menu' CurrentActionMsg = _U('press_menu') CurrentActionData = {zone = zone} - end) AddEventHandler('esx_shops:hasExitedMarker', function(zone) - CurrentAction = nil ESX.UI.Menu.CloseAll() - end) -- Create Blips diff --git a/locales/en.lua b/locales/en.lua index 1b02063a..237b5828 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -3,7 +3,7 @@ Locales['en'] = { ['shops'] = 'shops', ['press_menu'] = 'press ~INPUT_CONTEXT~ to access the ~y~store~s~.', ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', - ['not_enough'] = 'you do not have ~r~enough~s~ money, you\'re ~y~missing~s~ ~r~$%s~s~!', + ['not_enough'] = 'you do not have ~r~enough~s~ money, you\'re ~y~missing~s~ ~r~$%s~s~!', ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', ['shop_confirm'] = 'buy %sx %s for $%s?', ['no'] = 'no', From 538a97d3f348625325d637058778efd2fc921306 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Wed, 11 Jul 2018 12:16:58 +0200 Subject: [PATCH 24/64] Fixed max slider when item limit is unlimited --- __resource.lua | 5 ++++- client/main.lua | 51 ++++++++++++++++++++++++++----------------------- server/main.lua | 11 ++++++++++- 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/__resource.lua b/__resource.lua index 7c03c770..ec5f51b3 100644 --- a/__resource.lua +++ b/__resource.lua @@ -19,6 +19,7 @@ client_scripts { server_scripts { '@es_extended/locale.lua', + '@mysql-async/lib/MySQL.lua', 'locales/de.lua', 'locales/br.lua', 'locales/en.lua', @@ -26,7 +27,9 @@ server_scripts { 'locales/fr.lua', 'locales/es.lua', 'locales/sv.lua', - '@mysql-async/lib/MySQL.lua', + 'config.lua', 'server/main.lua' } + +dependency 'es_extended' diff --git a/client/main.lua b/client/main.lua index 935eebaa..1004b61a 100644 --- a/client/main.lua +++ b/client/main.lua @@ -91,16 +91,16 @@ end) -- Create Blips Citizen.CreateThread(function() for k,v in pairs(Config.Zones) do - for i = 1, #v.Pos, 1 do - local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z) - SetBlipSprite (blip, 52) - SetBlipDisplay(blip, 4) - SetBlipScale (blip, 1.0) - SetBlipColour (blip, 2) - SetBlipAsShortRange(blip, true) - BeginTextCommandSetBlipName("STRING") - AddTextComponentString(_U('shops')) - EndTextCommandSetBlipName(blip) + for i = 1, #v.Pos, 1 do + local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z) + SetBlipSprite (blip, 52) + SetBlipDisplay(blip, 4) + SetBlipScale (blip, 1.0) + SetBlipColour (blip, 2) + SetBlipAsShortRange(blip, true) + BeginTextCommandSetBlipName("STRING") + AddTextComponentString(_U('shops')) + EndTextCommandSetBlipName(blip) end end end) @@ -151,24 +151,27 @@ end) -- Key Controls Citizen.CreateThread(function() - while true do - Citizen.Wait(10) - if CurrentAction ~= nil then + while true do + Citizen.Wait(10) - SetTextComponentFormat('STRING') - AddTextComponentString(CurrentActionMsg) - DisplayHelpTextFromStringLabel(0, 0, 1, -1) + if CurrentAction ~= nil then - if IsControlJustReleased(0, 38) then + SetTextComponentFormat('STRING') + AddTextComponentString(CurrentActionMsg) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) - if CurrentAction == 'shop_menu' then - OpenShopMenu(CurrentActionData.zone) - end + if IsControlJustReleased(0, 38) then - CurrentAction = nil + if CurrentAction == 'shop_menu' then + OpenShopMenu(CurrentActionData.zone) + end - end + CurrentAction = nil - end - end + end + + else + Citizen.Wait(500) + end + end end) \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index f7099870..ab8e13f3 100644 --- a/server/main.lua +++ b/server/main.lua @@ -12,7 +12,7 @@ end) -- extremely useful when restarting script mid-game Citizen.CreateThread(function() - Citizen.Wait(20000) -- hopefully enough for connection to the SQL server + Citizen.Wait(2000) -- hopefully enough for connection to the SQL server if not hasSqlRun then LoadShop() @@ -26,6 +26,7 @@ function LoadShop() local itemInformation = {} for i=1, #itemResult, 1 do + if itemInformation[itemResult[i].name] == nil then itemInformation[itemResult[i].name] = {} end @@ -39,6 +40,10 @@ function LoadShop() ShopItems[shopResult[i].store] = {} end + if itemInformation[shopResult[i].item].limit == -1 then + itemInformation[shopResult[i].item].limit = 30 + end + table.insert(ShopItems[shopResult[i].store], { label = itemInformation[shopResult[i].item].label, item = shopResult[i].item, @@ -62,6 +67,8 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) local xPlayer = ESX.GetPlayerFromId(_source) local sourceItem = xPlayer.getInventoryItem(itemName) + amount = ESX.Round(amount) + -- is the player trying to exploit? if amount < 0 then print('esx_shops: ' .. xPlayer.identifier .. ' attempted to exploit the shop!') @@ -71,6 +78,7 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) -- get price local price = 0 local itemLabel = '' + for i=1, #ShopItems[zone], 1 do if ShopItems[zone][i].item == itemName then price = ShopItems[zone][i].price @@ -78,6 +86,7 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) break end end + price = price * amount -- can the player afford this item? From 9a337a09b948132246730cf03acad189ff142033 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Wed, 11 Jul 2018 12:24:56 +0200 Subject: [PATCH 25/64] Fixed max slider when item limit is unlimited --- __resource.lua | 1 - client/main.lua | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/__resource.lua b/__resource.lua index ec5f51b3..a849d332 100644 --- a/__resource.lua +++ b/__resource.lua @@ -27,7 +27,6 @@ server_scripts { 'locales/fr.lua', 'locales/es.lua', 'locales/sv.lua', - 'config.lua', 'server/main.lua' } diff --git a/client/main.lua b/client/main.lua index 1004b61a..797c61eb 100644 --- a/client/main.lua +++ b/client/main.lua @@ -107,17 +107,18 @@ end) -- Display markers Citizen.CreateThread(function() - while true do - Citizen.Wait(10) - local coords = GetEntityCoords(GetPlayerPed(-1)) - for k,v in pairs(Config.Zones) do - for i = 1, #v.Pos, 1 do - if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then - DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false) - end - end - end - end + while true do + Citizen.Wait(10) + local coords = GetEntityCoords(GetPlayerPed(-1)) + + for k,v in pairs(Config.Zones) do + for i = 1, #v.Pos, 1 do + if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then + DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false) + end + end + end + end end) -- Enter / Exit marker events From 3e855c0f0e049903f602bd353e92b63271d25fd1 Mon Sep 17 00:00:00 2001 From: MajorMarcin Date: Mon, 16 Jul 2018 11:37:06 +0200 Subject: [PATCH 26/64] add pl --- __resource.lua | 2 ++ locales/pl.lua | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 locales/pl.lua diff --git a/__resource.lua b/__resource.lua index a849d332..bf1ee68e 100644 --- a/__resource.lua +++ b/__resource.lua @@ -13,6 +13,7 @@ client_scripts { 'locales/fr.lua', 'locales/es.lua', 'locales/sv.lua', + 'locales/pl.lua', 'config.lua', 'client/main.lua' } @@ -27,6 +28,7 @@ server_scripts { 'locales/fr.lua', 'locales/es.lua', 'locales/sv.lua', + 'locales/pl.lua', 'config.lua', 'server/main.lua' } diff --git a/locales/pl.lua b/locales/pl.lua new file mode 100644 index 00000000..e31fbb2e --- /dev/null +++ b/locales/pl.lua @@ -0,0 +1,11 @@ +Locales['pl'] = { + ['shop'] = 'sklep', + ['shops'] = 'sklepy', + ['press_menu'] = 'naciśnij ~INPUT_CONTEXT~ żeby wejść do ~y~sklepu~s~.', + ['bought'] = 'właśnie zakupiłeś ~y~%s~s~ x ~b~%s~s~ za ~g~%s $~s~', + ['not_enough'] = 'nie masz ~r~wystarczjąco~s~ pięniędzy, ~y~Brakuje Ci~s~ ~r~$%s~s~!', + ['player_cannot_hold'] = '~r~Nie~s~ masz wystarczająco ~y~wolnego miejsca~s~ w swoim ekwipunku!', + ['shop_confirm'] = 'chcesz kupić %sx %s za $%s?', + ['no'] = 'nie', + ['yes'] = 'tak', +} \ No newline at end of file From 171ef9e656ef620d7879282e7f77338822977d70 Mon Sep 17 00:00:00 2001 From: nearbyplayer Date: Fri, 10 Aug 2018 00:55:30 -0400 Subject: [PATCH 27/64] Repo Update --- .editorconfig | 9 +++++++++ LICENSE.txt => LICENSE | 0 2 files changed, 9 insertions(+) create mode 100644 .editorconfig rename LICENSE.txt => LICENSE (100%) diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..9b425256 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_size = 4 +indent_style = tab +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE From 53cae38fe39607833c33e33b0398174ce29fefce Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sat, 11 Aug 2018 23:56:04 +0200 Subject: [PATCH 28/64] Corrected Swedish currency --- locales/sv.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locales/sv.lua b/locales/sv.lua index 294fb21e..1ea36395 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -2,10 +2,10 @@ Locales['sv'] = { ['shop'] = 'affär', ['shops'] = 'affärer', ['press_menu'] = 'tryck ~INPUT_CONTEXT~ för att ~y~handla prylar~s~.', - ['bought'] = 'du har köpt ~y~%sx~s~ ~b~%s~s~ för ~r~$%s~s~', - ['not_enough'] = 'du har inte ~r~tillräckligt~s~ med pengar, det ~y~saknas~s~ ~r~$%s~s~!', + ['bought'] = 'du har köpt ~y~%sx~s~ ~b~%s~s~ för ~r~%s SEK~s~', + ['not_enough'] = 'du har inte ~r~tillräckligt~s~ med pengar, det ~y~saknas~s~ ~r~%s SEK~s~!', ['player_cannot_hold'] = 'du har ~r~inte~s~ tillräckligt med ~y~utrymme~s~ för att hålla det!', - ['shop_confirm'] = 'köpa %sx %s för $%s?', + ['shop_confirm'] = 'köpa %sx %s för %s SEK?', ['no'] = 'nej', ['yes'] = 'ja', } \ No newline at end of file From 565af10b6caa123f197aa26b7f470deb86fc68a3 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 24 Sep 2018 17:31:33 +0200 Subject: [PATCH 29/64] mysql-async v3.0.1 support --- client/main.lua | 26 ++++++++++++++------------ server/main.lua | 24 ++---------------------- 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/client/main.lua b/client/main.lua index 797c61eb..c3c287f7 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,10 +1,21 @@ +local Keys = { + ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, + ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, + ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, + ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, + ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, + ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, + ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, + ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, + ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 +} + ESX = nil local HasAlreadyEnteredMarker = false local LastZone = nil local CurrentAction = nil local CurrentActionMsg = '' local CurrentActionData = {} -local PlayerData = {} Citizen.CreateThread(function() while ESX == nil do @@ -13,7 +24,6 @@ Citizen.CreateThread(function() end Citizen.Wait(5000) - PlayerData = ESX.GetPlayerData() ESX.TriggerServerCallback('esx_shops:requestDBItems', function(ShopItems) for k,v in pairs(ShopItems) do @@ -23,8 +33,6 @@ Citizen.CreateThread(function() end) function OpenShopMenu(zone) - PlayerData = ESX.GetPlayerData() - local elements = {} for i=1, #Config.Zones[zone].Items, 1 do local item = Config.Zones[zone].Items[i] @@ -156,21 +164,15 @@ Citizen.CreateThread(function() Citizen.Wait(10) if CurrentAction ~= nil then + ESX.ShowHelpNotification(CurrentActionMsg) - SetTextComponentFormat('STRING') - AddTextComponentString(CurrentActionMsg) - DisplayHelpTextFromStringLabel(0, 0, 1, -1) - - if IsControlJustReleased(0, 38) then - + if IsControlJustReleased(0, Keys['E']) then if CurrentAction == 'shop_menu' then OpenShopMenu(CurrentActionData.zone) end CurrentAction = nil - end - else Citizen.Wait(500) end diff --git a/server/main.lua b/server/main.lua index ab8e13f3..b674b281 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,26 +1,10 @@ ESX = nil local ShopItems = {} -local hasSqlRun = false TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -- Load items -AddEventHandler('onMySQLReady', function() - hasSqlRun = true - LoadShop() -end) - --- extremely useful when restarting script mid-game -Citizen.CreateThread(function() - Citizen.Wait(2000) -- hopefully enough for connection to the SQL server - - if not hasSqlRun then - LoadShop() - hasSqlRun = true - end -end) - -function LoadShop() +MySQL.ready(function() local itemResult = MySQL.Sync.fetchAll('SELECT * FROM items') local shopResult = MySQL.Sync.fetchAll('SELECT * FROM shops') @@ -51,13 +35,9 @@ function LoadShop() limit = itemInformation[shopResult[i].item].limit }) end -end +end) ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb) - if not hasSqlRun then - TriggerClientEvent('esx:showNotification', source, 'The shop database has not been loaded yet, try again in a few moments.') - end - cb(ShopItems) end) From 947b80832611168dbaf9beae30528084105cf64e Mon Sep 17 00:00:00 2001 From: JakeRyan1 Date: Fri, 19 Oct 2018 02:10:30 -0400 Subject: [PATCH 30/64] Causing the marker on the ground to blink very fast This will fix the issue with the ground marker blinking very fast needs to be ran every frame --- client/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/main.lua b/client/main.lua index c3c287f7..9fcc3e92 100644 --- a/client/main.lua +++ b/client/main.lua @@ -116,7 +116,7 @@ end) -- Display markers Citizen.CreateThread(function() while true do - Citizen.Wait(10) + Citizen.Wait(0) local coords = GetEntityCoords(GetPlayerPed(-1)) for k,v in pairs(Config.Zones) do @@ -177,4 +177,4 @@ Citizen.CreateThread(function() Citizen.Wait(500) end end -end) \ No newline at end of file +end) From 25071dfe332faed9647053980894378fdcc78d5c Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 19 Nov 2018 18:47:26 +0100 Subject: [PATCH 31/64] Added exception handler when invalid item is found, closes #32 --- client/main.lua | 2 +- server/main.lua | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/client/main.lua b/client/main.lua index 9fcc3e92..c15fdad2 100644 --- a/client/main.lua +++ b/client/main.lua @@ -42,7 +42,7 @@ function OpenShopMenu(zone) end table.insert(elements, { - label = item.label .. ' - $' .. item.price .. '', + label = item.label .. ' - $' .. ESX.Math.GroupDigits(item.price) .. '', label_real = item.label, item = item.item, price = item.price, diff --git a/server/main.lua b/server/main.lua index b674b281..85146473 100644 --- a/server/main.lua +++ b/server/main.lua @@ -20,20 +20,24 @@ MySQL.ready(function() end for i=1, #shopResult, 1 do - if ShopItems[shopResult[i].store] == nil then - ShopItems[shopResult[i].store] = {} - end + if itemInformation[shopResult[i].item] then + if ShopItems[shopResult[i].store] == nil then + ShopItems[shopResult[i].store] = {} + end - if itemInformation[shopResult[i].item].limit == -1 then - itemInformation[shopResult[i].item].limit = 30 - end + if itemInformation[shopResult[i].item].limit == -1 then + itemInformation[shopResult[i].item].limit = 30 + end - table.insert(ShopItems[shopResult[i].store], { - label = itemInformation[shopResult[i].item].label, - item = shopResult[i].item, - price = shopResult[i].price, - limit = itemInformation[shopResult[i].item].limit - }) + table.insert(ShopItems[shopResult[i].store], { + label = itemInformation[shopResult[i].item].label, + item = shopResult[i].item, + price = shopResult[i].price, + limit = itemInformation[shopResult[i].item].limit + }) + else + print(('esx_shops: invalid item "%s" found!'):format(shopResult[i].item)) + end end end) @@ -47,7 +51,7 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) local xPlayer = ESX.GetPlayerFromId(_source) local sourceItem = xPlayer.getInventoryItem(itemName) - amount = ESX.Round(amount) + amount = ESX.Math.Round(amount) -- is the player trying to exploit? if amount < 0 then @@ -77,10 +81,10 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) else xPlayer.removeMoney(price) xPlayer.addInventoryItem(itemName, amount) - TriggerClientEvent('esx:showNotification', _source, _U('bought', amount, itemLabel, price)) + TriggerClientEvent('esx:showNotification', _source, _U('bought', amount, itemLabel, ESX.Math.GroupDigits(price))) end else local missingMoney = price - xPlayer.getMoney() - TriggerClientEvent('esx:showNotification', _source, _U('not_enough', missingMoney)) + TriggerClientEvent('esx:showNotification', _source, _U('not_enough', ESX.Math.GroupDigits(missingMoney))) end end) \ No newline at end of file From 3c1e9ab32d7c6e9ddab46452e1eeb3f1c6cbaa89 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 19 Nov 2018 18:53:48 +0100 Subject: [PATCH 32/64] Enforced correct locale indent --- locales/br.lua | 18 +++++++++--------- locales/de.lua | 18 +++++++++--------- locales/en.lua | 20 ++++++++++---------- locales/es.lua | 18 +++++++++--------- locales/fi.lua | 20 ++++++++++---------- locales/fr.lua | 18 +++++++++--------- locales/pl.lua | 20 ++++++++++---------- locales/sv.lua | 20 ++++++++++---------- 8 files changed, 76 insertions(+), 76 deletions(-) diff --git a/locales/br.lua b/locales/br.lua index 71df11c2..9bace0e8 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -1,11 +1,11 @@ Locales['br'] = { - ['shop'] = 'comprar', - ['shops'] = 'lojas', - ['press_menu'] = 'pressione ~INPUT_CONTEXT~ para acessar a loja.', - ['bought'] = 'você acabou de comprar ~y~%sx~s~ ~b~%s~s~ por ~r~$%s~s~', - ['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~: %s', - ['player_cannot_hold'] = 'você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!', - ['shop_confirm'] = 'comprou %sx %s por $%s?', - ['no'] = 'não', - ['yes'] = 'sim', + ['shop'] = 'comprar', + ['shops'] = 'lojas', + ['press_menu'] = 'pressione ~INPUT_CONTEXT~ para acessar a loja.', + ['bought'] = 'você acabou de comprar ~y~%sx~s~ ~b~%s~s~ por ~r~$%s~s~', + ['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~: %s', + ['player_cannot_hold'] = 'você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!', + ['shop_confirm'] = 'comprou %sx %s por $%s?', + ['no'] = 'não', + ['yes'] = 'sim', } diff --git a/locales/de.lua b/locales/de.lua index beba2424..8da7e842 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -1,11 +1,11 @@ Locales['de'] = { - ['shop'] = 'geschäft', - ['shops'] = 'geschäfte', - ['press_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', - ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', - ['not_enough'] = 'du ~r~hast nicht~s~ genug geld: %s', - ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', - ['shop_confirm'] = 'buy %sx %s for $%s?', - ['no'] = 'no', - ['yes'] = 'yes', + ['shop'] = 'geschäft', + ['shops'] = 'geschäfte', + ['press_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', + ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['not_enough'] = 'du ~r~hast nicht~s~ genug geld: %s', + ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', + ['shop_confirm'] = 'buy %sx %s for $%s?', + ['no'] = 'no', + ['yes'] = 'yes', } diff --git a/locales/en.lua b/locales/en.lua index 237b5828..f504fedc 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,11 +1,11 @@ Locales['en'] = { - ['shop'] = 'shop', - ['shops'] = 'shops', - ['press_menu'] = 'press ~INPUT_CONTEXT~ to access the ~y~store~s~.', - ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', - ['not_enough'] = 'you do not have ~r~enough~s~ money, you\'re ~y~missing~s~ ~r~$%s~s~!', - ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', - ['shop_confirm'] = 'buy %sx %s for $%s?', - ['no'] = 'no', - ['yes'] = 'yes', -} \ No newline at end of file + ['shop'] = 'shop', + ['shops'] = 'shops', + ['press_menu'] = 'press ~INPUT_CONTEXT~ to access the ~y~store~s~.', + ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['not_enough'] = 'you do not have ~r~enough~s~ money, you\'re ~y~missing~s~ ~r~$%s~s~!', + ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', + ['shop_confirm'] = 'buy %sx %s for $%s?', + ['no'] = 'no', + ['yes'] = 'yes', +} diff --git a/locales/es.lua b/locales/es.lua index cbabfc9a..327981a1 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -1,11 +1,11 @@ Locales['es'] = { - ['shop'] = 'tienda', - ['shops'] = 'tiendas', - ['press_menu'] = 'presiona ~INPUT_CONTEXT~ para acceder a la tienda.', - ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', - ['not_enough'] = 'no tienes ~r~suficiente ~s~ dinero: %s', - ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', - ['shop_confirm'] = 'buy %sx %s for $%s?', - ['no'] = 'no', - ['yes'] = 'yes', + ['shop'] = 'tienda', + ['shops'] = 'tiendas', + ['press_menu'] = 'presiona ~INPUT_CONTEXT~ para acceder a la tienda.', + ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['not_enough'] = 'no tienes ~r~suficiente ~s~ dinero: %s', + ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', + ['shop_confirm'] = 'buy %sx %s for $%s?', + ['no'] = 'no', + ['yes'] = 'yes', } diff --git a/locales/fi.lua b/locales/fi.lua index 5d3c84c6..c2c9c567 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -1,11 +1,11 @@ Locales['fi'] = { - ['shop'] = 'kauppa', - ['shops'] = 'kaupat', - ['press_menu'] = 'paina ~INPUT_CONTEXT~ ostaaksesi jotain ~y~kaupasta~s~.', - ['bought'] = 'Sinä ostit juuri ~y~%sx~s~ ~b~%s~s~. Summaksi tuli ~r~$%s~s~', - ['not_enough'] = 'sinulla ei ole ~r~tarpeeksi~s~ rahaa, sinulta ~y~puuttuu~s~ ~r~$%s~s~!', - ['player_cannot_hold'] = 'sinulla ~r~ei ole~s~ tarpeeksi ~y~tilaa~s~ repussasi!', - ['shop_confirm'] = 'osta %sx %s summa olisi $%s?', - ['no'] = 'ei', - ['yes'] = 'kyllä', -} \ No newline at end of file + ['shop'] = 'kauppa', + ['shops'] = 'kaupat', + ['press_menu'] = 'paina ~INPUT_CONTEXT~ ostaaksesi jotain ~y~kaupasta~s~.', + ['bought'] = 'Sinä ostit juuri ~y~%sx~s~ ~b~%s~s~. Summaksi tuli ~r~$%s~s~', + ['not_enough'] = 'sinulla ei ole ~r~tarpeeksi~s~ rahaa, sinulta ~y~puuttuu~s~ ~r~$%s~s~!', + ['player_cannot_hold'] = 'sinulla ~r~ei ole~s~ tarpeeksi ~y~tilaa~s~ repussasi!', + ['shop_confirm'] = 'osta %sx %s summa olisi $%s?', + ['no'] = 'ei', + ['yes'] = 'kyllä', +} diff --git a/locales/fr.lua b/locales/fr.lua index 96513258..7494b137 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -1,11 +1,11 @@ Locales['fr'] = { - ['shop'] = 'magasin', - ['shops'] = 'magasins', - ['press_menu'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.', - ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', - ['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent: %s', - ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', - ['shop_confirm'] = 'buy %sx %s for $%s?', - ['no'] = 'no', - ['yes'] = 'yes', + ['shop'] = 'magasin', + ['shops'] = 'magasins', + ['press_menu'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.', + ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent: %s', + ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', + ['shop_confirm'] = 'buy %sx %s for $%s?', + ['no'] = 'no', + ['yes'] = 'yes', } diff --git a/locales/pl.lua b/locales/pl.lua index e31fbb2e..accbf9fb 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -1,11 +1,11 @@ Locales['pl'] = { - ['shop'] = 'sklep', - ['shops'] = 'sklepy', - ['press_menu'] = 'naciśnij ~INPUT_CONTEXT~ żeby wejść do ~y~sklepu~s~.', - ['bought'] = 'właśnie zakupiłeś ~y~%s~s~ x ~b~%s~s~ za ~g~%s $~s~', - ['not_enough'] = 'nie masz ~r~wystarczjąco~s~ pięniędzy, ~y~Brakuje Ci~s~ ~r~$%s~s~!', - ['player_cannot_hold'] = '~r~Nie~s~ masz wystarczająco ~y~wolnego miejsca~s~ w swoim ekwipunku!', - ['shop_confirm'] = 'chcesz kupić %sx %s za $%s?', - ['no'] = 'nie', - ['yes'] = 'tak', -} \ No newline at end of file + ['shop'] = 'sklep', + ['shops'] = 'sklepy', + ['press_menu'] = 'naciśnij ~INPUT_CONTEXT~ żeby wejść do ~y~sklepu~s~.', + ['bought'] = 'właśnie zakupiłeś ~y~%s~s~ x ~b~%s~s~ za ~g~%s $~s~', + ['not_enough'] = 'nie masz ~r~wystarczjąco~s~ pięniędzy, ~y~Brakuje Ci~s~ ~r~$%s~s~!', + ['player_cannot_hold'] = '~r~Nie~s~ masz wystarczająco ~y~wolnego miejsca~s~ w swoim ekwipunku!', + ['shop_confirm'] = 'chcesz kupić %sx %s za $%s?', + ['no'] = 'nie', + ['yes'] = 'tak', +} diff --git a/locales/sv.lua b/locales/sv.lua index 1ea36395..9666d4e4 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -1,11 +1,11 @@ Locales['sv'] = { - ['shop'] = 'affär', - ['shops'] = 'affärer', - ['press_menu'] = 'tryck ~INPUT_CONTEXT~ för att ~y~handla prylar~s~.', - ['bought'] = 'du har köpt ~y~%sx~s~ ~b~%s~s~ för ~r~%s SEK~s~', - ['not_enough'] = 'du har inte ~r~tillräckligt~s~ med pengar, det ~y~saknas~s~ ~r~%s SEK~s~!', - ['player_cannot_hold'] = 'du har ~r~inte~s~ tillräckligt med ~y~utrymme~s~ för att hålla det!', - ['shop_confirm'] = 'köpa %sx %s för %s SEK?', - ['no'] = 'nej', - ['yes'] = 'ja', -} \ No newline at end of file + ['shop'] = 'affär', + ['shops'] = 'affärer', + ['press_menu'] = 'tryck ~INPUT_CONTEXT~ för att ~y~handla prylar~s~.', + ['bought'] = 'du har köpt ~y~%sx~s~ ~b~%s~s~ för ~r~%s SEK~s~', + ['not_enough'] = 'du har inte ~r~tillräckligt~s~ med pengar, det ~y~saknas~s~ ~r~%s SEK~s~!', + ['player_cannot_hold'] = 'du har ~r~inte~s~ tillräckligt med ~y~utrymme~s~ för att hålla det!', + ['shop_confirm'] = 'köpa %sx %s för %s SEK?', + ['no'] = 'nej', + ['yes'] = 'ja', +} From e22733857330e9a646b3dd1d08a1c06ab06209b1 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 19 Nov 2018 18:58:06 +0100 Subject: [PATCH 33/64] Proper data items in locale, resolves #34 --- client/main.lua | 5 +++-- locales/br.lua | 1 + locales/de.lua | 1 + locales/en.lua | 1 + locales/es.lua | 1 + locales/fi.lua | 1 + locales/fr.lua | 1 + locales/pl.lua | 1 + locales/sv.lua | 1 + 9 files changed, 11 insertions(+), 2 deletions(-) diff --git a/client/main.lua b/client/main.lua index c15fdad2..dbde00d3 100644 --- a/client/main.lua +++ b/client/main.lua @@ -42,7 +42,7 @@ function OpenShopMenu(zone) end table.insert(elements, { - label = item.label .. ' - $' .. ESX.Math.GroupDigits(item.price) .. '', + label = ('%s - %s'):format(item.label, _U('shop_item', ESX.Math.GroupDigits(item.price))), label_real = item.label, item = item.item, price = item.price, @@ -62,7 +62,7 @@ function OpenShopMenu(zone) elements = elements }, function(data, menu) ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', { - title = _U('shop_confirm', data.current.value, data.current.label_real, data.current.price * data.current.value), + title = _U('shop_confirm', data.current.value, data.current.label_real, ESX.Math.GroupDigits(data.current.price * data.current.value)), align = 'bottom-right', elements = { {label = _U('no'), value = 'no'}, @@ -79,6 +79,7 @@ function OpenShopMenu(zone) end) end, function(data, menu) menu.close() + CurrentAction = 'shop_menu' CurrentActionMsg = _U('press_menu') CurrentActionData = {zone = zone} diff --git a/locales/br.lua b/locales/br.lua index 9bace0e8..b3182a66 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -2,6 +2,7 @@ Locales['br'] = { ['shop'] = 'comprar', ['shops'] = 'lojas', ['press_menu'] = 'pressione ~INPUT_CONTEXT~ para acessar a loja.', + ['shop_item'] = '$%s', ['bought'] = 'você acabou de comprar ~y~%sx~s~ ~b~%s~s~ por ~r~$%s~s~', ['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~: %s', ['player_cannot_hold'] = 'você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!', diff --git a/locales/de.lua b/locales/de.lua index 8da7e842..3081beee 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -2,6 +2,7 @@ Locales['de'] = { ['shop'] = 'geschäft', ['shops'] = 'geschäfte', ['press_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', + ['shop_item'] = '$%s', ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', ['not_enough'] = 'du ~r~hast nicht~s~ genug geld: %s', ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', diff --git a/locales/en.lua b/locales/en.lua index f504fedc..9879faa7 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -2,6 +2,7 @@ Locales['en'] = { ['shop'] = 'shop', ['shops'] = 'shops', ['press_menu'] = 'press ~INPUT_CONTEXT~ to access the ~y~store~s~.', + ['shop_item'] = '$%s', ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', ['not_enough'] = 'you do not have ~r~enough~s~ money, you\'re ~y~missing~s~ ~r~$%s~s~!', ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', diff --git a/locales/es.lua b/locales/es.lua index 327981a1..f31e5e9b 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -2,6 +2,7 @@ Locales['es'] = { ['shop'] = 'tienda', ['shops'] = 'tiendas', ['press_menu'] = 'presiona ~INPUT_CONTEXT~ para acceder a la tienda.', + ['shop_item'] = '$%s', ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', ['not_enough'] = 'no tienes ~r~suficiente ~s~ dinero: %s', ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', diff --git a/locales/fi.lua b/locales/fi.lua index c2c9c567..6ee317e0 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -2,6 +2,7 @@ Locales['fi'] = { ['shop'] = 'kauppa', ['shops'] = 'kaupat', ['press_menu'] = 'paina ~INPUT_CONTEXT~ ostaaksesi jotain ~y~kaupasta~s~.', + ['shop_item'] = '$%s', ['bought'] = 'Sinä ostit juuri ~y~%sx~s~ ~b~%s~s~. Summaksi tuli ~r~$%s~s~', ['not_enough'] = 'sinulla ei ole ~r~tarpeeksi~s~ rahaa, sinulta ~y~puuttuu~s~ ~r~$%s~s~!', ['player_cannot_hold'] = 'sinulla ~r~ei ole~s~ tarpeeksi ~y~tilaa~s~ repussasi!', diff --git a/locales/fr.lua b/locales/fr.lua index 7494b137..c61da5df 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -2,6 +2,7 @@ Locales['fr'] = { ['shop'] = 'magasin', ['shops'] = 'magasins', ['press_menu'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.', + ['shop_item'] = '$%s', ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', ['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent: %s', ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', diff --git a/locales/pl.lua b/locales/pl.lua index accbf9fb..2b705713 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -2,6 +2,7 @@ Locales['pl'] = { ['shop'] = 'sklep', ['shops'] = 'sklepy', ['press_menu'] = 'naciśnij ~INPUT_CONTEXT~ żeby wejść do ~y~sklepu~s~.', + ['shop_item'] = '$%s', ['bought'] = 'właśnie zakupiłeś ~y~%s~s~ x ~b~%s~s~ za ~g~%s $~s~', ['not_enough'] = 'nie masz ~r~wystarczjąco~s~ pięniędzy, ~y~Brakuje Ci~s~ ~r~$%s~s~!', ['player_cannot_hold'] = '~r~Nie~s~ masz wystarczająco ~y~wolnego miejsca~s~ w swoim ekwipunku!', diff --git a/locales/sv.lua b/locales/sv.lua index 9666d4e4..40658757 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -2,6 +2,7 @@ Locales['sv'] = { ['shop'] = 'affär', ['shops'] = 'affärer', ['press_menu'] = 'tryck ~INPUT_CONTEXT~ för att ~y~handla prylar~s~.', + ['shop_item'] = '%s SEK', ['bought'] = 'du har köpt ~y~%sx~s~ ~b~%s~s~ för ~r~%s SEK~s~', ['not_enough'] = 'du har inte ~r~tillräckligt~s~ med pengar, det ~y~saknas~s~ ~r~%s SEK~s~!', ['player_cannot_hold'] = 'du har ~r~inte~s~ tillräckligt med ~y~utrymme~s~ för att hålla det!', From 6fc21c8415163a55f39b7200be6a359c8a53affe Mon Sep 17 00:00:00 2001 From: Cedric LECOMTE Date: Tue, 20 Nov 2018 13:12:34 +0100 Subject: [PATCH 34/64] Fix french localization. --- locales/fr.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locales/fr.lua b/locales/fr.lua index c61da5df..b789e767 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -3,10 +3,10 @@ Locales['fr'] = { ['shops'] = 'magasins', ['press_menu'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.', ['shop_item'] = '$%s', - ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['bought'] = 'vous venez d\'acheter ~y~%sx~s~ ~b~%s~s~ pour ~r~$%s~s~', ['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent: %s', - ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', - ['shop_confirm'] = 'buy %sx %s for $%s?', - ['no'] = 'no', - ['yes'] = 'yes', + ['player_cannot_hold'] = 'vous n\'avez ~r~pas~s~ assez ~y~de place~s~ dans votre inventaire!', + ['shop_confirm'] = 'acheter %sx %s pour $%s?', + ['no'] = 'non', + ['yes'] = 'oui', } From 8bc906f518aa4082fb73a6777f7d7feb51195c45 Mon Sep 17 00:00:00 2001 From: Cedric LECOMTE Date: Tue, 20 Nov 2018 15:02:50 +0100 Subject: [PATCH 35/64] Optimize shop object loading --- server/main.lua | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/server/main.lua b/server/main.lua index 85146473..bba83bad 100644 --- a/server/main.lua +++ b/server/main.lua @@ -5,35 +5,23 @@ TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -- Load items MySQL.ready(function() - local itemResult = MySQL.Sync.fetchAll('SELECT * FROM items') - local shopResult = MySQL.Sync.fetchAll('SELECT * FROM shops') - - local itemInformation = {} - for i=1, #itemResult, 1 do - - if itemInformation[itemResult[i].name] == nil then - itemInformation[itemResult[i].name] = {} - end - - itemInformation[itemResult[i].name].label = itemResult[i].label - itemInformation[itemResult[i].name].limit = itemResult[i].limit - end +local shopResult = MySQL.Sync.fetchAll('SELECT * FROM shops LEFT JOIN items ON items.name = shops.item') for i=1, #shopResult, 1 do - if itemInformation[shopResult[i].item] then - if ShopItems[shopResult[i].store] == nil then + if shopResult[i].name ~= NULL then + if ShopItems[shopResult[i].name] == nil then ShopItems[shopResult[i].store] = {} end - if itemInformation[shopResult[i].item].limit == -1 then - itemInformation[shopResult[i].item].limit = 30 + if shopResult[i].limit == -1 then + shopResult[i].limit = 30 end table.insert(ShopItems[shopResult[i].store], { - label = itemInformation[shopResult[i].item].label, + label = shopResult[i].label, item = shopResult[i].item, price = shopResult[i].price, - limit = itemInformation[shopResult[i].item].limit + limit = shopResult[i].limit }) else print(('esx_shops: invalid item "%s" found!'):format(shopResult[i].item)) @@ -87,4 +75,4 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) local missingMoney = price - xPlayer.getMoney() TriggerClientEvent('esx:showNotification', _source, _U('not_enough', ESX.Math.GroupDigits(missingMoney))) end -end) \ No newline at end of file +end) From c975980198c60b7e704f3dc2181884cd955e1e2a Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Tue, 20 Nov 2018 19:39:37 +0100 Subject: [PATCH 36/64] Switched to async fetch, fixed issue where only the last item would appear. --- server/main.lua | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/server/main.lua b/server/main.lua index bba83bad..8c1ec5f5 100644 --- a/server/main.lua +++ b/server/main.lua @@ -3,30 +3,29 @@ local ShopItems = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) --- Load items MySQL.ready(function() -local shopResult = MySQL.Sync.fetchAll('SELECT * FROM shops LEFT JOIN items ON items.name = shops.item') + MySQL.Async.fetchAll('SELECT * FROM shops LEFT JOIN items ON items.name = shops.item', {}, function(shopResult) + for i=1, #shopResult, 1 do + if shopResult[i].name then + if ShopItems[shopResult[i].store] == nil then + ShopItems[shopResult[i].store] = {} + end - for i=1, #shopResult, 1 do - if shopResult[i].name ~= NULL then - if ShopItems[shopResult[i].name] == nil then - ShopItems[shopResult[i].store] = {} + if shopResult[i].limit == -1 then + shopResult[i].limit = 30 + end + + table.insert(ShopItems[shopResult[i].store], { + label = shopResult[i].label, + item = shopResult[i].item, + price = shopResult[i].price, + limit = shopResult[i].limit + }) + else + print(('esx_shops: invalid item "%s" found!'):format(shopResult[i].item)) end - - if shopResult[i].limit == -1 then - shopResult[i].limit = 30 - end - - table.insert(ShopItems[shopResult[i].store], { - label = shopResult[i].label, - item = shopResult[i].item, - price = shopResult[i].price, - limit = shopResult[i].limit - }) - else - print(('esx_shops: invalid item "%s" found!'):format(shopResult[i].item)) end - end + end) end) ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb) From 51d7c83c7f1d4c54fb4b92f9000e0d07282caf19 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 30 Dec 2018 20:59:06 +0100 Subject: [PATCH 37/64] Check IsControlJustReleased() every frame --- client/main.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/main.lua b/client/main.lua index dbde00d3..5d66a8b6 100644 --- a/client/main.lua +++ b/client/main.lua @@ -118,7 +118,7 @@ end) Citizen.CreateThread(function() while true do Citizen.Wait(0) - local coords = GetEntityCoords(GetPlayerPed(-1)) + local coords = GetEntityCoords(PlayerPedId()) for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do @@ -133,8 +133,8 @@ end) -- Enter / Exit marker events Citizen.CreateThread(function() while true do - Citizen.Wait(10) - local coords = GetEntityCoords(GetPlayerPed(-1)) + Citizen.Wait(0) + local coords = GetEntityCoords(PlayerPedId()) local isInMarker = false local currentZone = nil @@ -162,7 +162,7 @@ end) -- Key Controls Citizen.CreateThread(function() while true do - Citizen.Wait(10) + Citizen.Wait(0) if CurrentAction ~= nil then ESX.ShowHelpNotification(CurrentActionMsg) From d7ceb92d562819978d4d43c8308316bffb5d182d Mon Sep 17 00:00:00 2001 From: BackrndSource Date: Wed, 27 Mar 2019 12:36:14 +0000 Subject: [PATCH 38/64] Update es.lua --- locales/es.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/locales/es.lua b/locales/es.lua index f31e5e9b..c422abc1 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -1,12 +1,12 @@ Locales['es'] = { ['shop'] = 'tienda', ['shops'] = 'tiendas', - ['press_menu'] = 'presiona ~INPUT_CONTEXT~ para acceder a la tienda.', - ['shop_item'] = '$%s', - ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['press_menu'] = 'pulsa ~INPUT_CONTEXT~ para comprar en la tienda.', + ['shop_item'] = '%s€', + ['bought'] = 'has comprado ~y~%sx~s~ ~b~%s~s~ por ~r~%s€~s~', ['not_enough'] = 'no tienes ~r~suficiente ~s~ dinero: %s', - ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', - ['shop_confirm'] = 'buy %sx %s for $%s?', + ['player_cannot_hold'] = 'no tienes ~y~espacio libre~s~ en tu inventario...', + ['shop_confirm'] = '¿Comprar %sx %s por $%s?', ['no'] = 'no', - ['yes'] = 'yes', + ['yes'] = 'si', } From cd0ede58651d137ffefe6ef426329f4d7e409b42 Mon Sep 17 00:00:00 2001 From: SurDaft - Jack Stupple Date: Mon, 6 May 2019 01:08:58 +0100 Subject: [PATCH 39/64] fix empty shop bug --- client/main.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/main.lua b/client/main.lua index 5d66a8b6..f4a9ad7e 100644 --- a/client/main.lua +++ b/client/main.lua @@ -27,6 +27,10 @@ Citizen.CreateThread(function() ESX.TriggerServerCallback('esx_shops:requestDBItems', function(ShopItems) for k,v in pairs(ShopItems) do + if (Config.Zones[k] == nil) then + Config.Zones[k] = {} + end + Config.Zones[k].Items = v end end) From d78f21d08344d62df82fe56c6a2d4bf17afcc105 Mon Sep 17 00:00:00 2001 From: SurDaft - Jack Stupple Date: Mon, 6 May 2019 01:37:23 +0100 Subject: [PATCH 40/64] Fix markers not showing --- client/main.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/main.lua b/client/main.lua index f4a9ad7e..341c446a 100644 --- a/client/main.lua +++ b/client/main.lua @@ -28,7 +28,10 @@ Citizen.CreateThread(function() ESX.TriggerServerCallback('esx_shops:requestDBItems', function(ShopItems) for k,v in pairs(ShopItems) do if (Config.Zones[k] == nil) then - Config.Zones[k] = {} + Config.Zones[k] = { + Items = {}, + Pos = {} + } end Config.Zones[k].Items = v From 18b16dea70d070dfca8e0573506457d070490126 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sat, 12 Oct 2019 23:42:21 +0200 Subject: [PATCH 41/64] Removed keys table --- client/main.lua | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/client/main.lua b/client/main.lua index 5d66a8b6..7e039a26 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,15 +1,3 @@ -local Keys = { - ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, - ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, - ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, - ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, - ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, - ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, - ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, - ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, - ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 -} - ESX = nil local HasAlreadyEnteredMarker = false local LastZone = nil @@ -167,7 +155,7 @@ Citizen.CreateThread(function() if CurrentAction ~= nil then ESX.ShowHelpNotification(CurrentActionMsg) - if IsControlJustReleased(0, Keys['E']) then + if IsControlJustReleased(0, 38) then if CurrentAction == 'shop_menu' then OpenShopMenu(CurrentActionData.zone) end From 4efea53b37479be788886a7d6dff5d29a9c9c478 Mon Sep 17 00:00:00 2001 From: Poggu <45881722+Poggicek@users.noreply.github.com> Date: Sat, 19 Oct 2019 19:35:54 +0200 Subject: [PATCH 42/64] Added weight support (#65) * Added weight support --- client/main.lua | 8 ++------ server/main.lua | 15 +++++---------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/client/main.lua b/client/main.lua index 7e039a26..c07ad686 100644 --- a/client/main.lua +++ b/client/main.lua @@ -25,10 +25,6 @@ function OpenShopMenu(zone) for i=1, #Config.Zones[zone].Items, 1 do local item = Config.Zones[zone].Items[i] - if item.limit == -1 then - item.limit = 100 - end - table.insert(elements, { label = ('%s - %s'):format(item.label, _U('shop_item', ESX.Math.GroupDigits(item.price))), label_real = item.label, @@ -39,7 +35,7 @@ function OpenShopMenu(zone) value = 1, type = 'slider', min = 1, - max = item.limit + max = 100 }) end @@ -166,4 +162,4 @@ Citizen.CreateThread(function() Citizen.Wait(500) end end -end) +end) \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index 8c1ec5f5..dfb052b0 100644 --- a/server/main.lua +++ b/server/main.lua @@ -11,15 +11,10 @@ MySQL.ready(function() ShopItems[shopResult[i].store] = {} end - if shopResult[i].limit == -1 then - shopResult[i].limit = 30 - end - table.insert(ShopItems[shopResult[i].store], { label = shopResult[i].label, item = shopResult[i].item, price = shopResult[i].price, - limit = shopResult[i].limit }) else print(('esx_shops: invalid item "%s" found!'):format(shopResult[i].item)) @@ -63,15 +58,15 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) -- can the player afford this item? if xPlayer.getMoney() >= price then -- can the player carry the said amount of x item? - if sourceItem.limit ~= -1 and (sourceItem.count + amount) > sourceItem.limit then - TriggerClientEvent('esx:showNotification', _source, _U('player_cannot_hold')) - else + if xPlayer.canCarryItem(itemName, amount) then xPlayer.removeMoney(price) xPlayer.addInventoryItem(itemName, amount) - TriggerClientEvent('esx:showNotification', _source, _U('bought', amount, itemLabel, ESX.Math.GroupDigits(price))) + xPlayer.showNotification(_U('bought', amount, itemLabel, ESX.Math.GroupDigits(price)) + else + xPlayer.showNotification(_U('player_cannot_hold')) end else local missingMoney = price - xPlayer.getMoney() - TriggerClientEvent('esx:showNotification', _source, _U('not_enough', ESX.Math.GroupDigits(missingMoney))) + xPlayer.showNotification(_U('not_enough', ESX.Math.GroupDigits(missingMoney)) end end) From 549c28ff617ee48059b7fb2dd9e69b9c3fd95f56 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 20 Oct 2019 09:50:32 +0200 Subject: [PATCH 43/64] Fixed #66, cleanup code --- client/main.lua | 101 ++++++++++++++++++++++-------------------------- server/main.lua | 4 +- 2 files changed, 49 insertions(+), 56 deletions(-) diff --git a/client/main.lua b/client/main.lua index c07ad686..c6df4379 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,9 +1,6 @@ -ESX = nil -local HasAlreadyEnteredMarker = false -local LastZone = nil -local CurrentAction = nil -local CurrentActionMsg = '' -local CurrentActionData = {} +ESX = nil +local hasAlreadyEnteredMarker, lastZone +local currentAction, currentActionMsg, currentActionData = nil, nil, {} Citizen.CreateThread(function() while ESX == nil do @@ -27,7 +24,7 @@ function OpenShopMenu(zone) table.insert(elements, { label = ('%s - %s'):format(item.label, _U('shop_item', ESX.Math.GroupDigits(item.price))), - label_real = item.label, + itemLabel = item.label, item = item.item, price = item.price, @@ -40,19 +37,19 @@ function OpenShopMenu(zone) end ESX.UI.Menu.CloseAll() + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', { title = _U('shop'), align = 'bottom-right', elements = elements }, function(data, menu) ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', { - title = _U('shop_confirm', data.current.value, data.current.label_real, ESX.Math.GroupDigits(data.current.price * data.current.value)), + title = _U('shop_confirm', data.current.value, data.current.itemLabel, ESX.Math.GroupDigits(data.current.price * data.current.value)), align = 'bottom-right', elements = { {label = _U('no'), value = 'no'}, {label = _U('yes'), value = 'yes'} - } - }, function(data2, menu2) + }}, function(data2, menu2) if data2.current.value == 'yes' then TriggerServerEvent('esx_shops:buyItem', data.current.item, data.current.value, zone) end @@ -64,20 +61,20 @@ function OpenShopMenu(zone) end, function(data, menu) menu.close() - CurrentAction = 'shop_menu' - CurrentActionMsg = _U('press_menu') - CurrentActionData = {zone = zone} + currentAction = 'shop_menu' + currentActionMsg = _U('press_menu') + currentActionData = {zone = zone} end) end AddEventHandler('esx_shops:hasEnteredMarker', function(zone) - CurrentAction = 'shop_menu' - CurrentActionMsg = _U('press_menu') - CurrentActionData = {zone = zone} + currentAction = 'shop_menu' + currentActionMsg = _U('press_menu') + currentActionData = {zone = zone} end) AddEventHandler('esx_shops:hasExitedMarker', function(zone) - CurrentAction = nil + currentAction = nil ESX.UI.Menu.CloseAll() end) @@ -86,59 +83,55 @@ Citizen.CreateThread(function() for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z) + SetBlipSprite (blip, 52) - SetBlipDisplay(blip, 4) SetBlipScale (blip, 1.0) SetBlipColour (blip, 2) SetBlipAsShortRange(blip, true) - BeginTextCommandSetBlipName("STRING") - AddTextComponentString(_U('shops')) + + BeginTextCommandSetBlipName('STRING') + AddTextComponentSubstringPlayerName(_U('shops')) EndTextCommandSetBlipName(blip) end end end) --- Display markers -Citizen.CreateThread(function() - while true do - Citizen.Wait(0) - local coords = GetEntityCoords(PlayerPedId()) - - for k,v in pairs(Config.Zones) do - for i = 1, #v.Pos, 1 do - if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then - DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false) - end - end - end - end -end) - -- Enter / Exit marker events Citizen.CreateThread(function() while true do Citizen.Wait(0) - local coords = GetEntityCoords(PlayerPedId()) - local isInMarker = false - local currentZone = nil + local playerCoords = GetEntityCoords(PlayerPedId()) + local isInMarker, letSleep, currentZone = false, false for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do - if(GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.Size.x) then - isInMarker = true - ShopItems = v.Items - currentZone = k - LastZone = k + local distance = GetDistanceBetweenCoords(playerCoords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) + + if distance < Config.DrawDistance then + DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, nil, nil, false) + letSleep = false + + if distance < Config.Size.x then + isInMarker = true + currentZone = k + lastZone = k + end end end end - if isInMarker and not HasAlreadyEnteredMarker then - HasAlreadyEnteredMarker = true + + if isInMarker and not hasAlreadyEnteredMarker then + hasAlreadyEnteredMarker = true TriggerEvent('esx_shops:hasEnteredMarker', currentZone) end - if not isInMarker and HasAlreadyEnteredMarker then - HasAlreadyEnteredMarker = false - TriggerEvent('esx_shops:hasExitedMarker', LastZone) + + if not isInMarker and hasAlreadyEnteredMarker then + hasAlreadyEnteredMarker = false + TriggerEvent('esx_shops:hasExitedMarker', lastZone) + end + + if letSleep then + Citizen.Wait(500) end end end) @@ -148,15 +141,15 @@ Citizen.CreateThread(function() while true do Citizen.Wait(0) - if CurrentAction ~= nil then - ESX.ShowHelpNotification(CurrentActionMsg) + if currentAction then + ESX.ShowHelpNotification(currentActionMsg) if IsControlJustReleased(0, 38) then - if CurrentAction == 'shop_menu' then - OpenShopMenu(CurrentActionData.zone) + if currentAction == 'shop_menu' then + OpenShopMenu(currentActionData.zone) end - CurrentAction = nil + currentAction = nil end else Citizen.Wait(500) diff --git a/server/main.lua b/server/main.lua index dfb052b0..9660dd18 100644 --- a/server/main.lua +++ b/server/main.lua @@ -61,12 +61,12 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) if xPlayer.canCarryItem(itemName, amount) then xPlayer.removeMoney(price) xPlayer.addInventoryItem(itemName, amount) - xPlayer.showNotification(_U('bought', amount, itemLabel, ESX.Math.GroupDigits(price)) + xPlayer.showNotification(_U('bought', amount, itemLabel, ESX.Math.GroupDigits(price))) else xPlayer.showNotification(_U('player_cannot_hold')) end else local missingMoney = price - xPlayer.getMoney() - xPlayer.showNotification(_U('not_enough', ESX.Math.GroupDigits(missingMoney)) + xPlayer.showNotification(_U('not_enough', ESX.Math.GroupDigits(missingMoney))) end end) From 3eb220ad5ac47a36af2cde5c066f02ba20e93633 Mon Sep 17 00:00:00 2001 From: rex2630 Date: Tue, 12 Nov 2019 21:36:12 +0100 Subject: [PATCH 44/64] Removed unused variable --- server/main.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/server/main.lua b/server/main.lua index 9660dd18..6b9a2bb5 100644 --- a/server/main.lua +++ b/server/main.lua @@ -31,7 +31,6 @@ RegisterServerEvent('esx_shops:buyItem') AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) - local sourceItem = xPlayer.getInventoryItem(itemName) amount = ESX.Math.Round(amount) From 0214e834783f14830ac9dcc79559ff4eebc69e9f Mon Sep 17 00:00:00 2001 From: rex2630 Date: Sun, 19 Jan 2020 17:41:15 +0100 Subject: [PATCH 45/64] Replace __resource.lua with fxmanifest.lua --- __resource.lua => fxmanifest.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename __resource.lua => fxmanifest.lua (89%) diff --git a/__resource.lua b/fxmanifest.lua similarity index 89% rename from __resource.lua rename to fxmanifest.lua index bf1ee68e..3bb6d04d 100644 --- a/__resource.lua +++ b/fxmanifest.lua @@ -1,4 +1,6 @@ -resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' +fx_version 'adamant' + +game 'gta5' description 'ESX Shops' From fe041c05b844a41b555109768af55be425d7ae6c Mon Sep 17 00:00:00 2001 From: rex2630 Date: Thu, 27 Feb 2020 13:30:13 +0100 Subject: [PATCH 46/64] Moved all coords to vector3 types --- config.lua | 63 ++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/config.lua b/config.lua index e1d07b2b..f2b1f236 100644 --- a/config.lua +++ b/config.lua @@ -1,49 +1,46 @@ -Config = {} +Config = {} Config.DrawDistance = 100 -Config.Size = {x = 1.5, y = 1.5, z = 1.5} -Config.Color = {r = 0, g = 128, b = 255} -Config.Type = 1 -Config.Locale = 'en' +Config.Size = {x = 1.5, y = 1.5, z = 1.5} +Config.Color = {r = 0, g = 128, b = 255} +Config.Type = 1 +Config.Locale = 'en' Config.Zones = { TwentyFourSeven = { Items = {}, Pos = { - {x = 373.875, y = 325.896, z = 102.566}, - {x = 2557.458, y = 382.282, z = 107.622}, - {x = -3038.939, y = 585.954, z = 6.908}, - {x = -3241.927, y = 1001.462, z = 11.830}, - {x = 547.431, y = 2671.710, z = 41.156}, - {x = 1961.464, y = 3740.672, z = 31.343}, - {x = 2678.916, y = 3280.671, z = 54.241}, - {x = 1729.216, y = 6414.131, z = 34.037} - } - }, + vector3(373.8, 325.8, 102.5), + vector3(2557.4, 382.2, 107.6), + vector3(-3038.9, 585.9, 6.9), + vector3(-3241.9, 1001.4, 11.8), + vector3(547.4, 2671.7, 41.1), + vector3(1961.4, 3740.6, 31.3), + vector3(2678.9, 3280.6, 54.2), + vector3(1729.2, 6414.1, 34.0) + }}, RobsLiquor = { Items = {}, Pos = { - {x = 1135.808, y = -982.281, z = 45.415}, - {x = -1222.915, y = -906.983, z = 11.326}, - {x = -1487.553, y = -379.107, z = 39.163}, - {x = -2968.243, y = 390.910, z = 14.043}, - {x = 1166.024, y = 2708.930, z = 37.157}, - {x = 1392.562, y = 3604.684, z = 33.980}, - {x = 127.830, y = -1284.796, z = 28.280}, --StripClub - {x = -1393.409, y = -606.624, z = 29.319}, --Tequila la - {x = -559.906, y = 287.093, z = 81.176} --Bahamamas - } - }, + vector3(1135.8, -982.2, 45.4), + vector3(-1222.9, -906.9, 11.3), + vector3(-1487.5, -379.1, 39.1), + vector3(-2968.2, 390.9, 14.0), + vector3(1166.0, 2708.9, 37.1), + vector3(1392.5, 3604.6, 33.9), + vector3(127.8, -1284.7, 28.2), --StripClub + vector3(-1393.4, -606.6, 29.3), --Tequila la + vector3(-559.9, 287.0, 81.1) --Bahamamas + }}, LTDgasoline = { Items = {}, Pos = { - {x = -48.519, y = -1757.514, z = 28.421}, - {x = 1163.373, y = -323.801, z = 68.205}, - {x = -707.501, y = -914.260, z = 18.215}, - {x = -1820.523, y = 792.518, z = 137.118}, - {x = 1698.388, y = 4924.404, z = 41.063} - } - } + vector3(-48.5, -1757.5, 28.4), + vector3(1163.3, -323.8, 68.2), + vector3(-707.5, -914.2, 18.2), + vector3(-1820.5, 792.5, 137.1), + vector3(1698.3, 4924.4, 41.0) + }} } From aefe034d6c2190ad053723d1be64fd100ea5ae9a Mon Sep 17 00:00:00 2001 From: rex2630 Date: Thu, 27 Feb 2020 13:35:26 +0100 Subject: [PATCH 47/64] Moved all coords to vector3 types --- client/main.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/main.lua b/client/main.lua index c6df4379..fc33dabc 100644 --- a/client/main.lua +++ b/client/main.lua @@ -82,7 +82,7 @@ end) Citizen.CreateThread(function() for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do - local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z) + local blip = AddBlipForCoord(v.Pos[i]) SetBlipSprite (blip, 52) SetBlipScale (blip, 1.0) @@ -108,7 +108,7 @@ Citizen.CreateThread(function() local distance = GetDistanceBetweenCoords(playerCoords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) if distance < Config.DrawDistance then - DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, nil, nil, false) + DrawMarker(Config.Type, v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, nil, nil, false) letSleep = false if distance < Config.Size.x then @@ -155,4 +155,4 @@ Citizen.CreateThread(function() Citizen.Wait(500) end end -end) \ No newline at end of file +end) From d477fce1d547aece6fccc0dbb10f289866bb6f9f Mon Sep 17 00:00:00 2001 From: Marvbell110 <34713144+Marvbell110@users.noreply.github.com> Date: Wed, 4 Mar 2020 19:59:44 +0100 Subject: [PATCH 48/64] Update de.lua --- locales/de.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/locales/de.lua b/locales/de.lua index 3081beee..dfbd318a 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -3,10 +3,10 @@ Locales['de'] = { ['shops'] = 'geschäfte', ['press_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', ['shop_item'] = '$%s', - ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', - ['not_enough'] = 'du ~r~hast nicht~s~ genug geld: %s', - ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', - ['shop_confirm'] = 'buy %sx %s for $%s?', - ['no'] = 'no', - ['yes'] = 'yes', + ['bought'] = '~y~%sx~s~ ~b~%s~s~ wurde gekauft für ~r~$%s~s~.', + ['not_enough'] = '~r~ $%s fehlen dir!', + ['player_cannot_hold'] = 'du hast ~r~nicht genug~s~ ~y~freien Platz~s~, in deinem Inventar!', + ['shop_confirm'] = 'kaufe %sx %s für $%s?', + ['no'] = 'Nein', + ['yes'] = 'Ja', } From 34df4887553ed4eccd78830842c94ab03b7be6e9 Mon Sep 17 00:00:00 2001 From: rex2630 Date: Thu, 19 Mar 2020 23:01:19 +0100 Subject: [PATCH 49/64] French as default locale --- config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.lua b/config.lua index f2b1f236..d91b057b 100644 --- a/config.lua +++ b/config.lua @@ -3,7 +3,7 @@ Config.DrawDistance = 100 Config.Size = {x = 1.5, y = 1.5, z = 1.5} Config.Color = {r = 0, g = 128, b = 255} Config.Type = 1 -Config.Locale = 'en' +Config.Locale = 'fr' Config.Zones = { From 9d81a54b7633c963cc7bf1be8b1e48b30ea8aece Mon Sep 17 00:00:00 2001 From: rex2630 Date: Thu, 19 Mar 2020 23:03:31 +0100 Subject: [PATCH 50/64] vector distance check --- client/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/main.lua b/client/main.lua index fc33dabc..f965778b 100644 --- a/client/main.lua +++ b/client/main.lua @@ -105,7 +105,7 @@ Citizen.CreateThread(function() for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do - local distance = GetDistanceBetweenCoords(playerCoords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) + local distance = #(playerCoords - vector3(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z)) if distance < Config.DrawDistance then DrawMarker(Config.Type, v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, nil, nil, false) From dcc2aa762fcf9afd6c71976c5fd73a7dc67c009d Mon Sep 17 00:00:00 2001 From: Marvbell110 <34713144+Marvbell110@users.noreply.github.com> Date: Sat, 21 Mar 2020 14:20:39 +0100 Subject: [PATCH 51/64] Update de.lua --- locales/de.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/locales/de.lua b/locales/de.lua index dfbd318a..2e0093cf 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -1,12 +1,12 @@ Locales['de'] = { ['shop'] = 'geschäft', ['shops'] = 'geschäfte', - ['press_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', + ['press_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen', ['shop_item'] = '$%s', - ['bought'] = '~y~%sx~s~ ~b~%s~s~ wurde gekauft für ~r~$%s~s~.', - ['not_enough'] = '~r~ $%s fehlen dir!', - ['player_cannot_hold'] = 'du hast ~r~nicht genug~s~ ~y~freien Platz~s~, in deinem Inventar!', + ['bought'] = '~y~%sx~s~ ~b~%s~s~ wurde gekauft für ~r~$%s~s~', + ['not_enough'] = '~r~ $%s fehlen dir', + ['player_cannot_hold'] = 'du hast ~r~nicht genug~s~ ~y~freien Platz~s~, in deinem Inventar', ['shop_confirm'] = 'kaufe %sx %s für $%s?', - ['no'] = 'Nein', - ['yes'] = 'Ja', + ['no'] = 'nein', + ['yes'] = 'ja', } From 77bd7fa334083b5bb1e260a11d77b07cb0b63154 Mon Sep 17 00:00:00 2001 From: rex2630 Date: Sat, 21 Mar 2020 16:34:36 +0100 Subject: [PATCH 52/64] vector check fixed --- client/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/main.lua b/client/main.lua index f965778b..4e1c18ab 100644 --- a/client/main.lua +++ b/client/main.lua @@ -105,7 +105,7 @@ Citizen.CreateThread(function() for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do - local distance = #(playerCoords - vector3(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z)) + local distance = #(playerCoords - v.Pos[i]) if distance < Config.DrawDistance then DrawMarker(Config.Type, v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, nil, nil, false) From 797ed36eefadc00003b60b76af5f5d23dfb1495d Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Tue, 14 Apr 2020 16:52:53 +0200 Subject: [PATCH 53/64] Latest ESX code --- README.md | 2 +- esx_shops.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 670b02a1..40271425 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ start esx_shops ### License esx_shops - shoppin' -Copyright (C) 2015-2018 Jérémie N'gadi +Copyright (C) 2015-2020 Jérémie N'gadi 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. diff --git a/esx_shops.sql b/esx_shops.sql index 0952742d..19131d39 100644 --- a/esx_shops.sql +++ b/esx_shops.sql @@ -1,4 +1,4 @@ -USE `essentialmode`; +USE `es_extended`; CREATE TABLE `shops` ( `id` int(11) NOT NULL AUTO_INCREMENT, From 9b78b2d5c048d73a9105ae6afe59e841ea887141 Mon Sep 17 00:00:00 2001 From: shortybsd Date: Sat, 16 May 2020 23:49:48 -0500 Subject: [PATCH 54/64] Update esx_shops.sql int - Integer display width is deprecated and will be removed in a future release. --- esx_shops.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esx_shops.sql b/esx_shops.sql index 19131d39..e60fdd04 100644 --- a/esx_shops.sql +++ b/esx_shops.sql @@ -1,10 +1,10 @@ USE `es_extended`; CREATE TABLE `shops` ( - `id` int(11) NOT NULL AUTO_INCREMENT, + `id` int NOT NULL AUTO_INCREMENT, `store` varchar(100) NOT NULL, `item` varchar(100) NOT NULL, - `price` int(11) NOT NULL, + `price` int NOT NULL, PRIMARY KEY (`id`) ); @@ -16,4 +16,4 @@ INSERT INTO `shops` (store, item, price) VALUES ('RobsLiquor','water',15), ('LTDgasoline','bread',30), ('LTDgasoline','water',15) -; \ No newline at end of file +; From 926bd84744e7d3cd60904595ba2535a6ae30564d Mon Sep 17 00:00:00 2001 From: btwlouis <56355239+btwlouis@users.noreply.github.com> Date: Fri, 5 Jun 2020 15:08:26 +0200 Subject: [PATCH 55/64] Update de.lua --- locales/de.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locales/de.lua b/locales/de.lua index 3081beee..f8ed240f 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -3,10 +3,10 @@ Locales['de'] = { ['shops'] = 'geschäfte', ['press_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', ['shop_item'] = '$%s', - ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['bought'] = 'du kaufst ~y~%sx~s~ ~b~%s~s~ für ~r~$%s~s~', ['not_enough'] = 'du ~r~hast nicht~s~ genug geld: %s', - ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', - ['shop_confirm'] = 'buy %sx %s for $%s?', - ['no'] = 'no', - ['yes'] = 'yes', + ['player_cannot_hold'] = 'du hast ~r~nicht~s~ genug ~y~Platz~s~ in deinem Inventar', + ['shop_confirm'] = 'Kaufe %sx %s für $%s?', + ['no'] = 'nein', + ['yes'] = 'ja', } From c037507af01a5190e3b0c5b7ecfcf7f5138c2327 Mon Sep 17 00:00:00 2001 From: Ark Date: Mon, 1 Feb 2021 17:04:59 -0600 Subject: [PATCH 56/64] Revert "Merge pull request #85 from Naifen-Phoxidas/master" This reverts commit c4460aa6b3c9475e5119dce41e605bbef34f87b3, reversing changes made to 474cb8569120a7ad9905579ef9b797d8004a9b77. --- locales/de.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/locales/de.lua b/locales/de.lua index 2e0093cf..3081beee 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -1,12 +1,12 @@ Locales['de'] = { ['shop'] = 'geschäft', ['shops'] = 'geschäfte', - ['press_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen', + ['press_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', ['shop_item'] = '$%s', - ['bought'] = '~y~%sx~s~ ~b~%s~s~ wurde gekauft für ~r~$%s~s~', - ['not_enough'] = '~r~ $%s fehlen dir', - ['player_cannot_hold'] = 'du hast ~r~nicht genug~s~ ~y~freien Platz~s~, in deinem Inventar', - ['shop_confirm'] = 'kaufe %sx %s für $%s?', - ['no'] = 'nein', - ['yes'] = 'ja', + ['bought'] = 'you just bought ~y~%sx~s~ ~b~%s~s~ for ~r~$%s~s~', + ['not_enough'] = 'du ~r~hast nicht~s~ genug geld: %s', + ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', + ['shop_confirm'] = 'buy %sx %s for $%s?', + ['no'] = 'no', + ['yes'] = 'yes', } From e1394f629f6b277faf26d0b864fd6629f8123975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9derer=20Andr=C3=A1s?= Date: Sat, 20 Mar 2021 21:00:09 +0100 Subject: [PATCH 57/64] changed fr to en --- config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.lua b/config.lua index d91b057b..f2b1f236 100644 --- a/config.lua +++ b/config.lua @@ -3,7 +3,7 @@ Config.DrawDistance = 100 Config.Size = {x = 1.5, y = 1.5, z = 1.5} Config.Color = {r = 0, g = 128, b = 255} Config.Type = 1 -Config.Locale = 'fr' +Config.Locale = 'en' Config.Zones = { From dae312a0add0103a43503c3d9cb211490fd509b0 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:17:56 +0100 Subject: [PATCH 58/64] Updates --- client/main.lua | 22 ++++-------------- config.lua | 61 +++++++++++++++++++++++++++++++++++++++++-------- server/main.lua | 34 ++++----------------------- 3 files changed, 62 insertions(+), 55 deletions(-) diff --git a/client/main.lua b/client/main.lua index 51f4246c..7e3ed50f 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,18 +10,6 @@ Citizen.CreateThread(function() Citizen.Wait(5000) - ESX.TriggerServerCallback('esx_shops:requestDBItems', function(ShopItems) - for k,v in pairs(ShopItems) do - if (Config.Zones[k] == nil) then - Config.Zones[k] = { - Items = {}, - Pos = {} - } - end - - Config.Zones[k].Items = v - end - end) end) function OpenShopMenu(zone) @@ -91,9 +79,9 @@ Citizen.CreateThread(function() for i = 1, #v.Pos, 1 do local blip = AddBlipForCoord(v.Pos[i]) - SetBlipSprite (blip, 52) - SetBlipScale (blip, 1.0) - SetBlipColour (blip, 2) + SetBlipSprite (blip, v.Type[i]) + SetBlipScale (blip, v.Size[i]) + SetBlipColour (blip, v.Color[i]) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName('STRING') @@ -115,10 +103,10 @@ Citizen.CreateThread(function() local distance = #(playerCoords - v.Pos[i]) if distance < Config.DrawDistance then - DrawMarker(Config.Type, v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, nil, nil, false) + DrawMarker(v.Type[i], v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Size[i].x, v.Size[i].y, v.Size[i].z, v.Color[i].r, v.Color[i].g, v.Color[i].b, 100, false, true, 2, false, nil, nil, false) letSleep = false - if distance < Config.Size.x then + if distance < v.Size[i].x then isInMarker = true currentZone = k lastZone = k diff --git a/config.lua b/config.lua index f2b1f236..915b3d0b 100644 --- a/config.lua +++ b/config.lua @@ -1,14 +1,23 @@ Config = {} Config.DrawDistance = 100 -Config.Size = {x = 1.5, y = 1.5, z = 1.5} -Config.Color = {r = 0, g = 128, b = 255} -Config.Type = 1 Config.Locale = 'en' Config.Zones = { TwentyFourSeven = { - Items = {}, + Items = { + { + name = bread, + label = bread, + price = 100 + }, + { + name = water, + label = bread, + price = 100 + } + } + }, Pos = { vector3(373.8, 325.8, 102.5), vector3(2557.4, 382.2, 107.6), @@ -18,10 +27,25 @@ Config.Zones = { vector3(1961.4, 3740.6, 31.3), vector3(2678.9, 3280.6, 54.2), vector3(1729.2, 6414.1, 34.0) - }}, + }, + Size = {x = 1.0, y = 1.0, z = 1.0} + Type = 59, + Color = {r = 102, g = 102, b = 204, a = 255} +}, RobsLiquor = { - Items = {}, + Items = { + { + name = bread, + label = bread, + price = 100 + }, + { + name = water, + label = bread, + price = 100 + } + }, Pos = { vector3(1135.8, -982.2, 45.4), vector3(-1222.9, -906.9, 11.3), @@ -32,15 +56,34 @@ Config.Zones = { vector3(127.8, -1284.7, 28.2), --StripClub vector3(-1393.4, -606.6, 29.3), --Tequila la vector3(-559.9, 287.0, 81.1) --Bahamamas - }}, + }, + Size = 1.0, + Type = 59, + Color = {r = 102, g = 102, b = 204, a = 255} +}, LTDgasoline = { - Items = {}, + Items = { + { + name = bread, + label = bread, + price = 100 + }, + { + name = water, + label = bread, + price = 100 + } + }, Pos = { vector3(-48.5, -1757.5, 28.4), vector3(1163.3, -323.8, 68.2), vector3(-707.5, -914.2, 18.2), vector3(-1820.5, 792.5, 137.1), vector3(1698.3, 4924.4, 41.0) - }} + }, + Size = 1.0, + Type = 59, + Color = {r = 102, g = 102, b = 204, a = 255} +} } diff --git a/server/main.lua b/server/main.lua index 6b9a2bb5..d003b4a6 100644 --- a/server/main.lua +++ b/server/main.lua @@ -3,30 +3,6 @@ local ShopItems = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -MySQL.ready(function() - MySQL.Async.fetchAll('SELECT * FROM shops LEFT JOIN items ON items.name = shops.item', {}, function(shopResult) - for i=1, #shopResult, 1 do - if shopResult[i].name then - if ShopItems[shopResult[i].store] == nil then - ShopItems[shopResult[i].store] = {} - end - - table.insert(ShopItems[shopResult[i].store], { - label = shopResult[i].label, - item = shopResult[i].item, - price = shopResult[i].price, - }) - else - print(('esx_shops: invalid item "%s" found!'):format(shopResult[i].item)) - end - end - end) -end) - -ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb) - cb(ShopItems) -end) - RegisterServerEvent('esx_shops:buyItem') AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) local _source = source @@ -34,7 +10,6 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) amount = ESX.Math.Round(amount) - -- is the player trying to exploit? if amount < 0 then print('esx_shops: ' .. xPlayer.identifier .. ' attempted to exploit the shop!') return @@ -44,10 +19,11 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) local price = 0 local itemLabel = '' - for i=1, #ShopItems[zone], 1 do - if ShopItems[zone][i].item == itemName then - price = ShopItems[zone][i].price - itemLabel = ShopItems[zone][i].label + for i=1, #Config.Zones[zone].Items, 1 do + local item = Config.Zones[zone].Items[i] + if item.name == itemName then + price = item.price + itemLabel = item.label break end end From 4a10412d9bab942d1efafdf74345a38df8b49673 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:20:04 +0100 Subject: [PATCH 59/64] Update config.lua --- config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.lua b/config.lua index 915b3d0b..d19d599a 100644 --- a/config.lua +++ b/config.lua @@ -85,5 +85,5 @@ Config.Zones = { Size = 1.0, Type = 59, Color = {r = 102, g = 102, b = 204, a = 255} -} +}, } From 78c8139a8b072e838fcf75cd920d97b1ea28babf Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:21:26 +0100 Subject: [PATCH 60/64] Update config.lua --- config.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config.lua b/config.lua index d19d599a..ff3dfb33 100644 --- a/config.lua +++ b/config.lua @@ -16,7 +16,6 @@ Config.Zones = { label = bread, price = 100 } - } }, Pos = { vector3(373.8, 325.8, 102.5), @@ -28,7 +27,7 @@ Config.Zones = { vector3(2678.9, 3280.6, 54.2), vector3(1729.2, 6414.1, 34.0) }, - Size = {x = 1.0, y = 1.0, z = 1.0} + Size = {x = 1.0, y = 1.0, z = 1.0}, Type = 59, Color = {r = 102, g = 102, b = 204, a = 255} }, @@ -85,5 +84,5 @@ Config.Zones = { Size = 1.0, Type = 59, Color = {r = 102, g = 102, b = 204, a = 255} -}, +} } From 390ee49f73028e82fee2cdc609f88f8775c9f375 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:33:29 +0100 Subject: [PATCH 61/64] fixes --- client/main.lua | 4 ++-- config.lua | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/main.lua b/client/main.lua index 7e3ed50f..579b3469 100644 --- a/client/main.lua +++ b/client/main.lua @@ -103,10 +103,10 @@ Citizen.CreateThread(function() local distance = #(playerCoords - v.Pos[i]) if distance < Config.DrawDistance then - DrawMarker(v.Type[i], v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Size[i].x, v.Size[i].y, v.Size[i].z, v.Color[i].r, v.Color[i].g, v.Color[i].b, 100, false, true, 2, false, nil, nil, false) + DrawMarker(Config.MarkerType, v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, nil, nil, false) letSleep = false - if distance < v.Size[i].x then + if distance < Config.MarkerSize.x then isInMarker = true currentZone = k lastZone = k diff --git a/config.lua b/config.lua index ff3dfb33..c69fd272 100644 --- a/config.lua +++ b/config.lua @@ -1,5 +1,8 @@ Config = {} Config.DrawDistance = 100 +Config.MarkerSize = {x = 1.1, y = 1.1, z = 0.9} +Config.MarkerType = 21 +Config.MarkerColor = {r = 102, g = 102, b = 204, a = 255} Config.Locale = 'en' Config.Zones = { @@ -27,7 +30,7 @@ Config.Zones = { vector3(2678.9, 3280.6, 54.2), vector3(1729.2, 6414.1, 34.0) }, - Size = {x = 1.0, y = 1.0, z = 1.0}, + Size = 1.0, Type = 59, Color = {r = 102, g = 102, b = 204, a = 255} }, From af2a25767bcc288dd5bc54b2eb223af1f7e7e6a0 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:50:47 +0100 Subject: [PATCH 62/64] fixes --- client/main.lua | 8 ++++---- config.lua | 30 +++++++++++++++--------------- esx_shops.sql | 19 ------------------- 3 files changed, 19 insertions(+), 38 deletions(-) delete mode 100644 esx_shops.sql diff --git a/client/main.lua b/client/main.lua index 579b3469..049a35eb 100644 --- a/client/main.lua +++ b/client/main.lua @@ -20,7 +20,7 @@ function OpenShopMenu(zone) table.insert(elements, { label = ('%s - %s'):format(item.label, _U('shop_item', ESX.Math.GroupDigits(item.price))), itemLabel = item.label, - item = item.item, + item = item.name, price = item.price, -- menu properties @@ -79,9 +79,9 @@ Citizen.CreateThread(function() for i = 1, #v.Pos, 1 do local blip = AddBlipForCoord(v.Pos[i]) - SetBlipSprite (blip, v.Type[i]) - SetBlipScale (blip, v.Size[i]) - SetBlipColour (blip, v.Color[i]) + SetBlipSprite (blip, v.Type) + SetBlipScale (blip, v.Size) + SetBlipColour (blip, v.Color) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName('STRING') diff --git a/config.lua b/config.lua index c69fd272..4ae11565 100644 --- a/config.lua +++ b/config.lua @@ -10,13 +10,13 @@ Config.Zones = { TwentyFourSeven = { Items = { { - name = bread, - label = bread, + name = "bread", + label = "bread", price = 100 }, { - name = water, - label = bread, + name = "water", + label = "water", price = 100 } }, @@ -32,19 +32,19 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = {r = 102, g = 102, b = 204, a = 255} + Color = 25 }, RobsLiquor = { Items = { { - name = bread, - label = bread, + name = "bread", + label = "bread", price = 100 }, { - name = water, - label = bread, + name = "water", + label = "water", price = 100 } }, @@ -61,19 +61,19 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = {r = 102, g = 102, b = 204, a = 255} + Color = 25 }, LTDgasoline = { Items = { { - name = bread, - label = bread, + name = "bread", + label = "bread", price = 100 }, { - name = water, - label = bread, + name = "water", + label = "water", price = 100 } }, @@ -86,6 +86,6 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = {r = 102, g = 102, b = 204, a = 255} + Color = 25 } } diff --git a/esx_shops.sql b/esx_shops.sql deleted file mode 100644 index e60fdd04..00000000 --- a/esx_shops.sql +++ /dev/null @@ -1,19 +0,0 @@ -USE `es_extended`; - -CREATE TABLE `shops` ( - `id` int NOT NULL AUTO_INCREMENT, - `store` varchar(100) NOT NULL, - `item` varchar(100) NOT NULL, - `price` int NOT NULL, - - PRIMARY KEY (`id`) -); - -INSERT INTO `shops` (store, item, price) VALUES - ('TwentyFourSeven','bread',30), - ('TwentyFourSeven','water',15), - ('RobsLiquor','bread',30), - ('RobsLiquor','water',15), - ('LTDgasoline','bread',30), - ('LTDgasoline','water',15) -; From 7156d50da3c272e2e8a7db3c2c5220f0143dc20e Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:55:51 +0100 Subject: [PATCH 63/64] Add Config --- client/main.lua | 2 ++ config.lua | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/main.lua b/client/main.lua index 049a35eb..46a56488 100644 --- a/client/main.lua +++ b/client/main.lua @@ -77,6 +77,7 @@ end) Citizen.CreateThread(function() for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do + if v.Show then local blip = AddBlipForCoord(v.Pos[i]) SetBlipSprite (blip, v.Type) @@ -89,6 +90,7 @@ Citizen.CreateThread(function() EndTextCommandSetBlipName(blip) end end + end end) -- Enter / Exit marker events diff --git a/config.lua b/config.lua index 4ae11565..5c7a0b5f 100644 --- a/config.lua +++ b/config.lua @@ -32,7 +32,8 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = 25 + Color = 25, + Show = true -- show blip }, RobsLiquor = { @@ -61,7 +62,8 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = 25 + Color = 25, + Show = true -- show blip }, LTDgasoline = { @@ -86,6 +88,7 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = 25 + Color = 25, + Show = true -- show blip } } From 7a19d5c0ee3ffc6a3558a567b60d37f8287ace96 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Tue, 27 Apr 2021 00:12:42 +0100 Subject: [PATCH 64/64] ShowBlip Config --- client/main.lua | 6 ++++-- config.lua | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/client/main.lua b/client/main.lua index 46a56488..64b2c98e 100644 --- a/client/main.lua +++ b/client/main.lua @@ -77,7 +77,7 @@ end) Citizen.CreateThread(function() for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do - if v.Show then + if v.ShowBlip then local blip = AddBlipForCoord(v.Pos[i]) SetBlipSprite (blip, v.Type) @@ -105,10 +105,12 @@ Citizen.CreateThread(function() local distance = #(playerCoords - v.Pos[i]) if distance < Config.DrawDistance then + if v.ShowMarker then DrawMarker(Config.MarkerType, v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, nil, nil, false) + end letSleep = false - if distance < Config.MarkerSize.x then + if distance < 2.0 then isInMarker = true currentZone = k lastZone = k diff --git a/config.lua b/config.lua index 5c7a0b5f..58047091 100644 --- a/config.lua +++ b/config.lua @@ -33,7 +33,8 @@ Config.Zones = { Size = 1.0, Type = 59, Color = 25, - Show = true -- show blip + ShowBlip = true, + ShowMarker = true }, RobsLiquor = { @@ -63,7 +64,8 @@ Config.Zones = { Size = 1.0, Type = 59, Color = 25, - Show = true -- show blip + ShowBlip = true, + ShowMarker = true }, LTDgasoline = { @@ -89,6 +91,7 @@ Config.Zones = { Size = 1.0, Type = 59, Color = 25, - Show = true -- show blip + ShowBlip = true, + ShowMarker = true } }