diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..d3f0722 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,15 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: BeamMP # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +thanks_dev: # Replace with a single thanks.dev username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0ad25db --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 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 Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are 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. + + 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. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + 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 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 work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero 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 Affero 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 Affero 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 Affero 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + 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 AGPL, see +. diff --git a/docs/assets/content/ConfirmationDialog.png b/docs/assets/content/ConfirmationDialog.png new file mode 100644 index 0000000..a2c1ee4 Binary files /dev/null and b/docs/assets/content/ConfirmationDialog.png differ diff --git a/docs/assets/content/ConfirmationDialog_Example.png b/docs/assets/content/ConfirmationDialog_Example.png new file mode 100644 index 0000000..a17c604 Binary files /dev/null and b/docs/assets/content/ConfirmationDialog_Example.png differ diff --git a/docs/assets/content/Dialogue.png b/docs/assets/content/Dialogue.png new file mode 100644 index 0000000..1ce7c6a Binary files /dev/null and b/docs/assets/content/Dialogue.png differ diff --git a/docs/assets/content/imguiExample.png b/docs/assets/content/imguiExample.png new file mode 100644 index 0000000..c61416f Binary files /dev/null and b/docs/assets/content/imguiExample.png differ diff --git a/docs/assets/content/imguiExample.zip b/docs/assets/content/imguiExample.zip new file mode 100644 index 0000000..35e99a9 Binary files /dev/null and b/docs/assets/content/imguiExample.zip differ diff --git a/docs/assets/content/introPopupCareer.png b/docs/assets/content/introPopupCareer.png new file mode 100644 index 0000000..c52c18e Binary files /dev/null and b/docs/assets/content/introPopupCareer.png differ diff --git a/docs/assets/content/introPopupMission.png b/docs/assets/content/introPopupMission.png new file mode 100644 index 0000000..0863dea Binary files /dev/null and b/docs/assets/content/introPopupMission.png differ diff --git a/docs/assets/content/introPopupTutorial.png b/docs/assets/content/introPopupTutorial.png new file mode 100644 index 0000000..7f7f356 Binary files /dev/null and b/docs/assets/content/introPopupTutorial.png differ diff --git a/docs/en/API documentation/Client-Side.md b/docs/en/API documentation/Client-Side.md new file mode 100644 index 0000000..97e31dd --- /dev/null +++ b/docs/en/API documentation/Client-Side.md @@ -0,0 +1,1297 @@ +## Table of Contents + +### MPVehicleGE +- [Vehicle Functions](#vehicle-functions) +- [Player Functions](#player-functions) +- [Nametag Functions](#nametag-functions) +- [Role Functions](#role-functions) +- [Navigation Functions](#navigation-functions) +- [Object Methods](#object-methods) +- [Event Hooks](#event-hooks) + +### MPConfig +- [MPConfig Functions](#mpconfig-functions) + +### MPCoreNetwork +- [MPCoreNetwork Functions](#mpcorenetwork-functions) + +### MPGameNetwork +- [Event System Functions](#event-system-functions) +- [Keypress Functions](#keypress-functions) +- [UI Functions](#ui-functions) +- [MPGameNetwork Callbacks](#mpgamenetwork-callbacks) + +### MPHelpers +- [Encoding Functions](#encoding-functions) +- [Color Functions](#color-functions) +- [String Functions](#string-functions) +- [Table Functions](#table-functions) +- [Debug Functions](#debug-functions) + +--- + +## Vehicle Functions + +### `getGameVehicleID(serverVehicleID)` +Resolves a serverVehicleID into the gameVehicleID + +**Parameters:** +- `serverVehicleID` (string) - Format: "X-Y" where X is PlayerID and Y is VehicleID + +**Returns:** +- (number) - The game's internal vehicle ID +- (number) `-1` - If vehicle is unknown + +**Usage:** +```lua +local gameID = extensions.MPVehicleGE.getGameVehicleID("0-0") +``` + +--- + +### `getServerVehicleID(gameVehicleID)` +Resolves a gameVehicleID into the serverVehicleID + +**Parameters:** +- `gameVehicleID` (number) - The game's internal vehicle ID + +**Returns:** +- (string) - Server vehicle ID (e.g., "0-0") +- (nil) - If gameVehicleID is unknown + +**Usage:** +```lua +local serverID = extensions.MPVehicleGE.getServerVehicleID(11171) +``` + +--- + +### `getVehicleByServerID(serverVehicleID)` +Returns the complete vehicle table for this vehicle + +**Parameters:** +- `serverVehicleID` (string) - Format: "X-Y" + +**Returns:** +- (table) - Vehicle information (name, gameVehicleID, jbeam, ownerID, ownerName, isLocal, isSpawned, etc.) +- (nil) - If serverVehicleID is invalid + +**Usage:** +```lua +local vehicle = extensions.MPVehicleGE.getVehicleByServerID("0-0") +if vehicle then + print("Owner: " .. vehicle.ownerName) +end +``` + +--- + +### `getVehicleByGameID(gameVehicleID)` +Returns the complete vehicle table for this vehicle + +**Parameters:** +- `gameVehicleID` (number) - The game's internal vehicle ID + +**Returns:** +- (table) - Vehicle information +- (nil) - If gameVehicleID is invalid + +**Usage:** +```lua +local vehicle = extensions.MPVehicleGE.getVehicleByGameID(11171) +``` + +--- + +### `isOwn(gameVehicleID)` +Checks if the given vehicle belongs to this client + +**Parameters:** +- `gameVehicleID` (number) - The game's internal vehicle ID + +**Returns:** +- (boolean) - True if vehicle belongs to this client + +**Usage:** +```lua +if extensions.MPVehicleGE.isOwn(11171) then + print("This is my vehicle") +end +``` + +--- + +### `getOwnMap()` +Returns a table containing all vehicles owned by this client + +**Parameters:** +- None + +**Returns:** +- (table) - Map of owned vehicles `{[gameVehicleID] = vehicles_subtable}` + +**Usage:** +```lua +local myVehicles = extensions.MPVehicleGE.getOwnMap() +``` + +--- + +### `getVehicleMap()` +Returns a table of all known multiplayer vehicles + +**Parameters:** +- None + +**Returns:** +- (table) - Map of all vehicles `{[serverVehicleID] = gameVehicleID}` + +**Usage:** +```lua +local allVehicles = extensions.MPVehicleGE.getVehicleMap() +``` + +--- + +### `getDistanceMap()` +Returns the distance from each multiplayer vehicle to this client's point of view + +**Parameters:** +- None + +**Returns:** +- (table) - Map of distances `{[gameVehicleID] = distanceInMeters}` + +**Usage:** +```lua +local distances = extensions.MPVehicleGE.getDistanceMap() +``` + +--- + +### `getNicknameMap()` +Returns all multiplayer gameVehicleIDs with their owner names + +**Parameters:** +- None + +**Returns:** +- (table) - Map of nicknames `{[gameVehicleID] = ownerName}` + +**Usage:** +```lua +local nicknameMap = extensions.MPVehicleGE.getNicknameMap() +``` + +--- + +### `getVehicles()` +Returns the complete vehicles table + +**Parameters:** +- None + +**Returns:** +- (table) - All vehicles `{[serverVehicleID] = vehicles_subtable}` + +**Usage:** +```lua +local vehicles = extensions.MPVehicleGE.getVehicles() +for serverID, vehicle in pairs(vehicles) do + print("Vehicle: " .. vehicle.jbeam) +end +``` + +--- + +## Player Functions + +### `getPlayerByName(name)` +Returns this player's table and ID + +**Parameters:** +- `name` (string) - The player's name + +**Returns:** +- (table) - Player information (name, playerID, role, vehicles, etc.) +- (number) - The player's ID +- (nil) - If player not found + +**Usage:** +```lua +local player, playerID = extensions.MPVehicleGE.getPlayerByName("John") +if player then + print("Player ID: " .. playerID) +end +``` + +--- + +### `getPlayers()` +Returns the complete players table + +**Parameters:** +- None + +**Returns:** +- (table) - All players `{[playerID] = players_subtable}` + +**Usage:** +```lua +local players = extensions.MPVehicleGE.getPlayers() +for playerID, player in pairs(players) do + print("Player: " .. player.name) +end +``` + +--- + +## Nametag Functions + +### `setPlayerNickPrefix(targetName, tagSource, text)` +Adds a prefix to a player's nametag (displayed before the name) + +**Parameters:** +- `targetName` (string) - The player's name +- `tagSource` (string) - Unique identifier for this prefix +- `text` (string) - Text to display before the name + +**Usage:** +```lua +extensions.MPVehicleGE.setPlayerNickPrefix("John", "RANK", "1st.") +-- Result: "1st. John" +``` + +--- + +### `setPlayerNickSuffix(targetName, tagSource, text)` +Adds a suffix to a player's nametag (displayed after the name) + +**Parameters:** +- `targetName` (string) - The player's name +- `tagSource` (string) - Unique identifier for this suffix +- `text` (string) - Text to display after the name + +**Usage:** +```lua +extensions.MPVehicleGE.setPlayerNickSuffix("John", "STATUS", "[AFK]") +-- Result: "John [AFK]" +``` + +--- + +### `hideNicknames(hide)` +Turns on or off the nametag drawing from BeamMP + +**Parameters:** +- `hide` (boolean) - True to hide nametags, false to show them + +**Usage:** +```lua +extensions.MPVehicleGE.hideNicknames(true) -- Hide +extensions.MPVehicleGE.hideNicknames(false) -- Show +``` + +--- + +### `toggleNicknames()` +Toggles the displaying of nametags + +**Parameters:** +- None + +**Usage:** +```lua +extensions.MPVehicleGE.toggleNicknames() +``` + +--- + +## Role Functions + +### `setPlayerRole(playerID, tag, shorttag, red, green, blue)` +Sets a custom role for a player + +**Parameters:** +- `playerID` (number) - ID of the player +- `tag` (string) - Role tag (e.g., "VIP") +- `shorttag` (string) - Short version (e.g., "V") +- `red` (number) - Red channel (0-255) +- `green` (number) - Green channel (0-255) +- `blue` (number) - Blue channel (0-255) + +**Returns:** +- (boolean, string) - `false, "player not found"` if player doesn't exist +- (boolean, string) - `false, error` if invalid arguments +- (nil) - Nothing on success + +**Usage:** +```lua +local success, error = extensions.MPVehicleGE.setPlayerRole(0, "VIP", "V", 255, 215, 0) +if success == false then + print("Error: " .. error) +end +``` + +--- + +### `clearPlayerRole(playerID)` +Clears a custom role for a player + +**Parameters:** +- `playerID` (number) - ID of the player + +**Returns:** +- (boolean) - Always returns `false` (implementation quirk - use to check if player exists) + +**Usage:** +```lua +extensions.MPVehicleGE.clearPlayerRole(0) +``` + +--- + +### `setVehicleRole(playerIDVehicleID, tag, shorttag, red, green, blue)` +Sets a custom role for a specific vehicle + +**Parameters:** +- `playerIDVehicleID` (string) - Vehicle ID (format: "0-0") +- `tag` (string) - Role tag +- `shorttag` (string) - Short version +- `red` (number) - Red (0-255) +- `green` (number) - Green (0-255) +- `blue` (number) - Blue (0-255) + +**Returns:** +- (boolean, string) - `false, "vehicle not found"` if vehicle doesn't exist +- (boolean, string) - `false, error` if invalid arguments +- (nil) - Nothing on success + +**Usage:** +```lua +local success, error = extensions.MPVehicleGE.setVehicleRole("0-0", "Police", "POL", 0, 0, 255) +if success == false then + print("Error: " .. error) +end +``` + +--- + +### `clearVehicleRole(playerIDVehicleID)` +Clears a custom role for a vehicle + +**Parameters:** +- `playerIDVehicleID` (string) - Vehicle ID (format: "0-0") + +**Returns:** +- (boolean) - Always returns `false` (implementation quirk - use to check if vehicle exists) + +**Usage:** +```lua +extensions.MPVehicleGE.clearVehicleRole("0-0") +``` + +--- + +## Navigation Functions + +### `groundmarkerToPlayer(targetName)` +Sets a ground marker route to target player's position (static) + +**Parameters:** +- `targetName` (string) - Player's name, or nil to clear + +**Usage:** +```lua +extensions.MPVehicleGE.groundmarkerToPlayer("John") -- Set +extensions.MPVehicleGE.groundmarkerToPlayer(nil) -- Clear +``` + +--- + +### `groundmarkerFollowPlayer(targetName, dontfollow)` +Sets a ground marker route that follows target player + +**Parameters:** +- `targetName` (string) - Player's name, or nil to stop +- `dontfollow` (boolean) - If true, creates static marker + +**Usage:** +```lua +extensions.MPVehicleGE.groundmarkerFollowPlayer("John") -- Follow +extensions.MPVehicleGE.groundmarkerFollowPlayer("John", true) -- Static +extensions.MPVehicleGE.groundmarkerFollowPlayer(nil) -- Stop +``` + +--- + +### `queryRoadNodeToPosition(targetPosition, owner)` +Finds the closest road nodes to a target position + +**Parameters:** +- `targetPosition` (vec3 or table) - Target position with x, y, z +- `owner` (string) - Optional identifier (default: "target") + +**Returns:** +- (boolean) - Success status +- (number) - nodeID (if successful) + +**Usage:** +```lua +local pos = vec3(100, 200, 50) +local success, nodeID = extensions.MPVehicleGE.queryRoadNodeToPosition(pos) +``` + +--- + +## Object Methods + +### Player Object Methods + +#### `player:setNickPrefix(tagSource, text)` +Sets a prefix for this player's nametag + +**Parameters:** +- `tagSource` (string) - Unique identifier +- `text` (string) - Text to display (or nil to remove) + +**Usage:** +```lua +local player = extensions.MPVehicleGE.getPlayerByName("John") +if player then + player:setNickPrefix("STATUS", "[AFK]") +end +``` + +--- + +#### `player:setNickSuffix(tagSource, text)` +Sets a suffix for this player's nametag + +**Parameters:** +- `tagSource` (string) - Unique identifier +- `text` (string) - Text to display (or nil to remove) + +**Usage:** +```lua +local player = extensions.MPVehicleGE.getPlayerByName("John") +if player then + player:setNickSuffix("MISSION", "[In Mission]") +end +``` + +--- + +#### `player:setCustomRole(role)` +Sets a custom role for this player + +**Parameters:** +- `role` (table) - Role table: `{backcolor = {r, g, b}, tag = string, shorttag = string}` + +**Usage:** +```lua +local player = extensions.MPVehicleGE.getPlayerByName("John") +if player then + player:setCustomRole({ + backcolor = {r = 255, g = 0, b = 0}, + tag = " [VIP]", + shorttag = " [V]" + }) +end +``` + +--- + +#### `player:clearCustomRole()` +Clears the custom role for this player + +**Usage:** +```lua +local player = extensions.MPVehicleGE.getPlayerByName("John") +if player then + player:clearCustomRole() +end +``` + +--- + +### Vehicle Object Methods + +#### `vehicle:getOwner()` +Returns the owner of this vehicle + +**Returns:** +- (table) - Player object +- (number) - Player's ID + +**Usage:** +```lua +local vehicle = extensions.MPVehicleGE.getVehicleByServerID("0-0") +if vehicle then + local owner, ownerID = vehicle:getOwner() + print("Owner: " .. owner.name) +end +``` + +--- + +#### `vehicle:setCustomRole(role)` +Sets a custom role for this vehicle + +**Parameters:** +- `role` (table) - Role table: `{backcolor = {r, g, b}, tag = string, shorttag = string}` + +**Usage:** +```lua +local vehicle = extensions.MPVehicleGE.getVehicleByServerID("0-0") +if vehicle then + vehicle:setCustomRole({ + backcolor = {r = 0, g = 0, b = 255}, + tag = " [Police]", + shorttag = " [POL]" + }) +end +``` + +--- + +#### `vehicle:clearCustomRole()` +Clears the custom role for this vehicle + +**Usage:** +```lua +local vehicle = extensions.MPVehicleGE.getVehicleByServerID("0-0") +if vehicle then + vehicle:clearCustomRole() +end +``` + +--- + +#### `vehicle:setDisplayName(displayName)` +Sets a custom display name for this vehicle + +**Parameters:** +- `displayName` (string) - Custom name to display + +**Usage:** +```lua +local vehicle = extensions.MPVehicleGE.getVehicleByServerID("0-0") +if vehicle then + vehicle:setDisplayName("Patrol Car #1") +end +``` + +--- + +## Event Hooks + +BeamMP provides event hooks that you can override to execute custom code when specific events occur. **Do not call these functions directly** - instead, override them while preserving the original functionality. + +### Hook Pattern + +Always preserve the original function when overriding: + +```lua +-- Save the original function +local originalCallback = MPVehicleGE.onVehicleSpawned + +-- Override with your custom logic +MPVehicleGE.onVehicleSpawned = function(gameVehicleID) + -- Call the original first + originalCallback(gameVehicleID) + + -- Your custom code here + print("Vehicle spawned: " .. gameVehicleID) +end +``` + +--- + +### Available Event Hooks + +#### `onUpdate(dt)` +Called every frame while connected to multiplayer + +**Parameters:** +- `dt` (number) - Delta time in seconds since last frame + +**Usage:** +```lua +local originalOnUpdate = MPVehicleGE.onUpdate +MPVehicleGE.onUpdate = function(dt) + originalOnUpdate(dt) + -- Your frame-by-frame logic here +end +``` + +--- + +#### `onPreRender(dt)` +Called every frame before rendering + +**Parameters:** +- `dt` (number) - Delta time in seconds + +**Note:** +This handles nametag rendering, distance calculations, and ground markers internally. + +**Usage:** +```lua +local originalOnPreRender = MPVehicleGE.onPreRender +MPVehicleGE.onPreRender = function(dt) + originalOnPreRender(dt) + -- Your pre-render logic here +end +``` + +--- + +#### `onVehicleSpawned(gameVehicleID)` +Called when a vehicle spawns (both local and remote) + +**Parameters:** +- `gameVehicleID` (number) - The game's internal vehicle ID + +**Usage:** +```lua +local originalOnVehicleSpawned = MPVehicleGE.onVehicleSpawned +MPVehicleGE.onVehicleSpawned = function(gameVehicleID) + originalOnVehicleSpawned(gameVehicleID) + + local vehicle = extensions.MPVehicleGE.getVehicleByGameID(gameVehicleID) + if vehicle then + print(vehicle.ownerName .. " spawned a " .. vehicle.jbeam) + end +end +``` + +--- + +#### `onVehicleDestroyed(gameVehicleID)` +Called when a vehicle is destroyed/removed + +**Parameters:** +- `gameVehicleID` (number) - The game's internal vehicle ID + +**Usage:** +```lua +local originalOnVehicleDestroyed = MPVehicleGE.onVehicleDestroyed +MPVehicleGE.onVehicleDestroyed = function(gameVehicleID) + local vehicle = extensions.MPVehicleGE.getVehicleByGameID(gameVehicleID) + if vehicle then + print("Vehicle " .. vehicle.jbeam .. " was destroyed") + end + + originalOnVehicleDestroyed(gameVehicleID) +end +``` + +--- + +#### `onVehicleSwitched(oldGameVehicleID, newGameVehicleID)` +Called when player switches between vehicles + +**Parameters:** +- `oldGameVehicleID` (number) - Previous vehicle ID (or -1) +- `newGameVehicleID` (number) - New vehicle ID (or -1) + +**Usage:** +```lua +local originalOnVehicleSwitched = MPVehicleGE.onVehicleSwitched +MPVehicleGE.onVehicleSwitched = function(oldID, newID) + originalOnVehicleSwitched(oldID, newID) + + print("Switched from vehicle " .. oldID .. " to " .. newID) +end +``` + +--- + +#### `onVehicleResetted(gameVehicleID)` +Called when a vehicle is reset (local vehicles only) + +**Parameters:** +- `gameVehicleID` (number) - The game's internal vehicle ID + +**Usage:** +```lua +local originalOnVehicleResetted = MPVehicleGE.onVehicleResetted +MPVehicleGE.onVehicleResetted = function(gameVehicleID) + originalOnVehicleResetted(gameVehicleID) + + print("Vehicle " .. gameVehicleID .. " was reset") +end +``` + +--- + +#### `onVehicleColorChanged(gameVehicleID, index, paint)` +Called when a vehicle's paint color is changed + +**Parameters:** +- `gameVehicleID` (number) - The game's internal vehicle ID +- `index` (number) - Paint slot index (0, 1, or 2) +- `paint` (table) - Paint data with color information + +**Usage:** +```lua +local originalOnVehicleColorChanged = MPVehicleGE.onVehicleColorChanged +MPVehicleGE.onVehicleColorChanged = function(gameVehicleID, index, paint) + originalOnVehicleColorChanged(gameVehicleID, index, paint) + + print("Vehicle " .. gameVehicleID .. " changed paint slot " .. index) +end +``` + +--- + +#### `onVehicleReady(gameVehicleID)` +Called when a vehicle's extensions have loaded and the vehicle is fully ready + +**Parameters:** +- `gameVehicleID` (number) - The game's internal vehicle ID + +**Note:** +Use this instead of `onVehicleSpawned` if you need vehicle extensions to be loaded. + +**Usage:** +```lua +local originalOnVehicleReady = MPVehicleGE.onVehicleReady +MPVehicleGE.onVehicleReady = function(gameVehicleID) + originalOnVehicleReady(gameVehicleID) + + -- Safe to interact with vehicle extensions here + local veh = be:getObjectByID(gameVehicleID) + if veh then + veh:queueLuaCommand("print('Vehicle is ready!')") + end +end +``` + +--- + +#### `onUIInitialised()` +Called when the BeamMP UI is initialized + +**Usage:** +```lua +local originalOnUIInitialised = MPVehicleGE.onUIInitialised +MPVehicleGE.onUIInitialised = function() + originalOnUIInitialised() + + print("BeamMP UI initialized") +end +``` + +--- + +#### `onSettingsChanged()` +Called when BeamMP settings are changed + +**Usage:** +```lua +local originalOnSettingsChanged = MPVehicleGE.onSettingsChanged +MPVehicleGE.onSettingsChanged = function() + originalOnSettingsChanged() + + print("BeamMP settings changed") +end +``` + +--- + +## MPConfig Functions + +### `MPConfig.getPlayerServerID()` +Returns the local player's server-assigned ID + +**Returns:** +- (number) - The player's server ID (-1 if not set) + +**Usage:** +```lua +local myID = extensions.MPConfig.getPlayerServerID() +``` + +--- + +### `MPConfig.getNickname()` +Returns the local player's nickname + +**Returns:** +- (string) - The player's current nickname + +**Usage:** +```lua +local name = extensions.MPConfig.getNickname() +``` + +--- + +### `MPConfig.getConfig()` +Returns the BeamMP configuration settings + +**Returns:** +- (table) - Configuration table with all BeamMP settings +- (nil) - If config file doesn't exist + +**Usage:** +```lua +local config = extensions.MPConfig.getConfig() +``` + +--- + +### `MPConfig.setConfig(settingName, settingVal)` +Sets a specific configuration value + +**Parameters:** +- `settingName` (string) - Name of the setting +- `settingVal` (any) - Value to set + +**Usage:** +```lua +extensions.MPConfig.setConfig("myCustomSetting", true) +``` + +--- + +## MPCoreNetwork Functions + +### `MPCoreNetwork.getCurrentServer()` +Returns information about the current connected server + +**Returns:** +- (table) - Server data (ip, port, name, map) +- (nil) - If not connected + +**Usage:** +```lua +local server = extensions.MPCoreNetwork.getCurrentServer() +if server then + print("Server: " .. server.name) + print("IP: " .. server.ip .. ":" .. server.port) +end +``` + +--- + +## Event System Functions + +### `TriggerServerEvent(name, data)` +Sends an event to the server + +**Parameters:** +- `name` (string) - Event name +- `data` (string) - Data to send + +**Note:** +Global function. The server must have a registered handler for this event. + +**Usage:** +```lua +TriggerServerEvent("playerReady", "ready") + +-- With JSON +local data = {position = {x=100, y=200, z=50}} +TriggerServerEvent("updatePlayer", jsonEncode(data)) +``` + +--- + +### `TriggerClientEvent(name, data)` +Triggers a local client event + +**Parameters:** +- `name` (string) - Event name +- `data` (string) - Data to send + +**Note:** +Global function. Triggers locally without sending to server. + +**Usage:** +```lua +TriggerClientEvent("localUpdate", "data") +``` + +--- + +### `AddEventHandler(event_name, func, name)` +Registers a function to handle a specific event + +**Parameters:** +- `event_name` (string) - Name of the event to handle +- `func` (function) - Handler function (receives event data) +- `name` (string) - Optional internal name + +**Note:** +Global function. + +**Usage:** +```lua +AddEventHandler("playerDamage", function(data) + print("Damage: " .. data) +end) + +-- With JSON +AddEventHandler("vehicleSpawned", function(data) + local vehData = jsonDecode(data) + print("Spawned: " .. vehData.model) +end) +``` + +--- + +### `RemoveEventHandler(event_name, name)` +Removes an event handler + +**Parameters:** +- `event_name` (string) - Name of the event +- `name` (string) - Optional internal name + +**Note:** +Global function. + +**Usage:** +```lua +RemoveEventHandler("playerDamage") +``` + +--- + +## Keypress Functions + +### `onKeyPressed(keyname, func)` +Registers a function to be called when a key is pressed + +**Parameters:** +- `keyname` (string) - Name of the key (e.g., "NUMPAD1", "F1") +- `func` (function) - Function to call (receives boolean) + +**Note:** +Global function. + +**Usage:** +```lua +onKeyPressed("NUMPAD1", function(state) + print("NUMPAD1 pressed!") +end) +``` + +--- + +### `onKeyReleased(keyname, func)` +Registers a function to be called when a key is released + +**Parameters:** +- `keyname` (string) - Name of the key +- `func` (function) - Function to call (receives boolean) + +**Note:** +Global function. + +**Usage:** +```lua +onKeyReleased("NUMPAD1", function(state) + print("NUMPAD1 released!") +end) +``` + +--- + +### `addKeyEventListener(keyname, func, type)` +Registers a key event listener with customizable trigger type + +**Parameters:** +- `keyname` (string) - Name of the key +- `func` (function) - Function to call +- `type` (string) - Event type: "down", "up", or "both" (default: "both") + +**Note:** +Global function. + +**Usage:** +```lua +addKeyEventListener("F1", function(isPressed) + if isPressed then + print("F1 pressed") + else + print("F1 released") + end +end, "both") +``` + +--- + +### `getKeyState(keyname)` +Returns the current state of a key + +**Parameters:** +- `keyname` (string) - Name of the key + +**Returns:** +- (boolean) - True if pressed, false otherwise + +**Note:** +Global function. Only works for keys registered with addKeyEventListener. + +**Usage:** +```lua +local isPressed = getKeyState("NUMPAD1") +if isPressed then + print("NUMPAD1 is held down") +end +``` + +--- + +## UI Functions + +### `MPGameNetwork.spawnUiDialog(dialogInfo)` +Creates a custom interactive dialog box + +**Parameters:** +- `dialogInfo` (table) - Dialog configuration: + - `title` (string) - Dialog title (optional) + - `body` (string) - Dialog message (optional) + - `buttons` (table) - Button configurations (optional) + - `class` (string) - "experimental" for hazard lines (optional) + - `interactionID` (string) - Interaction identifier (optional) + - `reportToServer` (boolean) - Send to server (optional, default: false) + - `reportToExtensions` (boolean) - Trigger local event (optional, default: false) + +**Usage:** +```lua +-- Simple dialog +extensions.MPGameNetwork.spawnUiDialog({ + title = "Welcome", + body = "Welcome to the server!" +}) + +-- Choice dialog +extensions.MPGameNetwork.spawnUiDialog({ + title = "Choose Team", + body = "Which team?", + buttons = { + {label = "Red", key = "joinRed"}, + {label = "Blue", key = "joinBlue"} + }, + interactionID = "teamSelection", + reportToServer = true +}) +``` + +--- + +## MPGameNetwork Callbacks + +### `MPGameNetwork.onUpdate(dt)` +Called every frame while connected to multiplayer + +**Parameters:** +- `dt` (number) - Delta time in seconds + +**Usage:** +```lua +local originalOnUpdate = MPGameNetwork.onUpdate +MPGameNetwork.onUpdate = function(dt) + originalOnUpdate(dt) + -- Your code here +end +``` + +--- + +### `MPGameNetwork.onVehicleReady(gameVehicleID)` +Called when a vehicle is ready and extensions are loaded + +**Parameters:** +- `gameVehicleID` (number) - The game's internal vehicle ID + +**Usage:** +```lua +local originalOnVehicleReady = MPGameNetwork.onVehicleReady +MPGameNetwork.onVehicleReady = function(gameVehicleID) + originalOnVehicleReady(gameVehicleID) + -- Your code here +end +``` + +--- + +## Encoding Functions + +### `MPHelpers.b64encode(string)` +Encodes a string to Base64 (RFC 2045) + +**Parameters:** +- `string` (string) - String to encode + +**Returns:** +- (string) - Base64-encoded string + +**Usage:** +```lua +local encoded = extensions.MPHelpers.b64encode("Hello World") + +-- Encoding JSON +local data = {name = "Player", score = 100} +local encoded = extensions.MPHelpers.b64encode(jsonEncode(data)) +TriggerServerEvent("sendData", encoded) +``` + +--- + +### `MPHelpers.b64decode(string)` +Decodes a Base64 string (RFC 2045) + +**Parameters:** +- `string` (string) - Base64-encoded string + +**Returns:** +- (string) - Decoded string + +**Usage:** +```lua +local decoded = extensions.MPHelpers.b64decode("SGVsbG8gV29ybGQ=") + +-- Decoding JSON +AddEventHandler("receiveData", function(data) + local decoded = extensions.MPHelpers.b64decode(data) + local jsonData = jsonDecode(decoded) +end) +``` + +--- + +## Color Functions + +### `MPHelpers.hex2rgb(hex)` +Converts a hexadecimal color code to RGB values + +**Parameters:** +- `hex` (string) - Hex color code (e.g., "#FF5733" or "#F57") + +**Returns:** +- (table) - RGB values `{r, g, b}` in 0-1 range +- (table) - `{0, 0, 0}` if invalid + +**Note:** +Supports both 3-character and 6-character hex codes. + +**Usage:** +```lua +local rgb = extensions.MPHelpers.hex2rgb("#FF5733") +print(rgb[1], rgb[2], rgb[3]) -- 1.0, 0.341, 0.2 + +-- Short format +local rgb = extensions.MPHelpers.hex2rgb("#F57") +``` + +--- + +## String Functions + +### `MPHelpers.splitStringToTable(string, delimiter, convert_into)` +Splits a string by delimiter and optionally converts values + +**Parameters:** +- `string` (string) - String to split +- `delimiter` (string) - Delimiter to split by +- `convert_into` (number) - Conversion type (optional): + - `nil` or `0` - Keep as strings (default) + - `1` - Convert to numbers + - `2` - Convert to booleans + +**Returns:** +- (table) - Array of split values + +**Usage:** +```lua +-- Strings +local parts = extensions.MPHelpers.splitStringToTable("Hello,World", ",") +-- {"Hello", "World"} + +-- Numbers +local nums = extensions.MPHelpers.splitStringToTable("10,20,30", ",", 1) +-- {10, 20, 30} + +-- Parse coordinates +local coords = extensions.MPHelpers.splitStringToTable("100,200,50", ",", 1) +local x, y, z = coords[1], coords[2], coords[3] +``` + +--- + +## Table Functions + +### `MPHelpers.tableDiff(old, new)` +Compares two tables and returns their differences + +**Parameters:** +- `old` (table) - First table to compare +- `new` (table) - Second table to compare + +**Returns:** +- (table) `diff` - All keys that differ +- (table) `o` - Values from old that differ +- (table) `n` - Values from new that differ + +**Usage:** +```lua +local oldConfig = {speed = 100, damage = 50, armor = 30} +local newConfig = {speed = 120, damage = 50, armor = 40} + +local diff, oldVals, newVals = extensions.MPHelpers.tableDiff(oldConfig, newConfig) +-- diff = {speed = 120, armor = 40} + +for key, value in pairs(diff) do + print(key .. " changed from " .. oldVals[key] .. " to " .. newVals[key]) +end +``` + +--- + +## Debug Functions + +### `MPHelpers.simpletraces(level)` +Returns formatted caller information as string + +**Parameters:** +- `level` (number) - Stack level (optional, default: 2) + +**Returns:** +- (string) - Formatted string: `"source:line, namewhat name"` +- (string) - `"unknown"` if info not available + +**Usage:** +```lua +local function myFunction() + local caller = extensions.MPHelpers.simpletraces() + print("Called from: " .. caller) +end +``` + +--- + +### `MPHelpers.simpletrace(level)` +Logs caller information to console + +**Parameters:** +- `level` (number) - Stack level (optional, default: 1) + +**Note:** +Logs the calling location to the console. + +**Usage:** +```lua +local function myFunction() + extensions.MPHelpers.simpletrace() + -- Logs: "Code was called from: lua/ge/extensions/mymod.lua:42" +end +``` + +--- + +*Last updated: 01.01.2026* diff --git a/docs/en/API documentation/Server-Side.md b/docs/en/API documentation/Server-Side.md new file mode 100644 index 0000000..6d08c2c --- /dev/null +++ b/docs/en/API documentation/Server-Side.md @@ -0,0 +1,1407 @@ +## Table of Contents + +### Global +- [Global Functions](#global-functions) + +### MP +- [Players](#mp--players) +- [Vehicles](#mp--vehicles) +- [Communication](#mp--communication) +- [Events](#mp--events) +- [Utilities](#mp--utilities) + +### Util +- [Logging](#util--logging) +- [JSON](#util--json) +- [Random](#util--random) +- [Profiling](#util--profiling) + +### Http +- [Http Functions](#http) + +### FS +- [Checks](#fs--checks) +- [Operations](#fs--operations) +- [Paths](#fs--paths) + +### Events +- [Events Reference](#events) + +--- + +## Global Functions + +### `print(...)` + +Prints to the server console, prefixed with date, time and `[LUA]`. + +**Parameters:** +- `...` (any) - Values of any type. Tables are printed with their contents. + +**Usage:** +```lua +local name = "John Doe" +print("Hello, I'm", name, "and I'm", 32) +``` + +--- + +### `printRaw(...)` + +Prints to the server console without any prefix. + +**Parameters:** +- `...` (any) - Values of any type. + +--- + +### `exit()` + +Shuts down the server gracefully. Triggers the `onShutdown` event. + +--- + +## MP — Players + +### `MP.GetPlayerCount() -> number` + +Returns the number of currently connected players. + +**Returns:** +- (number) - Player count. + +--- + +### `MP.GetPlayers() -> table` + +Returns a table of all connected players. + +**Returns:** +- (table) - Map of `{[playerID] = playerName}`. + +--- + +### `MP.GetPlayerName(playerID) -> string` + +Returns the name of a player by ID. + +**Parameters:** +- `playerID` (number) - The player's ID. + +**Returns:** +- (string) - The player's name, or `""` if not found. + +**Usage:** +```lua +local player_id = 4 +print(MP.GetPlayerName(player_id)) +``` + +--- + +### `MP.GetPlayerIDByName(name) -> number` + +Returns the ID of a player by name. + +**Parameters:** +- `name` (string) - The player's name. + +**Returns:** +- (number) - The player's ID, or `-1` if not found. + +--- + +### `MP.GetPlayerIdentifiers(playerID) -> table` + +Returns identifiers for a player such as IP, BeamMP forum ID and Discord ID. + +**Parameters:** +- `playerID` (number) - The player's ID. + +**Returns:** +- (table) - Table with keys `ip`, `beammp`, `discord` (only if linked). +- (nil) - If the player was not found. + +**Usage:** +```lua +local player_id = 5 +print(MP.GetPlayerIdentifiers(player_id)) +-- { ip: "127.0.0.1", discord: "12345678987654321", beammp: "1234567" } +``` + +--- + +### `MP.GetPlayerRole(playerID) -> string|nil` + +Returns the player's role as set by the BeamMP backend. + +**Parameters:** +- `playerID` (number) - The player's ID. + +**Returns:** +- (string) - The player's role. +- (nil) - If the player was not found. + +--- + +### `MP.IsPlayerConnected(playerID) -> boolean` + +Returns whether a UDP packet has been received from the player, i.e. whether the connection is fully established. + +**Parameters:** +- `playerID` (number) - The player's ID. + +**Returns:** +- (boolean) - `true` if fully connected. + +**Usage:** +```lua +local player_id = 8 +print(MP.IsPlayerConnected(player_id)) +``` + +--- + +### `MP.IsPlayerGuest(playerID) -> boolean` + +Returns whether the player is a guest (not registered on the BeamMP forum). + +**Parameters:** +- `playerID` (number) - The player's ID. + +**Returns:** +- (boolean) - `true` if guest. + +--- + +### `MP.DropPlayer(playerID, reason?)` + +Kicks a player from the server. + +**Parameters:** +- `playerID` (number) - The player's ID. +- `reason` (string, optional) - Reason for the kick. + +**Usage:** +```lua +function ChatHandler(player_id, player_name, message) + if string.match(message, "darn") then + MP.DropPlayer(player_id, "Profanity is not allowed") + return 1 + end +end +``` + +--- + +## MP — Vehicles + +### `MP.GetPlayerVehicles(playerID) -> table` + +Returns all vehicles of a player. + +**Parameters:** +- `playerID` (number) - The player's ID. + +**Returns:** +- (table) - Map of `{[vehicleID] = dataString}` where dataString is a raw JSON string. +- (nil) - If the player has no vehicles or was not found. + +**Usage:** +```lua +local player_id = 3 +local player_vehicles = MP.GetPlayerVehicles(player_id) + +for vehicle_id, vehicle_data in pairs(player_vehicles) do + local start = string.find(vehicle_data, "{") + local formattedVehicleData = string.sub(vehicle_data, start, -1) + print(Util.JsonDecode(formattedVehicleData)) +end +``` + +--- + +### `MP.GetPositionRaw(playerID, vehicleID) -> table, string` + +Returns the current raw position of a vehicle. + +**Parameters:** +- `playerID` (number) - The player's ID. +- `vehicleID` (number) - The vehicle's ID. + +**Returns:** +- (table) - Table with keys: `pos`, `rot`, `vel`, `rvel`, `tim`, `ping`. +- (string) - Error message if one occurred, empty string on success. + +**Note:** +Each value in `pos`, `rot`, `vel`, `rvel` is a table with indices `1, 2, 3` (and `4` for `rot`). + +**Usage:** +```lua +local player_id = 4 +local vehicle_id = 0 + +local raw_pos, error = MP.GetPositionRaw(player_id, vehicle_id) +if error == "" then + local x, y, z = table.unpack(raw_pos["pos"]) + print("X:", x, "Y:", y, "Z:", z) +else + print(error) +end +``` + +--- + +### `MP.RemoveVehicle(playerID, vehicleID)` + +Removes a vehicle belonging to a player. + +**Parameters:** +- `playerID` (number) - The player's ID. +- `vehicleID` (number) - The vehicle's ID. + +**Usage:** +```lua +local player_id = 3 +local player_vehicles = MP.GetPlayerVehicles(player_id) + +for vehicle_id, vehicle_data in pairs(player_vehicles) do + MP.RemoveVehicle(player_id, vehicle_id) +end +``` + +--- + +## MP — Communication + +### `MP.SendChatMessage(playerID, message, logChat?)` + +Sends a chat message to a specific player or everyone. + +**Parameters:** +- `playerID` (number) - The player's ID, or `-1` for everyone. +- `message` (string) - The message content. +- `logChat` (boolean, optional) - Whether to log to the server log (default: `true`). + +**Note:** +This function does not return a value. + +**Usage:** +```lua +-- To a specific player +function ChatHandler(player_id, player_name, msg) + if string.match(msg, "darn") then + MP.SendChatMessage(player_id, "Please do not use profanity.") + return 1 + end +end + +-- To everyone +MP.SendChatMessage(-1, "Hello World!") +``` + +--- + +### `MP.SendNotification(playerID, message, icon?, category?)` + +Sends a notification (popup) to a specific player or everyone. + +**Parameters:** +- `playerID` (number) - The player's ID, or `-1` for everyone. +- `message` (string) - The notification content. +- `icon` (string, optional) - Notification icon. +- `category` (string, optional) - Notification category. + +**Note:** +This function does not return a value. When called with only 3 arguments (no category), the category is automatically set to the value of message. + +--- + +### `MP.ConfirmationDialog(playerID, title, body, buttons, interactionID, warning?, reportToServer?, reportToExtensions?)` + +Sends a confirmation dialog with buttons to a player. + +**Parameters:** +- `playerID` (number) - The player's ID, or `-1` for everyone. +- `title` (string) - Dialog title. +- `body` (string) - Dialog body text. +- `buttons` (table) - Array of buttons. +- `interactionID` (string) - Unique identifier for this interaction. +- `warning` (boolean, optional) - Show warning styling (default: `false`). +- `reportToServer` (boolean, optional) - Send response to server (default: `true`). +- `reportToExtensions` (boolean, optional) - Trigger local event (default: `true`). + +**Note:** +When called with only 5 arguments the function does not return a value. When called with 6–8 arguments it returns `boolean, string`. + +--- + +### `MP.TriggerClientEvent(playerID, eventName, data) -> boolean, string` + +Sends an event to a specific client or everyone. + +**Parameters:** +- `playerID` (number) - The player's ID, or `-1` for everyone. +- `eventName` (string) - The event name. +- `data` (string) - The data to send. + +**Returns:** +- (boolean) - `true` if sent successfully. Always `true` for `-1`. +- (string) - Error message if failed. + +--- + +### `MP.TriggerClientEventJson(playerID, eventName, data) -> boolean, string` + +Same as `TriggerClientEvent` but accepts a Lua table and automatically encodes it to JSON. + +**Parameters:** +- `playerID` (number) - The player's ID, or `-1` for everyone. +- `eventName` (string) - The event name. +- `data` (table) - Lua table to be JSON-encoded and sent. + +**Returns:** +- (boolean) - `true` on success. +- (string) - Error message if failed. + +--- + +## MP — Events + +### `MP.RegisterEvent(eventName, functionName)` + +Registers a function as a handler for an event. + +**Parameters:** +- `eventName` (string) - The event name. +- `functionName` (string) - The name of the Lua function to register. + +**Note:** +If the event does not exist it is created. Multiple handlers can be registered for the same event. + +**Usage:** +```lua +function ChatHandler(player_id, player_name, msg) + if msg == "hello" then + print("Hello World!") + return 0 + end +end + +MP.RegisterEvent("onChatMessage", "ChatHandler") +``` + +--- + +### `MP.TriggerLocalEvent(eventName, ...) -> table` + +Triggers an event in the current state only. Synchronous. + +**Parameters:** +- `eventName` (string) - The event name. +- `...` (any, optional) - Arguments passed to handlers. + +**Returns:** +- (table) - Table of return values from all handlers. + +**Usage:** +```lua +local Results = MP.TriggerLocalEvent("MyEvent") +print(Results) +``` + +--- + +### `MP.TriggerGlobalEvent(eventName, ...) -> table` + +Triggers an event in all states. Asynchronous. Local handlers run synchronously and immediately. + +**Parameters:** +- `eventName` (string) - The event name. +- `...` (any, optional) - Arguments. Supported types: string, number, boolean, table. + +**Returns:** +- (table) - Future-like object with: + - `:IsDone() -> boolean` — Whether all handlers have finished. + - `:GetResults() -> table` — Return values from all handlers. + +**Note:** +Call these methods with `:` not `.`. + +**Usage:** +```lua +local Future = MP.TriggerGlobalEvent("MyEvent") +while not Future:IsDone() do + MP.Sleep(100) +end +local Results = Future:GetResults() +print(Results) +``` + +--- + +### `MP.CreateEventTimer(eventName, intervalMS, strategy?)` + +Creates a timer that repeatedly triggers an event. + +**Parameters:** +- `eventName` (string) - The event to trigger. +- `intervalMS` (number) - Interval between triggers in milliseconds. +- `strategy` (number, optional) - `MP.CallStrategy.BestEffort` (default) or `MP.CallStrategy.Precise`. + +**Note:** +Intervals below 25ms are not recommended and will not be served reliably. + +**Usage:** +```lua +local seconds = 0 + +function CountSeconds() + seconds = seconds + 1 +end + +MP.RegisterEvent("EverySecond", "CountSeconds") +MP.CreateEventTimer("EverySecond", 1000) +``` + +--- + +### `MP.CancelEventTimer(eventName)` + +Cancels an existing event timer. + +**Parameters:** +- `eventName` (string) - The event name. + +**Note:** +The event may fire one more time before being cancelled due to asynchronous behaviour. + +--- + +## MP — Utilities + +### `MP.CreateTimer() -> table` + +Creates a timer object for measuring elapsed time. + +**Returns:** +- (table) - Object with: + - `:GetCurrent() -> float` — Seconds elapsed since last Start. + - `:Start()` — Resets the timer. + +**Usage:** +```lua +local mytimer = MP.CreateTimer() +-- do stuff here that needs to be timed +print(mytimer:GetCurrent()) +``` + +--- + +### `MP.GetOSName() -> string` + +Returns the name of the server's operating system. + +**Returns:** +- (string) - `"Windows"`, `"Linux"`, or `"Other"`. + +--- + +### `MP.GetServerVersion() -> number, number, number` + +Returns the server version. + +**Returns:** +- (number) - major +- (number) - minor +- (number) - patch + +**Usage:** +```lua +local major, minor, patch = MP.GetServerVersion() +print(major, minor, patch) +``` + +--- + +### `MP.Get(configID) -> value` + +Reads a server config setting by ID. + +**Parameters:** +- `configID` (number) - ID from `MP.Settings`. + +**Returns:** +- (value) - The setting's current value. + +--- + +### `MP.Set(configID, value)` + +Temporarily changes a server config setting. The change is not saved to the config file. + +**Parameters:** +- `configID` (number) - ID from `MP.Settings`. +- `value` (any) - New value. Type must match the setting. + +**Usage:** +```lua +MP.Set(MP.Settings.Debug, true) +``` + +--- + +### `MP.Settings` + +Enum of setting IDs for use with `MP.Get` and `MP.Set`. + +```lua +MP.Settings.Debug -- 0 (boolean) +MP.Settings.Private -- 1 (boolean) +MP.Settings.MaxCars -- 2 (number) +MP.Settings.MaxPlayers -- 3 (number) +MP.Settings.Map -- 4 (string) +MP.Settings.Name -- 5 (string) +MP.Settings.Description -- 6 (string) +MP.Settings.InformationPacket -- 7 (boolean) +``` + +--- + +### `MP.CallStrategy` + +Enum for use with `MP.CreateEventTimer`. + +```lua +MP.CallStrategy.BestEffort -- Skip trigger if previous handler hasn't finished (default) +MP.CallStrategy.Precise -- Always trigger, even if it causes the queue to build up +``` + +--- + +### `MP.Sleep(ms)` + +Halts the entire current Lua state for a number of milliseconds. + +**Parameters:** +- `ms` (number) - Time to sleep in milliseconds. + +**Note:** +Nothing will execute in the state while sleeping. **Do not sleep for more than 500ms** if event handlers are registered — a sleeping state can slow the entire server down significantly. + +**Usage:** +```lua +local Future = MP.TriggerGlobalEvent("MyEvent") +while not Future:IsDone() do + MP.Sleep(100) +end +``` + +--- + +### `MP.GetStateMemoryUsage() -> number` + +Returns the memory usage of the current Lua state. + +**Returns:** +- (number) - Memory in bytes. + +--- + +### `MP.GetLuaMemoryUsage() -> number` + +Returns the total memory usage of all Lua states combined. + +**Returns:** +- (number) - Memory in bytes. + +--- + +## Util — Logging + +### `Util.LogInfo(...)`, `Util.LogWarn(...)`, `Util.LogError(...)`, `Util.LogDebug(...)` + +Prints to the server log at the corresponding level. + +**Parameters:** +- `...` (any) - Values of any type. + +**Note:** +`Util.LogDebug` is only shown when `MP.Settings.Debug` is enabled. + +**Usage:** +```lua +Util.LogInfo("Hello, World!") +Util.LogWarn("Cool warning") +Util.LogError("Oh no!") +Util.LogDebug("hi") +``` + +--- + +## Util — JSON + +### `Util.JsonEncode(table) -> string` + +Encodes a Lua table into a JSON string. + +**Parameters:** +- `table` (table) - The table to encode. + +**Returns:** +- (string) - Minified JSON string. + +**Note:** +Automatically detects array vs object based on key types. Functions, userdata and unsupported types are ignored. + +**Usage:** +```lua +local player = { + name = "Lion", + age = 69, + skills = { "skill A", "skill B" } +} +local json = Util.JsonEncode(player) +-- '{"name":"Lion","age":69,"skills":["skill A","skill B"]}' +``` + +--- + +### `Util.JsonDecode(json) -> table` + +Decodes a JSON string into a Lua table. + +**Parameters:** +- `json` (string) - A valid JSON string. + +**Returns:** +- (table) - The decoded table. +- (nil) - If the JSON is invalid. + +**Usage:** +```lua +local json = "{\"message\":\"OK\",\"code\":200}" +local tbl = Util.JsonDecode(json) +-- { message = "OK", code = 200 } +``` + +--- + +### `Util.JsonPrettify(json) -> string` + +Adds indentation and newlines to a JSON string for human readability (indent of 4). + +**Parameters:** +- `json` (string) - A valid JSON string. + +**Returns:** +- (string) - Pretty-printed JSON. + +**Usage:** +```lua +local myjson = Util.JsonEncode({ name="Lion", age = 69, skills = { "skill A", "skill B" } }) +print(Util.JsonPrettify(myjson)) +``` + +--- + +### `Util.JsonMinify(json) -> string` + +Removes unnecessary whitespace and newlines from a JSON string. + +**Parameters:** +- `json` (string) - A valid JSON string. + +**Returns:** +- (string) - Minified JSON. + +**Usage:** +```lua +local pretty = Util.JsonPrettify(Util.JsonEncode({ name="Lion", age = 69 })) +print(Util.JsonMinify(pretty)) +``` + +--- + +### `Util.JsonFlatten(json) -> string` + +Flattens a nested JSON into `/a/b/c`-style keys per RFC 6901. + +**Parameters:** +- `json` (string) - A valid JSON string. + +**Returns:** +- (string) - Flattened JSON. + +**Usage:** +```lua +local json = Util.JsonEncode({ name="Lion", skills = { "skill A", "skill B" } }) +print(Util.JsonFlatten(json)) +-- '{"/name":"Lion","/skills/0":"skill A","/skills/1":"skill B"}' +``` + +--- + +### `Util.JsonUnflatten(json) -> string` + +Restores a flattened JSON back to its nested structure. + +**Parameters:** +- `json` (string) - A flattened JSON string. + +**Returns:** +- (string) - Nested JSON. + +--- + +### `Util.JsonDiff(a, b) -> string` + +Computes a diff between two JSON strings per RFC 6902. + +**Parameters:** +- `a` (string) - First JSON string. +- `b` (string) - Second JSON string. + +**Returns:** +- (string) - JSON Patch representing the differences. + +--- + +## Util — Random + +### `Util.Random() -> float` + +Returns a random float between 0 and 1. + +**Returns:** +- (float) + +**Usage:** +```lua +local rand = Util.Random() +print("rand: " .. rand) +-- rand: 0.135477 +``` + +--- + +### `Util.RandomRange(min, max) -> float` + +Returns a random float within a given range. + +**Parameters:** +- `min` (number) - Lower bound. +- `max` (number) - Upper bound. + +**Returns:** +- (float) + +**Usage:** +```lua +local randFloat = Util.RandomRange(1, 1000) +print("randFloat: " .. randFloat) +-- randFloat: 420.6969 +``` + +--- + +### `Util.RandomIntRange(min, max) -> number` + +Returns a random integer within a given range. + +**Parameters:** +- `min` (number) - Lower bound. +- `max` (number) - Upper bound. + +**Returns:** +- (number) - Integer. + +**Usage:** +```lua +local randInt = Util.RandomIntRange(1, 100) +print("randInt: " .. randInt) +-- randInt: 69 +``` + +--- + +## Util — Profiling + +### `Util.DebugStartProfile(name)` + +Starts a named execution time measurement. + +**Parameters:** +- `name` (string) - Identifier for this measurement. + +--- + +### `Util.DebugStopProfile(name)` + +Stops a named measurement. Must be called after `DebugStartProfile` with the same name. + +**Parameters:** +- `name` (string) - Identifier for this measurement. + +--- + +### `Util.DebugExecutionTime() -> table` + +Returns execution time statistics for every handler that has run. + +**Returns:** +- (table) - Per handler: `mean`, `stdev`, `min`, `max`, `n` (all in ms). + +**Usage:** +```lua +function printDebugExecutionTime() + local stats = Util.DebugExecutionTime() + local pretty = "DebugExecutionTime:\n" + local longest = 0 + for name, t in pairs(stats) do + if #name > longest then + longest = #name + end + end + for name, t in pairs(stats) do + pretty = pretty .. string.format("%" .. longest + 1 .. "s: %12f +/- %12f (min: %12f, max: %12f) (called %d time(s))\n", name, t.mean, t.stdev, t.min, t.max, t.n) + end + print(pretty) +end +``` + +--- + +## Http + +### `Http.CreateConnection(host, port) -> table` + +Creates an HTTP connection to an external server. + +**Parameters:** +- `host` (string) - Server address. +- `port` (number) - Port number. + +**Returns:** +- (table) - Connection object with method `:Get(path, headers)`. + +--- + +### `connection:Get(path, headers)` + +Sends an HTTP GET request. + +**Parameters:** +- `path` (string) - The request path. +- `headers` (table) - Headers as `{[string] = string}`. + +--- + +## FS — Checks + +### `FS.Exists(path) -> boolean` + +Returns whether a path exists. + +**Parameters:** +- `path` (string) - The path to check. + +**Returns:** +- (boolean) - `true` if exists. + +--- + +### `FS.IsDirectory(path) -> boolean` + +Returns whether a path is a directory. + +**Parameters:** +- `path` (string) - The path to check. + +**Returns:** +- (boolean) - `true` if directory. + +**Note:** +`false` does not imply the path is a file. Use `FS.IsFile` to check separately. + +--- + +### `FS.IsFile(path) -> boolean` + +Returns whether a path is a regular file. + +**Parameters:** +- `path` (string) - The path to check. + +**Returns:** +- (boolean) - `true` if regular file. + +**Note:** +`false` does not imply the path is a directory. + +--- + +## FS — Operations + +### `FS.CreateDirectory(path) -> boolean, string` + +Creates a directory including any missing parent directories (like `mkdir -p`). + +**Parameters:** +- `path` (string) - Path of the directory to create. + +**Returns:** +- (boolean) - `true` on success. +- (string) - Error message on failure, or `""` on success. + +**Usage:** +```lua +local success, error_message = FS.CreateDirectory("data/mystuff/somefolder") + +if not success then + print("failed to create directory: " .. error_message) +end +``` + +--- + +### `FS.Remove(path) -> boolean, string` + +Removes a file or empty directory. + +**Parameters:** +- `path` (string) - The path to remove. + +**Returns:** +- (boolean) - `true` on success. +- (string) - Error message on failure. + +--- + +### `FS.Rename(path, newPath) -> boolean, string` + +Renames or moves a file or directory. + +**Parameters:** +- `path` (string) - Current path. +- `newPath` (string) - New path. + +**Returns:** +- (boolean) - `true` on success. +- (string) - Error message on failure. + +--- + +### `FS.Copy(path, newPath) -> boolean, string` + +Copies a file or directory (recursive). + +**Parameters:** +- `path` (string) - Source path. +- `newPath` (string) - Destination path. + +**Returns:** +- (boolean) - `true` on success. +- (string) - Error message on failure. + +--- + +### `FS.ListFiles(path) -> table` + +Returns a list of file names in a directory (not recursive). + +**Parameters:** +- `path` (string) - Directory path. + +**Returns:** +- (table) - Array of file names. +- (nil) - If the path does not exist. + +**Usage:** +```lua +print(FS.ListFiles("Resources/Server/examplePlugin")) +-- { 1: "example.json", 2: "example.lua" } +``` + +--- + +### `FS.ListDirectories(path) -> table` + +Returns a list of directory names inside a directory (not recursive). + +**Parameters:** +- `path` (string) - Directory path. + +**Returns:** +- (table) - Array of directory names. +- (nil) - If the path does not exist. + +**Usage:** +```lua +print(FS.ListDirectories("Resources")) +-- { 1: "Client", 2: "Server" } +``` + +--- + +## FS — Paths + +### `FS.GetFilename(path) -> string` + +Returns the filename with extension from a path. + +**Parameters:** +- `path` (string) - A path string. + +**Returns:** +- (string) - The filename. + +**Usage:** +```lua +"my/path/a.txt" -> "a.txt" +"somefile.txt" -> "somefile.txt" +"/awesome/path" -> "path" +``` + +--- + +### `FS.GetExtension(path) -> string` + +Returns the file extension including the dot. + +**Parameters:** +- `path` (string) - A path string. + +**Returns:** +- (string) - The extension (e.g. `".json"`), or `""` if none. + +**Usage:** +```lua +"myfile.txt" -> ".txt" +"somefile." -> "." +"/awesome/path" -> "" +"/awesome/path/file.zip.txt" -> ".txt" +``` + +--- + +### `FS.GetParentFolder(path) -> string` + +Returns the path of the containing directory. + +**Parameters:** +- `path` (string) - A path string. + +**Returns:** +- (string) - Parent folder path. + +**Usage:** +```lua +"/var/tmp/example.txt" -> "/var/tmp" +"/" -> "/" +"mydir/a/b/c.txt" -> "mydir/a/b" +``` + +--- + +### `FS.ConcatPaths(...) -> string` + +Joins path segments together using the system's preferred separator, resolving `..` where present. + +**Parameters:** +- `...` (string) - Path segments. + +**Returns:** +- (string) - Joined path. + +**Usage:** +```lua +FS.ConcatPaths("a", "b", "/c/d/e/", "/f/", "g", "h.txt") +-- "a/b/c/d/e/f/g/h.txt" +``` + +--- + +## Events + +### Player connection order + +``` +onPlayerAuth → onPlayerConnecting → onPlayerJoining → onPlayerJoin +``` + +--- + +### `onInit` + +Triggered right after all plugin files have been loaded. + +**Arguments:** none +**Cancellable:** no + +--- + +### `onConsoleInput` + +Triggered when the server console receives input. + +**Arguments:** +- `input` (string) - The text that was entered. + +**Cancellable:** no + +**Usage:** +```lua +function handleConsoleInput(cmd) + local delim = cmd:find(' ') + if delim then + local message = cmd:sub(delim+1) + if cmd:sub(1, delim-1) == "print" then + return message + end + end +end + +MP.RegisterEvent("onConsoleInput", "handleConsoleInput") +``` + +--- + +### `onShutdown` + +Triggered when the server shuts down, after all players have been kicked. + +**Arguments:** none +**Cancellable:** no + +--- + +### `onPlayerAuth` + +Triggered when a player attempts to connect, before any other connection events. + +**Arguments:** +- `name` (string) - Player name. +- `role` (string) - Player role from the backend. +- `isGuest` (boolean) - Whether the player is a guest. +- `identifiers` (table) - Identifiers: `ip`, `beammp`, `discord`. + +**Cancellable:** yes +- Return `1` — deny with a generic message. +- Return `string` — deny with the string as the reason. +- Return `2` — allow entry even if the server is full. + +**Usage:** +```lua +function myPlayerAuthorizer(name, role, is_guest, identifiers) + return "Sorry, you cannot join at this time." +end + +MP.RegisterEvent("onPlayerAuth", "myPlayerAuthorizer") +``` + +--- + +### `postPlayerAuth` + +Triggered after `onPlayerAuth`, regardless of whether the player was accepted or rejected. + +**Arguments:** +- `wasRejected` (boolean) - Whether the player was rejected. +- `reason` (string) - Rejection reason if rejected. +- `name` (string) - Player name. +- `role` (string) - Player role. +- `isGuest` (boolean) - Whether guest. +- `identifiers` (table) - Identifiers. + +**Cancellable:** no + +--- + +### `onPlayerConnecting` + +Triggered when a player starts connecting, after `onPlayerAuth`. + +**Arguments:** +- `playerID` (number) + +**Cancellable:** no + +--- + +### `onPlayerJoining` + +Triggered after the player has finished downloading all mods. + +**Arguments:** +- `playerID` (number) + +**Cancellable:** no + +--- + +### `onPlayerJoin` + +Triggered after the player has finished syncing and entered the game. + +**Arguments:** +- `playerID` (number) + +**Cancellable:** no + +--- + +### `onPlayerDisconnect` + +Triggered when a player disconnects. + +**Arguments:** +- `playerID` (number) + +**Cancellable:** no + +--- + +### `onChatMessage` + +Triggered when a player sends a chat message. + +**Arguments:** +- `playerID` (number) +- `playerName` (string) +- `message` (string) + +**Cancellable:** yes — returning `1` prevents the message from being shown to anyone. + +**Usage:** +```lua +function MyChatMessageHandler(sender_id, sender_name, message) + if message == "darn" then + return 1 + else + return 0 + end +end + +MP.RegisterEvent("onChatMessage", "MyChatMessageHandler") +``` + +--- + +### `postChatMessage` + +Triggered after `onChatMessage`. + +**Arguments:** +- `wasSent` (boolean) - Whether the message was sent. +- `playerID` (number) +- `playerName` (string) +- `message` (string) + +**Cancellable:** no + +--- + +### `onVehicleSpawn` + +Triggered when a player spawns a new vehicle. + +**Arguments:** +- `playerID` (number) +- `vehicleID` (number) +- `data` (string) - JSON string with vehicle configuration and positional data. + +**Cancellable:** yes — returning a value other than `0` prevents the spawn. + +--- + +### `postVehicleSpawn` + +Triggered after `onVehicleSpawn`. + +**Arguments:** +- `wasSpawned` (boolean) - Whether the vehicle was actually spawned. +- `playerID` (number) +- `vehicleID` (number) +- `data` (string) + +**Cancellable:** no + +--- + +### `onVehicleEdited` + +Triggered when a player edits an existing vehicle. + +**Arguments:** +- `playerID` (number) +- `vehicleID` (number) +- `data` (string) - JSON string of the new configuration (does not include positional data). + +**Cancellable:** yes — returning a value other than `0` cancels the edit. + +--- + +### `postVehicleEdited` + +Triggered after `onVehicleEdited`. + +**Arguments:** +- `wasAllowed` (boolean) - Whether the edit was allowed. +- `playerID` (number) +- `vehicleID` (number) +- `data` (string) + +**Cancellable:** no + +--- + +### `onVehicleDeleted` + +Triggered when a vehicle is deleted. + +**Arguments:** +- `playerID` (number) +- `vehicleID` (number) + +**Cancellable:** no + +--- + +### `onVehicleReset` + +Triggered when a player resets a vehicle. + +**Arguments:** +- `playerID` (number) +- `vehicleID` (number) +- `data` (string) - JSON string of the new position and rotation (does not include configuration). + +**Cancellable:** no + +--- + +### `onVehiclePaintChanged` + +Triggered when a vehicle's paint is changed. + +**Arguments:** +- `playerID` (number) +- `vehicleID` (number) +- `data` (string) - JSON string with the new paint data. + +**Cancellable:** no + +--- + +### `onFileChanged` + +Triggered when a file in the plugin directory changes. + +**Arguments:** +- `path` (string) - Path of the changed file, relative to the server root. + +**Cancellable:** no + +**Note:** +Files added after the server has started are not tracked. diff --git a/docs/en/FAQ/march-28-outage.md b/docs/en/FAQ/march-28-outage.md new file mode 100644 index 0000000..0b0d42e --- /dev/null +++ b/docs/en/FAQ/march-28-outage.md @@ -0,0 +1,30 @@ +# March 28, 2026 BeamMP Outage FAQ + +Temporary FAQ for the (currently) ongoing BeamMP outage that started on March 28th, 2026. + +**Last updated April 1st, 2026.** + +=== Help! My BeamMP launcher doesn't work! + Try reinstalling the BeamMP launcher. To do so, follow the instructions below: + 1. Go to [beammp.com](https://beammp.com/) + 2. Click *Download Now* + 3. Run the installer and follow instructions + + !!! note + + As of April 1st, 2026, the MSI installer is an "unrecognized app" according to Windows Defender SmartScreen. + + To bypass this warning, click *More info*, then click *Run anyway*. + +=== Help! My authkey(s) don't work anymore! + As of April 1st, 2026, keymaster and auth systems are offline. This means that your authkeys won't work. To get around this, follow the instructions below: + 1. Open your `ServerConfig.toml`, or wherever your server config is modified + 2. Set `Private` to `true`. It should look like this: `Private = true` + 3. This should fix the authkey issue. + + !!! note + + As of April 1st, 2026, BeamMP's auth systems are offline. Only guest accounts are available. + + Make sure your server allows guests. + diff --git a/docs/en/beamng/cef-snippets.md b/docs/en/beamng/cef-snippets.md new file mode 100644 index 0000000..680d071 --- /dev/null +++ b/docs/en/beamng/cef-snippets.md @@ -0,0 +1,11 @@ +!!! warning "This site is under construction!" + + This site is being actively worked on. + + Feel you could help? Please do by clicking on the page with a pencil on the right! + + This can be done any page too. + +# BeamNG.drive CEF Code Snippets + +to-do diff --git a/docs/en/beamng/css-snippets.md b/docs/en/beamng/css-snippets.md new file mode 100644 index 0000000..6d0a6a9 --- /dev/null +++ b/docs/en/beamng/css-snippets.md @@ -0,0 +1,179 @@ +!!! warning "This site is under construction!" + + This site is being actively worked on. + + Feel you could help? Please do by clicking on the page with a pencil on the right! + + This can be done any page too. + +# BeamNG.drive CSS Code Snippets + +## Common variables + +=== BeamNG Orange + + ```css + var(--bng-orange) /*Common orange*/ + var(--bng-orange-shade1) /*70% opacity*/ + var(--bng-orange-shade2) /*40% opacity*/ + var(--bng-orange-shade1opaque) + var(--bng-orange-shade2opaque) + ``` + +=== Monochrome + + ```css + --- Monochrome + var(--bng-black-8) /*80% opacity (duplicate --bng-black-o8)*/ + var(--bng-black-6) /*60% opacity (duplicate --bng-black-o6)*/ + var(--bng-black-4) /*40% opacity (duplicate --bng-black-o4)*/ + var(--bng-black-2) /*20% opacity (duplicate --bng-black-o2)*/ + + var(--dark-neutral-grey) + var(--neutral-grey) + var(--light-neutral-grey) + var(--dark-grey) + var(--dark-grey-alpha) /*80% opacity*/ + + var(--black-1) /*70% opacity*/ + var(--black-2) /*40% opacity (duplicate --bng-black-o4)*/ + + var(--white-1) /*80% opacity*/ + var(--white-2) /*40% opacity*/ + var(--white-3) /*20% opacity*/ + ``` + +=== BeamNG UI Color Palette + + === Orange + + ```css + var(--bng-orange-50) + var(--bng-orange-100) + var(--bng-orange-200) + var(--bng-orange-300) + var(--bng-orange-b400) + var(--bng-orange-500) + var(--bng-orange-600) + var(--bng-orange-700) + var(--bng-orange-800) + var(--bng-orange-900) + ``` + + === Cool Gray + + ```css + var(--bng-cool-gray-50) + var(--bng-cool-gray-100) + var(--bng-cool-gray-200) + var(--bng-cool-gray-300) + var(--bng-cool-gray-400) + var(--bng-cool-gray-500) + var(--bng-cool-gray-600) + var(--bng-cool-gray-700) + var(--bng-cool-gray-800) + var(--bng-cool-gray-900) + ``` + + === Ter Blue + ```css + var(--bng-ter-blue-50) + var(--bng-ter-blue-100) + var(--bng-ter-blue-200) + var(--bng-ter-blue-300) + var(--bng-ter-blue-400) + var(--bng-ter-blue-500) + var(--bng-ter-blue-600) + var(--bng-ter-blue-700) + var(--bng-ter-blue-800) + var(--bng-ter-blue-900) + ``` + + === Add Blue + ```css + var(--bng-add-blue-50) + var(--bng-add-blue-100) + var(--bng-add-blue-200) + var(--bng-add-blue-300) + var(--bng-add-blue-400) + var(--bng-add-blue-500) + var(--bng-add-blue-600) + var(--bng-add-blue-700) + var(--bng-add-blue-800) + var(--bng-add-blue-900) + ``` + + === Add Green + ```css + var(--bng-add-green-50) + var(--bng-add-green-100) + var(--bng-add-green-200) + var(--bng-add-green-300) + var(--bng-add-green-400) + var(--bng-add-green-500) + var(--bng-add-green-600) + var(--bng-add-green-700) + var(--bng-add-green-800) + var(--bng-add-green-900) + ``` + + === Add Yellow + ```css + var(--bng-add-yellow-50) + var(--bng-add-yellow-100) + var(--bng-add-yellow-200) + var(--bng-add-yellow-300) + var(--bng-add-yellow-400) + var(--bng-add-yellow-500) + var(--bng-add-yellow-600) + var(--bng-add-yellow-700) + var(--bng-add-yellow-800) + var(--bng-add-yellow-900) + ``` + + === Add Peach + ```css + var(--bng-add-peach-50) + var(--bng-add-peach-100) + var(--bng-add-peach-200) + var(--bng-add-peach-300) + var(--bng-add-peach-400) + var(--bng-add-peach-500) + var(--bng-add-peach-600) + var(--bng-add-peach-700) + var(--bng-add-peach-800) + var(--bng-add-peach-900) + ``` + + === Add Red + ```css + var(--bng-add-red-50) + var(--bng-add-red-100) + var(--bng-add-red-200) + var(--bng-add-red-300) + var(--bng-add-red-400) + var(--bng-add-red-500) + var(--bng-add-red-600) + var(--bng-add-red-700) + var(--bng-add-red-800) + var(--bng-add-red-900) + ``` + + +=== Extra color presets + + ```css + var(--bng-filter-orange) /*Filter preset to force SVGs to use bng-orange*/ + var(--bng-black-o8) /*80% opacity*/ + var(--bng-black-o6) /*60% opacity*/ + var(--bng-black-o4) /*40% opacity*/ + var(--bng-black-o2) /*20% opacity*/ + ``` + +=== Corner rounding presets + + ```css + var(--bng-corners-1) /*0.25rem*/ + var(--bng-corners-2) /*0.50rem*/ + var(--bng-corners-3) /*1.00rem*/ + ``` diff --git a/docs/en/beamng/dev/modding/imgui-window-tutorial.md b/docs/en/beamng/dev/modding/imgui-window-tutorial.md new file mode 100644 index 0000000..6b70749 --- /dev/null +++ b/docs/en/beamng/dev/modding/imgui-window-tutorial.md @@ -0,0 +1,88 @@ +!!! warning "This site is under construction!" + + This site is being actively worked on. + + Feel you could help? Please do by clicking on the page with a pencil on the right! + + This can be done any page too. + # Creating an ImGui Window + +This page covers how to create a basic ImGui window. + +## Setup + +Before using ImGui, some setup is required: + +```lua +local im = ui_imgui -- shortcut to prevent lookups all the time. should help with optimization +local imguiExampleWindowOpen = im.BoolPtr(true) +``` + +`imguiExampleWindowOpen` will be used to determine when this example window should be rendered. + +## Window Rendering + +ImGui windows and their contents must be recreated for every frame they should be displayed. This means that some form of onUpdate function is necessary to use ImGui. + +```lua +local function onUpdate() + if worldReadyState == 2 then + if imguiExampleWindowOpen[0] == true then + imguiExample() + end + end +end +M.onUpdate = onUpdate +``` + +This will run a function to create this example's window, so long as the level is fully loaded, and that the example window should be displaying. + +## Window Content + +If you're new to writing ImGui, think of it as a distant cousin of HTML: + +* `im.SetNextWindowSize(im.ImVec2(x, y), im.Cond_FirstUseEver)` defines your viewport size if it hasn't already been defined +* `im.Begin()` and `im.End()` is your `` and `` +* `im.Text()` is your `

` + +```lua +local buttonPresses = 0 + +local function imguiExample() + im.SetNextWindowSize(im.ImVec2(366, 100), im.Cond_FirstUseEver) -- prepare our window + im.Begin("Hello World, I am a window") -- create a window with the title of "Hello World, I am a window" + im.Indent() -- a... padding element + im.Text("Hello World, I am text.") -- add a line of text, somewhat like a

element + im.SameLine() -- Not really HTML. This appends the following element to the same line as the previous element. + if im.Button("The Hello World Button") then -- Like