From 1d5062b2d5856c433e431a2785453367555f2564 Mon Sep 17 00:00:00 2001 From: Don Date: Tue, 12 Sep 2017 12:30:42 -0700 Subject: [PATCH 01/78] Initial commit --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..08ba7be7 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# fxserver-esx_identity +FXServer ESX Identity + +[REQUIREMENTS] + +* Dependencies For Full Functionality + * esx_policejob => https://github.com/FXServer-ESX/fxserver-esx_policejob + +[INSTALLATION] + +1) Install To resources/esx_identity +`<< MUST BE INSTALLED HERE` +2) Import esx_identity.sql in your database + +3) Add this in your server.cfg : + +``` +start esx_identity +``` +4) If you are using esx_policejob, you need to change Config.EnableESXIdentity = true in esx_policejob/config.lua +```Config.EnableESXIdentity = true``` + +Credits: +`Script Created By: ArkSeyonet @Ark` + +Licensing: +`This script uses GNU GPLv3` + From 2e892cd9466d6b22c673022ac66333f9d5cadf9e Mon Sep 17 00:00:00 2001 From: Don Date: Tue, 12 Sep 2017 12:31:14 -0700 Subject: [PATCH 02/78] Initial commit Initial commit --- .gitattributes | 2 + __resource.lua | 13 + client.lua | 76 ++++++ esx_identity.sql | 11 + html/cursor.png | Bin 0 -> 272 bytes html/index.html | 21 ++ html/script.js | 52 ++++ html/style.css | 51 ++++ license.txt | 674 +++++++++++++++++++++++++++++++++++++++++++++++ server.lua | 67 +++++ 10 files changed, 967 insertions(+) create mode 100644 .gitattributes create mode 100644 __resource.lua create mode 100644 client.lua create mode 100644 esx_identity.sql create mode 100644 html/cursor.png create mode 100644 html/index.html create mode 100644 html/script.js create mode 100644 html/style.css create mode 100644 license.txt create mode 100644 server.lua diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..eba1110b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto \ No newline at end of file diff --git a/__resource.lua b/__resource.lua new file mode 100644 index 00000000..b5ede11b --- /dev/null +++ b/__resource.lua @@ -0,0 +1,13 @@ +client_script('client.lua') + +server_script "@mysql-async/lib/MySQL.lua" +server_script "server.lua" + +ui_page('html/index.html') + +files({ + 'html/index.html', + 'html/script.js', + 'html/style.css', + 'html/cursor.png' +}) \ No newline at end of file diff --git a/client.lua b/client.lua new file mode 100644 index 00000000..5e85a9e2 --- /dev/null +++ b/client.lua @@ -0,0 +1,76 @@ +--================================================================================== +--====== ESX_IDENTITY BY ARKSEYONET @Ark ====== +--====== YOU CAN FIND ME ON MY DISCORD @Ark - https://discord.gg/cGHHxPX ====== +--====== IF YOU ALTER THIS VERSION OF THE SCRIPT, PLEASE GIVE ME CREDIT ====== +--====== Special Thanks To COSHAREK FOR THE UI Design ====== +--====== Special Thanks To Alphakush and CMD.Telhada For Help Testing ====== +--================================================================================== + +--=============================================== +--== VARIABLES == +--=============================================== +local guiEnabled = false +local myIdentity = {} + +--=============================================== +--== VARIABLES == +--=============================================== +function EnableGui(enable) + SetNuiFocus(enable) + guiEnabled = enable + + SendNUIMessage({ + type = "enableui", + enable = enable + }) +end + + +--=============================================== +--== Show Registration == +--=============================================== +RegisterNetEvent("esx_identity:showRegisterIdentity") +AddEventHandler("esx_identity:showRegisterIdentity", function() + EnableGui(true) +end) + +--=============================================== +--== Close GUI == +--=============================================== +RegisterNUICallback('escape', function(data, cb) + EnableGui(false) +end) + +--=============================================== +--== Register Callback == +--=============================================== +RegisterNUICallback('register', function(data, cb) + myIdentity = data + TriggerServerEvent('esx_identity:createIdentity', data) + EnableGui(false) + Wait (500) + TriggerEvent('esx_skin:openSaveableMenu') +end) + +--=============================================== +--== THREADING == +--=============================================== +Citizen.CreateThread(function() + while true do + if guiEnabled then + DisableControlAction(0, 1, guiEnabled) -- LookLeftRight + DisableControlAction(0, 2, guiEnabled) -- LookUpDown + + DisableControlAction(0, 142, guiEnabled) -- MeleeAttackAlternate + + DisableControlAction(0, 106, guiEnabled) -- VehicleMouseControlOverride + + if IsDisabledControlJustReleased(0, 142) then -- MeleeAttackAlternate + SendNUIMessage({ + type = "click" + }) + end + end + Citizen.Wait(0) + end +end) \ No newline at end of file diff --git a/esx_identity.sql b/esx_identity.sql new file mode 100644 index 00000000..cdc60abb --- /dev/null +++ b/esx_identity.sql @@ -0,0 +1,11 @@ +USE `essentialmode`; + + +CREATE TABLE `characters` ( + `identifier` varchar(255) NOT NULL, + `firstname` varchar(255) NOT NULL, + `lastname` varchar(255) NOT NULL, + `dateofbirth` varchar(255) NOT NULL, + `sex` varchar(1) NOT NULL DEFAULT 'f', + `height` varchar(128) NOT NULL +); \ No newline at end of file diff --git a/html/cursor.png b/html/cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..39536f953d701b36a90dc56084bafd988371a2fb GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^q9Dw{1|(OCFP#RYSkfJR9T^xl_H+M9WCij$3p^r= z85sBufiR<}hF1enP_o1|q9iy!t)x7$D3zfgF*C13FE6!3!9>qM&(L5k7uNxxqFzrI z#}Etut!FreS`>I(0^ikVp5f1PInc0ibrsXWO3z8Ee_BE>W<&%Ean9H1Y|@_Ma)5tI zP3vrppG@U}o4EJ`H!a-_TKCSz%v`zHX&3lrYRgJzbSuAt9 z@6PvoS_%Jm+&BGp_A+yZ?Fo&SwU@JtJ?kA`YTb#E`^&mC!8qZZWp1Mjt5em&H79@$ OWAJqKb6Mw<&;$S!<6)ox literal 0 HcmV?d00001 diff --git a/html/index.html b/html/index.html new file mode 100644 index 00000000..2f214da0 --- /dev/null +++ b/html/index.html @@ -0,0 +1,21 @@ + + + + + + + +
+
+
+
+
+
+
+ + +
+ + + + \ No newline at end of file diff --git a/html/script.js b/html/script.js new file mode 100644 index 00000000..a34ab658 --- /dev/null +++ b/html/script.js @@ -0,0 +1,52 @@ +var documentWidth = document.documentElement.clientWidth; +var documentHeight = document.documentElement.clientHeight; + +var cursor = document.getElementById("cursor"); +var cursorX = documentWidth / 2; +var cursorY = documentHeight / 2; + +function UpdateCursorPos() { + cursor.style.left = cursorX; + cursor.style.top = cursorY; +} + +function Click(x, y) { + var element = $(document.elementFromPoint(x, y)); + element.focus().click(); +} + +$(function() { + window.addEventListener('message', function(event) { + if (event.data.type == "enableui") { + cursor.style.display = event.data.enable ? "block" : "none"; + document.body.style.display = event.data.enable ? "block" : "none"; + } else if (event.data.type == "click") { + // Avoid clicking the cursor itself, click 1px to the top/left; + Click(cursorX - 1, cursorY - 1); + } + }); + + $(document).mousemove(function(event) { + cursorX = event.pageX; + cursorY = event.pageY; + UpdateCursorPos(); + }); + + document.onkeyup = function (data) { + if (data.which == 27) { // Escape key + $.post('http://esx_identity/escape', JSON.stringify({})); + } + }; + + $("#register").submit(function(e) { + e.preventDefault(); // Prevent form from submitting + + $.post('http://esx_identity/register', JSON.stringify({ + firstname: $("#firstname").val(), + lastname: $("#lastname").val(), + dateofbirth: $("#dateofbirth").val(), + sex: $("#sex").val(), + height: $("#height").val() + })); + }); +}); diff --git a/html/style.css b/html/style.css new file mode 100644 index 00000000..54bb4ec9 --- /dev/null +++ b/html/style.css @@ -0,0 +1,51 @@ +body { + font-family: sans-serif; + overflow: hidden; + display: none; +} + +#cursor { + position: absolute; + z-index: 999999; + display: none; +} + +.dialog { + width: 300px; + position: absolute; + left: 50%; + transform: translateX(-50%); + padding: 10px; + background-color: rgba(0, 0, 0, 0.5); +} + +form { + margin: 0; +} + +input[type=text] { + width: 100%; + padding: 10px; + text-align: center; +} + +button { + display: block; + margin-top: 5px; + padding: 10px; + background-color: Blue; + border: 0; + color: #fff; + width: 100%; +} + +h1 { + display: block; + margin-top: 5px; + margin-right: 5px; + padding: 10px; + background-color: Blue; + border: 0; + color: #fff; + width: 100%; +} \ No newline at end of file diff --git a/license.txt b/license.txt new file mode 100644 index 00000000..30ace6a8 --- /dev/null +++ b/license.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/server.lua b/server.lua new file mode 100644 index 00000000..7f1aa5ac --- /dev/null +++ b/server.lua @@ -0,0 +1,67 @@ +--================================================================================== +--====== ESX_IDENTITY BY ARKSEYONET @Ark ====== +--====== YOU CAN FIND ME ON MY DISCORD @Ark - https://discord.gg/cGHHxPX ====== +--====== IF YOU ALTER THIS VERSION OF THE SCRIPT, PLEASE GIVE ME CREDIT ====== +--====== Special Thanks To COSHAREK FOR THE UI Design ====== +--====== Special Thanks To Alphakush and CMD.Telhada For Help Testing ====== +--================================================================================== + +--=============================================== +--== Get The Player's Identification == +--=============================================== +function getIdentity(source) + local identifier = GetPlayerIdentifiers(source)[1] + local result = MySQL.Sync.fetchAll("SELECT * FROM characters WHERE identifier = @identifier", { + ['@identifier'] = identifier + }) + if result[1] ~= nil then + local identity = result[1] + + return { + identifier = identity['identifier'], + firstname = identity['firstname'], + lastname = identity['lastname'], + dateofbirth = identity['dateofbirth'], + sex = identity['sex'], + height = identity['height'] + } + else + return nil + end +end + +--=============================================== +--== Create The Player's Identification == +--=============================================== +function createIdentity(identifier, data) + MySQL.Sync.execute( + 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', + { + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, + ['@sex'] = data.sex, + ['@height'] = data.height + }) +end + +--=============================================== +--== Server Event Create Identity == +--=============================================== +RegisterServerEvent('esx_identity:createIdentity') +AddEventHandler('esx_identity:createIdentity', function(data) + createIdentity(GetPlayerIdentifiers(source)[1], data) +end) + +--=============================================== +--== Player Loaded Event Handler == +--=============================================== +AddEventHandler('es:playerLoaded', function(source) + local result = getIdentity(source) + if result == nil then + TriggerClientEvent('esx_identity:showRegisterIdentity', source) + else + end +end) + From 7be30b4c4d8f37b6e122047b8ac01b5a93070b72 Mon Sep 17 00:00:00 2001 From: nearbyplayer Date: Wed, 13 Sep 2017 06:00:37 -0400 Subject: [PATCH 03/78] Small fix --- server.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.lua b/server.lua index 7f1aa5ac..62a8cdba 100644 --- a/server.lua +++ b/server.lua @@ -59,7 +59,7 @@ end) --=============================================== AddEventHandler('es:playerLoaded', function(source) local result = getIdentity(source) - if result == nil then + if result ~= nil then TriggerClientEvent('esx_identity:showRegisterIdentity', source) else end From a9705ac27193ca40aecdb8fd6e64401d13654d83 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Wed, 13 Sep 2017 09:56:03 -0500 Subject: [PATCH 04/78] Update server.lua --- server.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/server.lua b/server.lua index 62a8cdba..46797e93 100644 --- a/server.lua +++ b/server.lua @@ -11,22 +11,19 @@ --=============================================== function getIdentity(source) local identifier = GetPlayerIdentifiers(source)[1] - local result = MySQL.Sync.fetchAll("SELECT * FROM characters WHERE identifier = @identifier", { + local result = MySQL.Sync.fetchAll("SELECT firstname, lastname FROM characters WHERE identifier = @identifier", { ['@identifier'] = identifier }) if result[1] ~= nil then local identity = result[1] return { - identifier = identity['identifier'], - firstname = identity['firstname'], - lastname = identity['lastname'], - dateofbirth = identity['dateofbirth'], - sex = identity['sex'], - height = identity['height'] + firstname = identity['firstname'] } else - return nil + return { + firstname = '' + } end end @@ -59,9 +56,11 @@ end) --=============================================== AddEventHandler('es:playerLoaded', function(source) local result = getIdentity(source) - if result ~= nil then + if result.firstname == '' then + print('Player Does Not Have An Identity') + Wait(2000) TriggerClientEvent('esx_identity:showRegisterIdentity', source) else + print('Player Has An Identity') end end) - From 6ffe62c364ef11a85ad61f3dc754c96e27b0f757 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Wed, 13 Sep 2017 09:59:05 -0500 Subject: [PATCH 05/78] Update server.lua --- server.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server.lua b/server.lua index 46797e93..4b92fbc2 100644 --- a/server.lua +++ b/server.lua @@ -11,18 +11,26 @@ --=============================================== function getIdentity(source) local identifier = GetPlayerIdentifiers(source)[1] - local result = MySQL.Sync.fetchAll("SELECT firstname, lastname FROM characters WHERE identifier = @identifier", { + local result = MySQL.Sync.fetchAll("SELECT * FROM characters WHERE identifier = @identifier", { ['@identifier'] = identifier }) if result[1] ~= nil then local identity = result[1] return { - firstname = identity['firstname'] + firstname = identity['firstname'], + lastname = identity['lastname'], + dateofbirth = identity['dateofbirth'], + sex = identity['sex'], + height = identity['height'] } else return { - firstname = '' + firstname = '', + lastname = '', + dateofbirth = '', + sex = '', + height = '' } end end From d0b76fd4de8ce50fce40978fd34737da70fc1df4 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Wed, 13 Sep 2017 10:00:31 -0500 Subject: [PATCH 06/78] Update server.lua --- server.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/server.lua b/server.lua index 4b92fbc2..1b48aae6 100644 --- a/server.lua +++ b/server.lua @@ -42,12 +42,12 @@ function createIdentity(identifier, data) MySQL.Sync.execute( 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', { - ['@identifier'] = identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, ['@sex'] = data.sex, - ['@height'] = data.height + ['@height'] = data.height }) end @@ -65,10 +65,9 @@ end) AddEventHandler('es:playerLoaded', function(source) local result = getIdentity(source) if result.firstname == '' then - print('Player Does Not Have An Identity') - Wait(2000) - TriggerClientEvent('esx_identity:showRegisterIdentity', source) - else - print('Player Has An Identity') - end + Wait(500) + TriggerClientEvent('esx_identity:showRegisterIdentity', source) + else + print('Player Has An Identity. Continuing.') + end end) From 6f7980d6e789a5747dd9ceb1f260ca9b201b3868 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Wed, 13 Sep 2017 10:01:53 -0500 Subject: [PATCH 07/78] Update server.lua --- server.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server.lua b/server.lua index 1b48aae6..a0e4208e 100644 --- a/server.lua +++ b/server.lua @@ -18,11 +18,11 @@ function getIdentity(source) local identity = result[1] return { - firstname = identity['firstname'], - lastname = identity['lastname'], - dateofbirth = identity['dateofbirth'], - sex = identity['sex'], - height = identity['height'] + firstname = identity['firstname'], + lastname = identity['lastname'], + dateofbirth = identity['dateofbirth'], + sex = identity['sex'], + height = identity['height'] } else return { From 4eb84d19ebece33613aaae192c19ef5eb3b3ae08 Mon Sep 17 00:00:00 2001 From: Romain Lanz Date: Thu, 14 Sep 2017 16:49:54 +0200 Subject: [PATCH 08/78] chore(coding-style): correct indentation --- .editorconfig | 9 ++++++ __resource.lua | 10 +++---- client.lua | 14 +++++----- esx_identity.sql | 16 +++++------ server.lua | 72 ++++++++++++++++++++++++------------------------ 5 files changed, 65 insertions(+), 56 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..4bfca33b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_size = 2 +indent_style = space +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/__resource.lua b/__resource.lua index b5ede11b..42c2dec2 100644 --- a/__resource.lua +++ b/__resource.lua @@ -6,8 +6,8 @@ server_script "server.lua" ui_page('html/index.html') files({ - 'html/index.html', - 'html/script.js', - 'html/style.css', - 'html/cursor.png' -}) \ No newline at end of file + 'html/index.html', + 'html/script.js', + 'html/style.css', + 'html/cursor.png', +}) diff --git a/client.lua b/client.lua index 5e85a9e2..086e995c 100644 --- a/client.lua +++ b/client.lua @@ -1,5 +1,5 @@ --================================================================================== ---====== ESX_IDENTITY BY ARKSEYONET @Ark ====== +--====== ESX_IDENTITY BY ARKSEYONET @Ark ====== --====== YOU CAN FIND ME ON MY DISCORD @Ark - https://discord.gg/cGHHxPX ====== --====== IF YOU ALTER THIS VERSION OF THE SCRIPT, PLEASE GIVE ME CREDIT ====== --====== Special Thanks To COSHAREK FOR THE UI Design ====== @@ -45,11 +45,11 @@ end) --== Register Callback == --=============================================== RegisterNUICallback('register', function(data, cb) - myIdentity = data - TriggerServerEvent('esx_identity:createIdentity', data) - EnableGui(false) - Wait (500) - TriggerEvent('esx_skin:openSaveableMenu') + myIdentity = data + TriggerServerEvent('esx_identity:createIdentity', data) + EnableGui(false) + Wait (500) + TriggerEvent('esx_skin:openSaveableMenu') end) --=============================================== @@ -73,4 +73,4 @@ Citizen.CreateThread(function() end Citizen.Wait(0) end -end) \ No newline at end of file +end) diff --git a/esx_identity.sql b/esx_identity.sql index cdc60abb..4e6aa28c 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -1,11 +1,11 @@ USE `essentialmode`; - + CREATE TABLE `characters` ( - `identifier` varchar(255) NOT NULL, - `firstname` varchar(255) NOT NULL, - `lastname` varchar(255) NOT NULL, - `dateofbirth` varchar(255) NOT NULL, - `sex` varchar(1) NOT NULL DEFAULT 'f', - `height` varchar(128) NOT NULL -); \ No newline at end of file + `identifier` varchar(255) NOT NULL, + `firstname` varchar(255) NOT NULL, + `lastname` varchar(255) NOT NULL, + `dateofbirth` varchar(255) NOT NULL, + `sex` varchar(1) NOT NULL DEFAULT 'f', + `height` varchar(128) NOT NULL +); diff --git a/server.lua b/server.lua index a0e4208e..8cedd197 100644 --- a/server.lua +++ b/server.lua @@ -1,5 +1,5 @@ --================================================================================== ---====== ESX_IDENTITY BY ARKSEYONET @Ark ====== +--====== ESX_IDENTITY BY ARKSEYONET @Ark ====== --====== YOU CAN FIND ME ON MY DISCORD @Ark - https://discord.gg/cGHHxPX ====== --====== IF YOU ALTER THIS VERSION OF THE SCRIPT, PLEASE GIVE ME CREDIT ====== --====== Special Thanks To COSHAREK FOR THE UI Design ====== @@ -14,24 +14,24 @@ function getIdentity(source) local result = MySQL.Sync.fetchAll("SELECT * FROM characters WHERE identifier = @identifier", { ['@identifier'] = identifier }) - if result[1] ~= nil then - local identity = result[1] - - return { - firstname = identity['firstname'], - lastname = identity['lastname'], - dateofbirth = identity['dateofbirth'], - sex = identity['sex'], - height = identity['height'] - } - else - return { - firstname = '', - lastname = '', - dateofbirth = '', - sex = '', - height = '' - } + if result[1] ~= nil then + local identity = result[1] + + return { + firstname = identity['firstname'], + lastname = identity['lastname'], + dateofbirth = identity['dateofbirth'], + sex = identity['sex'], + height = identity['height'] + } + else + return { + firstname = '', + lastname = '', + dateofbirth = '', + sex = '', + height = '' + } end end @@ -39,16 +39,16 @@ end --== Create The Player's Identification == --=============================================== function createIdentity(identifier, data) - MySQL.Sync.execute( - 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', - { - ['@identifier'] = identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }) + MySQL.Sync.execute( + 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', + { + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, + ['@sex'] = data.sex, + ['@height'] = data.height + }) end --=============================================== @@ -63,11 +63,11 @@ end) --== Player Loaded Event Handler == --=============================================== AddEventHandler('es:playerLoaded', function(source) - local result = getIdentity(source) - if result.firstname == '' then - Wait(500) - TriggerClientEvent('esx_identity:showRegisterIdentity', source) - else - print('Player Has An Identity. Continuing.') - end + local result = getIdentity(source) + if result.firstname == '' then + Wait(500) + TriggerClientEvent('esx_identity:showRegisterIdentity', source) + else + print('Player Has An Identity. Continuing.') + end end) From 2c6deb804234277ae7b561067fa1606b2e2618ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20N=27gadi?= Date: Fri, 15 Sep 2017 15:27:04 +0200 Subject: [PATCH 09/78] chore(resource): Add version --- __resource.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/__resource.lua b/__resource.lua index 42c2dec2..5ddf9e6f 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,3 +1,5 @@ +version '1.0.0' + client_script('client.lua') server_script "@mysql-async/lib/MySQL.lua" From ae8db72e038a1cfc24cf34777a2a4f514165337a Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 19 Sep 2017 12:23:49 -0500 Subject: [PATCH 10/78] Update esx_identity.sql --- esx_identity.sql | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/esx_identity.sql b/esx_identity.sql index 4e6aa28c..eec9e241 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -1,11 +1,9 @@ USE `essentialmode`; - -CREATE TABLE `characters` ( - `identifier` varchar(255) NOT NULL, - `firstname` varchar(255) NOT NULL, - `lastname` varchar(255) NOT NULL, - `dateofbirth` varchar(255) NOT NULL, - `sex` varchar(1) NOT NULL DEFAULT 'f', - `height` varchar(128) NOT NULL -); +ALTER TABLE `users` + ADD COLUMN `firstname` VARCHAR(50) NULL DEFAULT '', + ADD COLUMN `lastname` VARCHAR(50) NULL DEFAULT '', + ADD COLUMN `dateofbirth` VARCHAR(25) NULL DEFAULT '', + ADD COLUMN `sex` VARCHAR(10) NULL DEFAULT '', + ADD COLUMN `height` VARCHAR(5) NULL DEFAULT '' +; From 379262cd1ce166ee190367b93181a363491baa1c Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 19 Sep 2017 12:24:25 -0500 Subject: [PATCH 11/78] Update server.lua --- server.lua | 112 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 44 deletions(-) diff --git a/server.lua b/server.lua index 8cedd197..8d0edba1 100644 --- a/server.lua +++ b/server.lua @@ -1,73 +1,97 @@ --================================================================================== ---====== ESX_IDENTITY BY ARKSEYONET @Ark ====== +--====== ESX_IDENTITY BY ARKSEYONET @Ark ====== --====== YOU CAN FIND ME ON MY DISCORD @Ark - https://discord.gg/cGHHxPX ====== --====== IF YOU ALTER THIS VERSION OF THE SCRIPT, PLEASE GIVE ME CREDIT ====== ---====== Special Thanks To COSHAREK FOR THE UI Design ====== --====== Special Thanks To Alphakush and CMD.Telhada For Help Testing ====== --================================================================================== --=============================================== --== Get The Player's Identification == --=============================================== -function getIdentity(source) - local identifier = GetPlayerIdentifiers(source)[1] - local result = MySQL.Sync.fetchAll("SELECT * FROM characters WHERE identifier = @identifier", { - ['@identifier'] = identifier - }) - if result[1] ~= nil then - local identity = result[1] - - return { - firstname = identity['firstname'], - lastname = identity['lastname'], - dateofbirth = identity['dateofbirth'], - sex = identity['sex'], - height = identity['height'] - } - else - return { - firstname = '', - lastname = '', - dateofbirth = '', - sex = '', - height = '' - } - end +function getIdentity(source, callback) + local identifier = GetPlayerIdentifiers(source)[1] + MySQL.Async.fetchAll("SELECT * FROM `users` WHERE `identifier` = @identifier", + { + ['@identifier'] = identifier + }, + function(result) + if result[1]['firstname'] ~= nil then + local data = { + identifier = result[1]['identifier'], + firstname = result[1]['firstname'], + lastname = result[1]['lastname'], + dateofbirth = result[1]['dateofbirth'], + sex = result[1]['sex'], + height = result[1]['height'] + } + + callback(data) + else + local data = { + identifier = '', + firstname = '', + lastname = '', + dateofbirth = '', + sex = '', + height = '' + } + + callback(data) + end + end) end --=============================================== ---== Create The Player's Identification == +--== Set The Player's Identification == --=============================================== -function createIdentity(identifier, data) - MySQL.Sync.execute( - 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', +function setIdentity(identifier, data, callback) + MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", { ['@identifier'] = identifier, ['@firstname'] = data.firstname, ['@lastname'] = data.lastname, ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }) + ['@sex'] = data.sex, + ['@height'] = data.height + }, + function(done) + if callback then + callback(true) + end + end) end --=============================================== ---== Server Event Create Identity == +--== Server Event Set Identity == --=============================================== -RegisterServerEvent('esx_identity:createIdentity') -AddEventHandler('esx_identity:createIdentity', function(data) - createIdentity(GetPlayerIdentifiers(source)[1], data) +RegisterServerEvent('esx_identity:setIdentity') +AddEventHandler('esx_identity:setIdentity', function(data) + local identifier = GetPlayerIdentifiers(source)[1] + setIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + print('Successfully Set Identity For ' .. identifier) + else + print('Failed To Set Identity.') + end + end) end) --=============================================== --== Player Loaded Event Handler == --=============================================== AddEventHandler('es:playerLoaded', function(source) - local result = getIdentity(source) - if result.firstname == '' then - Wait(500) - TriggerClientEvent('esx_identity:showRegisterIdentity', source) - else - print('Player Has An Identity. Continuing.') - end + getIdentity(source, function(data) + if data.firstname == '' then + TriggerClientEvent('esx_identity:showRegisterIdentity', source) + else + print('Successfully Loaded Identity For ' .. data.firstname .. ' ' .. data.lastname) + end + end) +end) + +--=============================================== +--== /register - Open Registration == +--=============================================== +TriggerEvent('es:addCommand', 'register', function(source, args, user) + TriggerClientEvent('esx_identity:showRegisterIdentity', source, {}) end) From 02c48828984b565f444a75cd4c3387757da6be69 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 19 Sep 2017 12:24:55 -0500 Subject: [PATCH 12/78] Update client.lua --- client.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client.lua b/client.lua index 086e995c..985a001d 100644 --- a/client.lua +++ b/client.lua @@ -1,8 +1,7 @@ --================================================================================== ---====== ESX_IDENTITY BY ARKSEYONET @Ark ====== +--====== ESX_IDENTITY BY ARKSEYONET @Ark ====== --====== YOU CAN FIND ME ON MY DISCORD @Ark - https://discord.gg/cGHHxPX ====== --====== IF YOU ALTER THIS VERSION OF THE SCRIPT, PLEASE GIVE ME CREDIT ====== ---====== Special Thanks To COSHAREK FOR THE UI Design ====== --====== Special Thanks To Alphakush and CMD.Telhada For Help Testing ====== --================================================================================== @@ -46,7 +45,7 @@ end) --=============================================== RegisterNUICallback('register', function(data, cb) myIdentity = data - TriggerServerEvent('esx_identity:createIdentity', data) + TriggerServerEvent('esx_identity:setIdentity', data) EnableGui(false) Wait (500) TriggerEvent('esx_skin:openSaveableMenu') From fd71f3719ad54c574f0b0108209211c85ae01e7b Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 19 Sep 2017 12:25:21 -0500 Subject: [PATCH 13/78] Update index.html --- html/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/html/index.html b/html/index.html index 2f214da0..555b930b 100644 --- a/html/index.html +++ b/html/index.html @@ -7,6 +7,7 @@
+

Registration




@@ -18,4 +19,4 @@ - \ No newline at end of file + From a68be002728f1731fbdb4154b827c885c2db5ca9 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 19 Sep 2017 12:25:36 -0500 Subject: [PATCH 14/78] Update style.css --- html/style.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/html/style.css b/html/style.css index 54bb4ec9..e9e8069b 100644 --- a/html/style.css +++ b/html/style.css @@ -47,5 +47,6 @@ h1 { background-color: Blue; border: 0; color: #fff; - width: 100%; -} \ No newline at end of file + width: 93%; + text-align: center; +} From fba4e3911b48d58832a170ee7a8749d1ed3ce181 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 19 Sep 2017 12:28:26 -0500 Subject: [PATCH 15/78] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 08ba7be7..0a9bfd15 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,12 @@ FXServer ESX Identity [REQUIREMENTS] * Dependencies For Full Functionality - * esx_policejob => https://github.com/FXServer-ESX/fxserver-esx_policejob + * esx_policejob => https://github.com/ESX-Org/esx_policejob + * esx_society => https://github.com/ESX-Org/esx_society [INSTALLATION] -1) Install To resources/esx_identity +1) Install To resources/[esx]/esx_identity `<< MUST BE INSTALLED HERE` 2) Import esx_identity.sql in your database @@ -17,9 +18,12 @@ FXServer ESX Identity ``` start esx_identity ``` -4) If you are using esx_policejob, you need to change Config.EnableESXIdentity = true in esx_policejob/config.lua +4) If you are using esx_policejob or esx_society, you need to enable the following in the files config.lua: ```Config.EnableESXIdentity = true``` +Notice: +`Drop the characters table, it is no longer used` + Credits: `Script Created By: ArkSeyonet @Ark` From 265ac804e1d563f24734d2a358b3779e146a2afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20N=27gadi?= Date: Tue, 19 Sep 2017 20:18:39 +0200 Subject: [PATCH 16/78] chore(version): Increment version --- __resource.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__resource.lua b/__resource.lua index 5ddf9e6f..c937ec92 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,4 +1,4 @@ -version '1.0.0' +version '1.0.1' client_script('client.lua') From b602ea4135ce33f2d3313ab9f220dd9482f687fd Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Wed, 20 Sep 2017 19:43:57 -0500 Subject: [PATCH 17/78] update(feat): Multiple Characters (Command Based) (#4) * Update server.lua * Add files via upload * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update server.lua * Update server.lua --- README.md | 14 ++ esx_identity_update.sql | 11 ++ server.lua | 368 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 391 insertions(+), 2 deletions(-) create mode 100644 esx_identity_update.sql diff --git a/README.md b/README.md index 0a9bfd15..313a718b 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,26 @@ FXServer ESX Identity 3) Add this in your server.cfg : +Notice: +`If you were already using the latest version of esx_identity before the update, you can just import esx_identity_update.sql` + ``` start esx_identity ``` 4) If you are using esx_policejob or esx_society, you need to enable the following in the files config.lua: ```Config.EnableESXIdentity = true``` +``` +Commands: + +/identityhelp +/register +/charlist +/charselect 1,2,3 +/delchar 1,2,3 +``` + + Notice: `Drop the characters table, it is no longer used` diff --git a/esx_identity_update.sql b/esx_identity_update.sql new file mode 100644 index 00000000..14a05ed4 --- /dev/null +++ b/esx_identity_update.sql @@ -0,0 +1,11 @@ +USE `essentialmode`; + +CREATE TABLE `characters` ( + + `identifier` varchar(255) NOT NULL, + `firstname` varchar(255) NOT NULL, + `lastname` varchar(255) NOT NULL, + `dateofbirth` varchar(255) NOT NULL, + `sex` varchar(1) NOT NULL DEFAULT 'f', + `height` varchar(128) NOT NULL +); diff --git a/server.lua b/server.lua index 8d0edba1..35c2e1ab 100644 --- a/server.lua +++ b/server.lua @@ -1,10 +1,15 @@ --================================================================================== ---====== ESX_IDENTITY BY ARKSEYONET @Ark ====== +--====== ESX_IDENTITY BY ARKSEYONET @Ark ====== --====== YOU CAN FIND ME ON MY DISCORD @Ark - https://discord.gg/cGHHxPX ====== --====== IF YOU ALTER THIS VERSION OF THE SCRIPT, PLEASE GIVE ME CREDIT ====== +--====== Special Thanks To COSHAREK FOR THE UI Design ====== --====== Special Thanks To Alphakush and CMD.Telhada For Help Testing ====== --================================================================================== +--=================================================================== +--== MAIN FUNCTIONS == +--=================================================================== + --=============================================== --== Get The Player's Identification == --=============================================== @@ -41,11 +46,160 @@ function getIdentity(source, callback) end) end +--=============================================== +--== Get The Player's Identification == +--=============================================== +function getCharacters(source, callback) + local identifier = GetPlayerIdentifiers(source)[1] + MySQL.Async.fetchAll("SELECT * FROM `characters` WHERE `identifier` = @identifier", + { + ['@identifier'] = identifier + }, + function(result) + if result[1] and result[2] and result[3] then + local data = { + identifier = result[1]['identifier'], + firstname1 = result[1]['firstname'], + lastname1 = result[1]['lastname'], + dateofbirth1 = result[1]['dateofbirth'], + sex1 = result[1]['sex'], + height1 = result[1]['height'], + firstname2 = result[2]['firstname'], + lastname2 = result[2]['lastname'], + dateofbirth2 = result[2]['dateofbirth'], + sex2 = result[2]['sex'], + height2 = result[2]['height'], + firstname3 = result[3]['firstname'], + lastname3 = result[3]['lastname'], + dateofbirth3 = result[3]['dateofbirth'], + sex3 = result[3]['sex'], + height3 = result[3]['height'] + } + + callback(data) + elseif result[1] and result[2] and not result[3] then + local data = { + identifier = result[1]['identifier'], + firstname1 = result[1]['firstname'], + lastname1 = result[1]['lastname'], + dateofbirth1 = result[1]['dateofbirth'], + sex1 = result[1]['sex'], + height1 = result[1]['height'], + firstname2 = result[2]['firstname'], + lastname2 = result[2]['lastname'], + dateofbirth2 = result[2]['dateofbirth'], + sex2 = result[2]['sex'], + height2 = result[2]['height'], + firstname3 = '', + lastname3 = '', + dateofbirth3 = '', + sex3 = '', + height3 = '' + } + + callback(data) + elseif result[1] and not result[2] and not result[3] then + local data = { + identifier = result[1]['identifier'], + firstname1 = result[1]['firstname'], + lastname1 = result[1]['lastname'], + dateofbirth1 = result[1]['dateofbirth'], + sex1 = result[1]['sex'], + height1 = result[1]['height'], + firstname2 = '', + lastname2 = '', + dateofbirth2 = '', + sex2 = '', + height2 = '', + firstname3 = '', + lastname3 = '', + dateofbirth3 = '', + sex3 = '', + height3 = '' + } + + callback(data) + else + local data = { + identifier = '', + firstname1 = '', + lastname1 = '', + dateofbirth1 = '', + sex1 = '', + height1 = '', + firstname2 = '', + lastname2 = '', + dateofbirth2 = '', + sex2 = '', + height2 = '', + firstname3 = '', + lastname3 = '', + dateofbirth3 = '', + sex3 = '', + height3 = '' + } + + callback(data) + end + end) +end + --=============================================== --== Set The Player's Identification == --=============================================== function setIdentity(identifier, data, callback) MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", + { + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, + ['@sex'] = data.sex, + ['@height'] = data.height + }, + function(done) + if callback then + callback(true) + end + end) + + MySQL.Async.execute( + 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', + { + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, + ['@sex'] = data.sex, + ['@height'] = data.height + }) +end + +--=============================================== +--== Update The Player's Identification == +--=============================================== +function updateIdentity(identifier, data, callback) + MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", + { + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, + ['@sex'] = data.sex, + ['@height'] = data.height + }, + function(done) + if callback then + callback(true) + end + end) +end + +--=============================================== +--== Delete The Player's Identification == +--=============================================== +function deleteIdentity(identifier, data, callback) + MySQL.Async.execute("DELETE FROM `characters` WHERE identifier = @identifier AND firstname = @firstname AND lastname = @lastname AND dateofbirth = @dateofbirth AND sex = @sex AND height = @height", { ['@identifier'] = identifier, ['@firstname'] = data.firstname, @@ -89,9 +243,219 @@ AddEventHandler('es:playerLoaded', function(source) end) end) +--=================================================================== +--== MAIN COMMANDS == +--=================================================================== + +--=============================================== +--== /charlist - Show Your Characters == +--=============================================== +TriggerEvent('es:addGroupCommand', 'idhelp', "user", function(source, args, user) + TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "ESX_IDENTITY Commands") + TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/register - Register A New Character") + TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/charlist - List Your Characters") + TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/charselect 1,2,3 - Change Your Active Character") + TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/delchar 1,2,3 - Delete A Character") +end, function(source, args, user) + TriggerClientEvent('chatMessage', source, "IDHelp", {255, 0, 0}, "Insufficienct permissions!") +end, {help = "List Your Characters"}) + + --=============================================== --== /register - Open Registration == --=============================================== TriggerEvent('es:addCommand', 'register', function(source, args, user) - TriggerClientEvent('esx_identity:showRegisterIdentity', source, {}) + getCharacters(source, function(data) + if data.firstname3 ~= '' then + TriggerClientEvent('chatMessage', source, 'REGISTER', {255, 0, 0}, "You Can Only Have 3 Characters.") + else + TriggerClientEvent('esx_identity:showRegisterIdentity', source, {}) + end + end) +end) + +--=============================================== +--== /char - Show Active Character == +--=============================================== +TriggerEvent('es:addGroupCommand', 'char', "user", function(source, args, user) + getIdentity(source, function(data) + if data.firstname == '' then + TriggerClientEvent('chatMessage', source, 'CHAR', {255, 0, 0}, "You Have No Active Character.") + else + TriggerClientEvent('chatMessage', source, 'CHAR', {255, 0, 0}, "Active Character: " .. data.firstname .. " " .. data.lastname) + end + end) +end, function(source, args, user) + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") +end, {help = "List Your Current Active Character"}) + +--=============================================== +--== /charlist - Show Your Characters == +--=============================================== +TriggerEvent('es:addGroupCommand', 'charlist', "user", function(source, args, user) + getCharacters(source, function(data) + if data.firstname1 ~= '' then + TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 1: " .. data.firstname1 .. " " .. data.lastname1) + if data.firstname2 ~= '' then + TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 2: " .. data.firstname2 .. " " .. data.lastname2) + if data.firstname3 ~= '' then + TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 3: " .. data.firstname3 .. " " .. data.lastname3) + end + end + else + TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "You Have No Characters. Please use the /register command.") + end + end) +end, function(source, args, user) + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") +end, {help = "List Your Characters"}) + +--=============================================== +--== /charselect 1,2,3 Select Your Active Char == +--=============================================== +TriggerEvent('es:addCommand', 'charselect', function(source, args, user) + table.remove(args, 1) + local charNumber = tonumber(table.concat(args, " ")) + getCharacters(source, function(data) + if charNumber == 1 then + local data = { + identifier = data.identifier, + firstname = data.firstname1, + lastname = data.lastname1, + dateofbirth = data.dateofbirth1, + sex = data.sex1, + height = data.height1 + } + + if data.firstname ~= '' then + updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 1!") + end + elseif charNumber == 2 then + local data = { + identifier = data.identifier, + firstname = data.firstname2, + lastname = data.lastname2, + dateofbirth = data.dateofbirth2, + sex = data.sex2, + height = data.height2 + } + + if data.firstname ~= '' then + updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + + if callback == true then + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 2!") + end + elseif charNumber == 3 then + local data = { + identifier = data.identifier, + firstname = data.firstname3, + lastname = data.lastname3, + dateofbirth = data.dateofbirth3, + sex = data.sex3, + height = data.height3 + } + + if data.firstname ~= '' then + updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 3!") + end + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") + end + end) +end) + +--=============================================== +--== /charselect 1,2,3 Select Your Active Char == +--=============================================== +TriggerEvent('es:addCommand', 'delchar', function(source, args, user) + table.remove(args, 1) + local charNumber = tonumber(table.concat(args, " ")) + getCharacters(source, function(data) + if charNumber == 1 then + local data = { + identifier = data.identifier, + firstname = data.firstname1, + lastname = data.lastname1, + dateofbirth = data.dateofbirth1, + sex = data.sex1, + height = data.height1 + } + if data.firstname ~= '' then + deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 1!") + end + elseif charNumber == 2 then + local data = { + identifier = data.identifier, + firstname = data.firstname2, + lastname = data.lastname2, + dateofbirth = data.dateofbirth2, + sex = data.sex2, + height = data.height2 + } + if data.firstname ~= '' then + deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 2!") + end + elseif charNumber == 3 then + local data = { + identifier = data.identifier, + firstname = data.firstname3, + lastname = data.lastname3, + dateofbirth = data.dateofbirth3, + sex = data.sex3, + height = data.height3 + } + if data.firstname ~= '' then + deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 3!") + end + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") + end + end) end) From 74e17a05f785047797da67c5bf317a0bcf85b79e Mon Sep 17 00:00:00 2001 From: nearbyplayer <3721216+nearbyplayer@users.noreply.github.com> Date: Wed, 20 Sep 2017 20:44:40 -0400 Subject: [PATCH 18/78] chore: bump version --- __resource.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__resource.lua b/__resource.lua index c937ec92..c8055612 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,4 +1,4 @@ -version '1.0.1' +version '1.0.2' client_script('client.lua') From 5c3bf1f262c16015e1741d389b9ae5b130725e2d Mon Sep 17 00:00:00 2001 From: nearbyplayer Date: Wed, 20 Sep 2017 20:51:53 -0400 Subject: [PATCH 19/78] chore(coding-style): correct indentation --- server.lua | 678 ++++++++++++++++++++++++++--------------------------- 1 file changed, 339 insertions(+), 339 deletions(-) diff --git a/server.lua b/server.lua index 35c2e1ab..b09c840a 100644 --- a/server.lua +++ b/server.lua @@ -1,5 +1,5 @@ --================================================================================== ---====== ESX_IDENTITY BY ARKSEYONET @Ark ====== +--====== ESX_IDENTITY BY ARKSEYONET @Ark ====== --====== YOU CAN FIND ME ON MY DISCORD @Ark - https://discord.gg/cGHHxPX ====== --====== IF YOU ALTER THIS VERSION OF THE SCRIPT, PLEASE GIVE ME CREDIT ====== --====== Special Thanks To COSHAREK FOR THE UI Design ====== @@ -14,134 +14,134 @@ --== Get The Player's Identification == --=============================================== function getIdentity(source, callback) - local identifier = GetPlayerIdentifiers(source)[1] + local identifier = GetPlayerIdentifiers(source)[1] MySQL.Async.fetchAll("SELECT * FROM `users` WHERE `identifier` = @identifier", - { - ['@identifier'] = identifier - }, - function(result) - if result[1]['firstname'] ~= nil then - local data = { - identifier = result[1]['identifier'], - firstname = result[1]['firstname'], - lastname = result[1]['lastname'], - dateofbirth = result[1]['dateofbirth'], - sex = result[1]['sex'], - height = result[1]['height'] - } - - callback(data) - else - local data = { - identifier = '', - firstname = '', - lastname = '', - dateofbirth = '', - sex = '', - height = '' - } - - callback(data) - end - end) + { + ['@identifier'] = identifier + }, + function(result) + if result[1]['firstname'] ~= nil then + local data = { + identifier = result[1]['identifier'], + firstname = result[1]['firstname'], + lastname = result[1]['lastname'], + dateofbirth = result[1]['dateofbirth'], + sex = result[1]['sex'], + height = result[1]['height'] + } + + callback(data) + else + local data = { + identifier = '', + firstname = '', + lastname = '', + dateofbirth = '', + sex = '', + height = '' + } + + callback(data) + end + end) end --=============================================== --== Get The Player's Identification == --=============================================== function getCharacters(source, callback) - local identifier = GetPlayerIdentifiers(source)[1] + local identifier = GetPlayerIdentifiers(source)[1] MySQL.Async.fetchAll("SELECT * FROM `characters` WHERE `identifier` = @identifier", - { - ['@identifier'] = identifier - }, - function(result) - if result[1] and result[2] and result[3] then - local data = { - identifier = result[1]['identifier'], - firstname1 = result[1]['firstname'], - lastname1 = result[1]['lastname'], - dateofbirth1 = result[1]['dateofbirth'], - sex1 = result[1]['sex'], - height1 = result[1]['height'], - firstname2 = result[2]['firstname'], - lastname2 = result[2]['lastname'], - dateofbirth2 = result[2]['dateofbirth'], - sex2 = result[2]['sex'], - height2 = result[2]['height'], - firstname3 = result[3]['firstname'], - lastname3 = result[3]['lastname'], - dateofbirth3 = result[3]['dateofbirth'], - sex3 = result[3]['sex'], - height3 = result[3]['height'] - } - - callback(data) - elseif result[1] and result[2] and not result[3] then - local data = { - identifier = result[1]['identifier'], - firstname1 = result[1]['firstname'], - lastname1 = result[1]['lastname'], - dateofbirth1 = result[1]['dateofbirth'], - sex1 = result[1]['sex'], - height1 = result[1]['height'], - firstname2 = result[2]['firstname'], - lastname2 = result[2]['lastname'], - dateofbirth2 = result[2]['dateofbirth'], - sex2 = result[2]['sex'], - height2 = result[2]['height'], - firstname3 = '', - lastname3 = '', - dateofbirth3 = '', - sex3 = '', - height3 = '' - } - - callback(data) - elseif result[1] and not result[2] and not result[3] then - local data = { - identifier = result[1]['identifier'], - firstname1 = result[1]['firstname'], - lastname1 = result[1]['lastname'], - dateofbirth1 = result[1]['dateofbirth'], - sex1 = result[1]['sex'], - height1 = result[1]['height'], - firstname2 = '', - lastname2 = '', - dateofbirth2 = '', - sex2 = '', - height2 = '', - firstname3 = '', - lastname3 = '', - dateofbirth3 = '', - sex3 = '', - height3 = '' - } - - callback(data) - else - local data = { - identifier = '', - firstname1 = '', - lastname1 = '', - dateofbirth1 = '', - sex1 = '', - height1 = '', - firstname2 = '', - lastname2 = '', - dateofbirth2 = '', - sex2 = '', - height2 = '', - firstname3 = '', - lastname3 = '', - dateofbirth3 = '', - sex3 = '', - height3 = '' - } - - callback(data) - end - end) + { + ['@identifier'] = identifier + }, + function(result) + if result[1] and result[2] and result[3] then + local data = { + identifier = result[1]['identifier'], + firstname1 = result[1]['firstname'], + lastname1 = result[1]['lastname'], + dateofbirth1 = result[1]['dateofbirth'], + sex1 = result[1]['sex'], + height1 = result[1]['height'], + firstname2 = result[2]['firstname'], + lastname2 = result[2]['lastname'], + dateofbirth2 = result[2]['dateofbirth'], + sex2 = result[2]['sex'], + height2 = result[2]['height'], + firstname3 = result[3]['firstname'], + lastname3 = result[3]['lastname'], + dateofbirth3 = result[3]['dateofbirth'], + sex3 = result[3]['sex'], + height3 = result[3]['height'] + } + + callback(data) + elseif result[1] and result[2] and not result[3] then + local data = { + identifier = result[1]['identifier'], + firstname1 = result[1]['firstname'], + lastname1 = result[1]['lastname'], + dateofbirth1 = result[1]['dateofbirth'], + sex1 = result[1]['sex'], + height1 = result[1]['height'], + firstname2 = result[2]['firstname'], + lastname2 = result[2]['lastname'], + dateofbirth2 = result[2]['dateofbirth'], + sex2 = result[2]['sex'], + height2 = result[2]['height'], + firstname3 = '', + lastname3 = '', + dateofbirth3 = '', + sex3 = '', + height3 = '' + } + + callback(data) + elseif result[1] and not result[2] and not result[3] then + local data = { + identifier = result[1]['identifier'], + firstname1 = result[1]['firstname'], + lastname1 = result[1]['lastname'], + dateofbirth1 = result[1]['dateofbirth'], + sex1 = result[1]['sex'], + height1 = result[1]['height'], + firstname2 = '', + lastname2 = '', + dateofbirth2 = '', + sex2 = '', + height2 = '', + firstname3 = '', + lastname3 = '', + dateofbirth3 = '', + sex3 = '', + height3 = '' + } + + callback(data) + else + local data = { + identifier = '', + firstname1 = '', + lastname1 = '', + dateofbirth1 = '', + sex1 = '', + height1 = '', + firstname2 = '', + lastname2 = '', + dateofbirth2 = '', + sex2 = '', + height2 = '', + firstname3 = '', + lastname3 = '', + dateofbirth3 = '', + sex3 = '', + height3 = '' + } + + callback(data) + end + end) end --=============================================== @@ -154,25 +154,25 @@ function setIdentity(identifier, data, callback) ['@firstname'] = data.firstname, ['@lastname'] = data.lastname, ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height + ['@sex'] = data.sex, + ['@height'] = data.height }, - function(done) - if callback then - callback(true) - end - end) - - MySQL.Async.execute( - 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', - { - ['@identifier'] = identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }) + function(done) + if callback then + callback(true) + end + end) + + MySQL.Async.execute( + 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', + { + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, + ['@sex'] = data.sex, + ['@height'] = data.height + }) end --=============================================== @@ -185,14 +185,14 @@ function updateIdentity(identifier, data, callback) ['@firstname'] = data.firstname, ['@lastname'] = data.lastname, ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height + ['@sex'] = data.sex, + ['@height'] = data.height }, - function(done) - if callback then - callback(true) - end - end) + function(done) + if callback then + callback(true) + end + end) end --=============================================== @@ -205,14 +205,14 @@ function deleteIdentity(identifier, data, callback) ['@firstname'] = data.firstname, ['@lastname'] = data.lastname, ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height + ['@sex'] = data.sex, + ['@height'] = data.height }, - function(done) - if callback then - callback(true) - end - end) + function(done) + if callback then + callback(true) + end + end) end --=============================================== @@ -220,27 +220,27 @@ end --=============================================== RegisterServerEvent('esx_identity:setIdentity') AddEventHandler('esx_identity:setIdentity', function(data) - local identifier = GetPlayerIdentifiers(source)[1] + local identifier = GetPlayerIdentifiers(source)[1] setIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - print('Successfully Set Identity For ' .. identifier) - else - print('Failed To Set Identity.') - end - end) + if callback == true then + print('Successfully Set Identity For ' .. identifier) + else + print('Failed To Set Identity.') + end + end) end) --=============================================== --== Player Loaded Event Handler == --=============================================== AddEventHandler('es:playerLoaded', function(source) - getIdentity(source, function(data) - if data.firstname == '' then - TriggerClientEvent('esx_identity:showRegisterIdentity', source) - else - print('Successfully Loaded Identity For ' .. data.firstname .. ' ' .. data.lastname) - end - end) + getIdentity(source, function(data) + if data.firstname == '' then + TriggerClientEvent('esx_identity:showRegisterIdentity', source) + else + print('Successfully Loaded Identity For ' .. data.firstname .. ' ' .. data.lastname) + end + end) end) --=================================================================== @@ -251,13 +251,13 @@ end) --== /charlist - Show Your Characters == --=============================================== TriggerEvent('es:addGroupCommand', 'idhelp', "user", function(source, args, user) - TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "ESX_IDENTITY Commands") - TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/register - Register A New Character") - TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/charlist - List Your Characters") - TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/charselect 1,2,3 - Change Your Active Character") - TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/delchar 1,2,3 - Delete A Character") + TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "ESX_IDENTITY Commands") + TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/register - Register A New Character") + TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/charlist - List Your Characters") + TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/charselect 1,2,3 - Change Your Active Character") + TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/delchar 1,2,3 - Delete A Character") end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "IDHelp", {255, 0, 0}, "Insufficienct permissions!") + TriggerClientEvent('chatMessage', source, "IDHelp", {255, 0, 0}, "Insufficienct permissions!") end, {help = "List Your Characters"}) @@ -265,197 +265,197 @@ end, {help = "List Your Characters"}) --== /register - Open Registration == --=============================================== TriggerEvent('es:addCommand', 'register', function(source, args, user) - getCharacters(source, function(data) - if data.firstname3 ~= '' then - TriggerClientEvent('chatMessage', source, 'REGISTER', {255, 0, 0}, "You Can Only Have 3 Characters.") - else - TriggerClientEvent('esx_identity:showRegisterIdentity', source, {}) - end - end) + getCharacters(source, function(data) + if data.firstname3 ~= '' then + TriggerClientEvent('chatMessage', source, 'REGISTER', {255, 0, 0}, "You Can Only Have 3 Characters.") + else + TriggerClientEvent('esx_identity:showRegisterIdentity', source, {}) + end + end) end) --=============================================== --== /char - Show Active Character == --=============================================== TriggerEvent('es:addGroupCommand', 'char', "user", function(source, args, user) - getIdentity(source, function(data) - if data.firstname == '' then - TriggerClientEvent('chatMessage', source, 'CHAR', {255, 0, 0}, "You Have No Active Character.") - else - TriggerClientEvent('chatMessage', source, 'CHAR', {255, 0, 0}, "Active Character: " .. data.firstname .. " " .. data.lastname) - end - end) + getIdentity(source, function(data) + if data.firstname == '' then + TriggerClientEvent('chatMessage', source, 'CHAR', {255, 0, 0}, "You Have No Active Character.") + else + TriggerClientEvent('chatMessage', source, 'CHAR', {255, 0, 0}, "Active Character: " .. data.firstname .. " " .. data.lastname) + end + end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") end, {help = "List Your Current Active Character"}) --=============================================== --== /charlist - Show Your Characters == --=============================================== TriggerEvent('es:addGroupCommand', 'charlist', "user", function(source, args, user) - getCharacters(source, function(data) - if data.firstname1 ~= '' then - TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 1: " .. data.firstname1 .. " " .. data.lastname1) - if data.firstname2 ~= '' then - TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 2: " .. data.firstname2 .. " " .. data.lastname2) - if data.firstname3 ~= '' then - TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 3: " .. data.firstname3 .. " " .. data.lastname3) - end - end - else - TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "You Have No Characters. Please use the /register command.") - end - end) + getCharacters(source, function(data) + if data.firstname1 ~= '' then + TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 1: " .. data.firstname1 .. " " .. data.lastname1) + if data.firstname2 ~= '' then + TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 2: " .. data.firstname2 .. " " .. data.lastname2) + if data.firstname3 ~= '' then + TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 3: " .. data.firstname3 .. " " .. data.lastname3) + end + end + else + TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "You Have No Characters. Please use the /register command.") + end + end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") end, {help = "List Your Characters"}) --=============================================== --== /charselect 1,2,3 Select Your Active Char == --=============================================== TriggerEvent('es:addCommand', 'charselect', function(source, args, user) - table.remove(args, 1) - local charNumber = tonumber(table.concat(args, " ")) - getCharacters(source, function(data) - if charNumber == 1 then - local data = { - identifier = data.identifier, - firstname = data.firstname1, - lastname = data.lastname1, - dateofbirth = data.dateofbirth1, - sex = data.sex1, - height = data.height1 - } - - if data.firstname ~= '' then - updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 1!") - end - elseif charNumber == 2 then - local data = { - identifier = data.identifier, - firstname = data.firstname2, - lastname = data.lastname2, - dateofbirth = data.dateofbirth2, - sex = data.sex2, - height = data.height2 - } - - if data.firstname ~= '' then - updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + table.remove(args, 1) + local charNumber = tonumber(table.concat(args, " ")) + getCharacters(source, function(data) + if charNumber == 1 then + local data = { + identifier = data.identifier, + firstname = data.firstname1, + lastname = data.lastname1, + dateofbirth = data.dateofbirth1, + sex = data.sex1, + height = data.height1 + } - if callback == true then - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 2!") - end - elseif charNumber == 3 then - local data = { - identifier = data.identifier, - firstname = data.firstname3, - lastname = data.lastname3, - dateofbirth = data.dateofbirth3, - sex = data.sex3, - height = data.height3 - } - - if data.firstname ~= '' then - updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 3!") - end - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") - end - end) + if data.firstname ~= '' then + updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 1!") + end + elseif charNumber == 2 then + local data = { + identifier = data.identifier, + firstname = data.firstname2, + lastname = data.lastname2, + dateofbirth = data.dateofbirth2, + sex = data.sex2, + height = data.height2 + } + + if data.firstname ~= '' then + updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + + if callback == true then + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 2!") + end + elseif charNumber == 3 then + local data = { + identifier = data.identifier, + firstname = data.firstname3, + lastname = data.lastname3, + dateofbirth = data.dateofbirth3, + sex = data.sex3, + height = data.height3 + } + + if data.firstname ~= '' then + updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 3!") + end + else + TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") + end + end) end) --=============================================== --== /charselect 1,2,3 Select Your Active Char == --=============================================== TriggerEvent('es:addCommand', 'delchar', function(source, args, user) - table.remove(args, 1) - local charNumber = tonumber(table.concat(args, " ")) - getCharacters(source, function(data) - if charNumber == 1 then - local data = { - identifier = data.identifier, - firstname = data.firstname1, - lastname = data.lastname1, - dateofbirth = data.dateofbirth1, - sex = data.sex1, - height = data.height1 - } - if data.firstname ~= '' then - deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 1!") - end - elseif charNumber == 2 then - local data = { - identifier = data.identifier, - firstname = data.firstname2, - lastname = data.lastname2, - dateofbirth = data.dateofbirth2, - sex = data.sex2, - height = data.height2 - } - if data.firstname ~= '' then - deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 2!") - end - elseif charNumber == 3 then - local data = { - identifier = data.identifier, - firstname = data.firstname3, - lastname = data.lastname3, - dateofbirth = data.dateofbirth3, - sex = data.sex3, - height = data.height3 - } - if data.firstname ~= '' then - deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 3!") - end - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") - end - end) + table.remove(args, 1) + local charNumber = tonumber(table.concat(args, " ")) + getCharacters(source, function(data) + if charNumber == 1 then + local data = { + identifier = data.identifier, + firstname = data.firstname1, + lastname = data.lastname1, + dateofbirth = data.dateofbirth1, + sex = data.sex1, + height = data.height1 + } + if data.firstname ~= '' then + deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 1!") + end + elseif charNumber == 2 then + local data = { + identifier = data.identifier, + firstname = data.firstname2, + lastname = data.lastname2, + dateofbirth = data.dateofbirth2, + sex = data.sex2, + height = data.height2 + } + if data.firstname ~= '' then + deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 2!") + end + elseif charNumber == 3 then + local data = { + identifier = data.identifier, + firstname = data.firstname3, + lastname = data.lastname3, + dateofbirth = data.dateofbirth3, + sex = data.sex3, + height = data.height3 + } + if data.firstname ~= '' then + deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback == true then + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 3!") + end + else + TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") + end + end) end) From 3a2e5e7eb46453fdfbc0b7d22dc16890711e2c52 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 10 Oct 2017 06:25:27 -0500 Subject: [PATCH 20/78] Update esx_identity.sql --- esx_identity.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/esx_identity.sql b/esx_identity.sql index eec9e241..55dbfd88 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -7,3 +7,13 @@ ALTER TABLE `users` ADD COLUMN `sex` VARCHAR(10) NULL DEFAULT '', ADD COLUMN `height` VARCHAR(5) NULL DEFAULT '' ; + +CREATE TABLE `characters` ( + + `identifier` varchar(255) NOT NULL, + `firstname` varchar(255) NOT NULL, + `lastname` varchar(255) NOT NULL, + `dateofbirth` varchar(255) NOT NULL, + `sex` varchar(1) NOT NULL DEFAULT 'f', + `height` varchar(128) NOT NULL +); From d2f91fbaa267f39b06f282ba2568e82a4dad5e71 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 10 Oct 2017 06:26:50 -0500 Subject: [PATCH 21/78] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 313a718b..f063e967 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,12 @@ Commands: /delchar 1,2,3 ``` - -Notice: -`Drop the characters table, it is no longer used` - Credits: `Script Created By: ArkSeyonet @Ark` Licensing: `This script uses GNU GPLv3` +Notice: +`This version is not compatible with ES5, you must use https://github.com/ArkSeyonet/esx_identity_es5 if you are using es5` + From 240e83fb8c136fcf4b21260b52356879b3ef68ec Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 10 Oct 2017 06:27:15 -0500 Subject: [PATCH 22/78] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f063e967..10c088fa 100644 --- a/README.md +++ b/README.md @@ -41,5 +41,5 @@ Licensing: `This script uses GNU GPLv3` Notice: -`This version is not compatible with ES5, you must use https://github.com/ArkSeyonet/esx_identity_es5 if you are using es5` +``This version is not compatible with ES5, you must use https://github.com/ArkSeyonet/esx_identity_es5 if you are using es5 From 0c305772610793b4b42b02aa1d82c7709bfd5b88 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 10 Oct 2017 06:27:48 -0500 Subject: [PATCH 23/78] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 10c088fa..0a38cfb6 100644 --- a/README.md +++ b/README.md @@ -41,5 +41,5 @@ Licensing: `This script uses GNU GPLv3` Notice: -``This version is not compatible with ES5, you must use https://github.com/ArkSeyonet/esx_identity_es5 if you are using es5 +`This version is not compatible with ES5, you must use the new version if you are using es5` https://github.com/ArkSeyonet/esx_identity_es5 From 5eec6b6ad98d9dd2e29ec45efdafbe02b4e784e9 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 10 Oct 2017 06:28:09 -0500 Subject: [PATCH 24/78] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a38cfb6..e2d997bb 100644 --- a/README.md +++ b/README.md @@ -41,5 +41,6 @@ Licensing: `This script uses GNU GPLv3` Notice: -`This version is not compatible with ES5, you must use the new version if you are using es5` https://github.com/ArkSeyonet/esx_identity_es5 + +This version is not compatible with ES5, you must use the new version if you are using es5 => https://github.com/ArkSeyonet/esx_identity_es5 From e6c9d317150debe1acf0312bae7cfa6342ee2041 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 10 Oct 2017 06:28:39 -0500 Subject: [PATCH 25/78] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index e2d997bb..16060125 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,5 @@ Credits: Licensing: `This script uses GNU GPLv3` -Notice: - This version is not compatible with ES5, you must use the new version if you are using es5 => https://github.com/ArkSeyonet/esx_identity_es5 From 99f186b8b2366d26c2f40856507cc64c2537b104 Mon Sep 17 00:00:00 2001 From: Samuel Date: Sun, 15 Apr 2018 12:12:45 +0200 Subject: [PATCH 26/78] Update README.md --- README.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 16060125..aa35bfa9 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ -# fxserver-esx_identity -FXServer ESX Identity +# esx_identity + +### Important message +This version is not compatible with ES5, use [esx_identity_es5](https://github.com/ArkSeyonet/esx_identity_es5) [REQUIREMENTS] * Dependencies For Full Functionality - * esx_policejob => https://github.com/ESX-Org/esx_policejob - * esx_society => https://github.com/ESX-Org/esx_society + * [esx_policejob](https://github.com/ESX-Org/esx_policejob) + * [esx_society](https://github.com/ESX-Org/esx_society) [INSTALLATION] @@ -34,11 +36,5 @@ Commands: /delchar 1,2,3 ``` -Credits: -`Script Created By: ArkSeyonet @Ark` - -Licensing: -`This script uses GNU GPLv3` - -This version is not compatible with ES5, you must use the new version if you are using es5 => https://github.com/ArkSeyonet/esx_identity_es5 - +### License +This script is licensed under GPLv3, see the [license](license.txt) From cb68068cb713ea856ae8d39dde9a93cf9246e14c Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 15 Apr 2018 12:23:40 +0200 Subject: [PATCH 27/78] Initial edits for ES5 --- .editorconfig | 9 ----- .gitattributes | 2 - license.txt => LICENSE | 0 README.md | 9 ++--- __resource.lua | 31 ++++++++++----- client.lua | 75 ----------------------------------- client/main.lua | 46 +++++++++++++++++++++ esx_identity.sql | 10 ++--- esx_identity_update.sql | 11 ----- html/style.css | 58 +++++++++++++-------------- server.lua => server/main.lua | 55 ------------------------- 11 files changed, 103 insertions(+), 203 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .gitattributes rename license.txt => LICENSE (100%) delete mode 100644 client.lua create mode 100644 client/main.lua delete mode 100644 esx_identity_update.sql rename server.lua => server/main.lua (83%) diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 4bfca33b..00000000 --- a/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -indent_size = 2 -indent_style = space -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index eba1110b..00000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto \ No newline at end of file diff --git a/license.txt b/LICENSE similarity index 100% rename from license.txt rename to LICENSE diff --git a/README.md b/README.md index aa35bfa9..6bb0e8c7 100644 --- a/README.md +++ b/README.md @@ -17,18 +17,15 @@ This version is not compatible with ES5, use [esx_identity_es5](https://github.c 3) Add this in your server.cfg : -Notice: -`If you were already using the latest version of esx_identity before the update, you can just import esx_identity_update.sql` - ``` start esx_identity ``` + 4) If you are using esx_policejob or esx_society, you need to enable the following in the files config.lua: ```Config.EnableESXIdentity = true``` +### Commands ``` -Commands: - /identityhelp /register /charlist @@ -37,4 +34,4 @@ Commands: ``` ### License -This script is licensed under GPLv3, see the [license](license.txt) +This script is licensed under GPLv3, see the [license](LICENSE) diff --git a/__resource.lua b/__resource.lua index c8055612..6b6702e4 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,15 +1,24 @@ -version '1.0.2' +-- https://wiki.fivem.net/wiki/Resource_manifest -client_script('client.lua') +resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' -server_script "@mysql-async/lib/MySQL.lua" -server_script "server.lua" +description 'ESX Identity' -ui_page('html/index.html') +version '1.0.4' -files({ - 'html/index.html', - 'html/script.js', - 'html/style.css', - 'html/cursor.png', -}) +client_script 'client/main.lua' + +server_scripts { + "@mysql-async/lib/MySQL.lua", + "@es_extended/locale.lua", + "server/main.lua", +} + +ui_page 'html/index.html' + +files { + 'html/index.html', + 'html/script.js', + 'html/style.css', + 'html/cursor.png', +} diff --git a/client.lua b/client.lua deleted file mode 100644 index 985a001d..00000000 --- a/client.lua +++ /dev/null @@ -1,75 +0,0 @@ ---================================================================================== ---====== ESX_IDENTITY BY ARKSEYONET @Ark ====== ---====== YOU CAN FIND ME ON MY DISCORD @Ark - https://discord.gg/cGHHxPX ====== ---====== IF YOU ALTER THIS VERSION OF THE SCRIPT, PLEASE GIVE ME CREDIT ====== ---====== Special Thanks To Alphakush and CMD.Telhada For Help Testing ====== ---================================================================================== - ---=============================================== ---== VARIABLES == ---=============================================== -local guiEnabled = false -local myIdentity = {} - ---=============================================== ---== VARIABLES == ---=============================================== -function EnableGui(enable) - SetNuiFocus(enable) - guiEnabled = enable - - SendNUIMessage({ - type = "enableui", - enable = enable - }) -end - - ---=============================================== ---== Show Registration == ---=============================================== -RegisterNetEvent("esx_identity:showRegisterIdentity") -AddEventHandler("esx_identity:showRegisterIdentity", function() - EnableGui(true) -end) - ---=============================================== ---== Close GUI == ---=============================================== -RegisterNUICallback('escape', function(data, cb) - EnableGui(false) -end) - ---=============================================== ---== Register Callback == ---=============================================== -RegisterNUICallback('register', function(data, cb) - myIdentity = data - TriggerServerEvent('esx_identity:setIdentity', data) - EnableGui(false) - Wait (500) - TriggerEvent('esx_skin:openSaveableMenu') -end) - ---=============================================== ---== THREADING == ---=============================================== -Citizen.CreateThread(function() - while true do - if guiEnabled then - DisableControlAction(0, 1, guiEnabled) -- LookLeftRight - DisableControlAction(0, 2, guiEnabled) -- LookUpDown - - DisableControlAction(0, 142, guiEnabled) -- MeleeAttackAlternate - - DisableControlAction(0, 106, guiEnabled) -- VehicleMouseControlOverride - - if IsDisabledControlJustReleased(0, 142) then -- MeleeAttackAlternate - SendNUIMessage({ - type = "click" - }) - end - end - Citizen.Wait(0) - end -end) diff --git a/client/main.lua b/client/main.lua new file mode 100644 index 00000000..9d7ba252 --- /dev/null +++ b/client/main.lua @@ -0,0 +1,46 @@ +local guiEnabled = false +local myIdentity = {} + +function EnableGui(enable) + SetNuiFocus(enable) + guiEnabled = enable + + SendNUIMessage({ + type = "enableui", + enable = enable + }) +end + +RegisterNetEvent("esx_identity:showRegisterIdentity") +AddEventHandler("esx_identity:showRegisterIdentity", function() + EnableGui(true) +end) + +RegisterNUICallback('escape', function(data, cb) + EnableGui(false) +end) + +RegisterNUICallback('register', function(data, cb) + myIdentity = data + TriggerServerEvent('esx_identity:setIdentity', data) + EnableGui(false) + Citizen.Wait(500) + TriggerEvent('esx_skin:openSaveableMenu') +end) + +Citizen.CreateThread(function() + while true do + if guiEnabled then + DisableControlAction(0, 1, guiEnabled) -- LookLeftRight + DisableControlAction(0, 2, guiEnabled) -- LookUpDown + DisableControlAction(0, 142, guiEnabled) -- MeleeAttackAlternate + DisableControlAction(0, 106, guiEnabled) -- VehicleMouseControlOverride + if IsDisabledControlJustReleased(0, 142) then -- MeleeAttackAlternate + SendNUIMessage({ + type = "click" + }) + end + end + Citizen.Wait(10) + end +end) diff --git a/esx_identity.sql b/esx_identity.sql index 55dbfd88..dc5b1549 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -1,11 +1,11 @@ USE `essentialmode`; ALTER TABLE `users` - ADD COLUMN `firstname` VARCHAR(50) NULL DEFAULT '', - ADD COLUMN `lastname` VARCHAR(50) NULL DEFAULT '', - ADD COLUMN `dateofbirth` VARCHAR(25) NULL DEFAULT '', - ADD COLUMN `sex` VARCHAR(10) NULL DEFAULT '', - ADD COLUMN `height` VARCHAR(5) NULL DEFAULT '' + ADD COLUMN `firstname` VARCHAR(50) NULL DEFAULT '', + ADD COLUMN `lastname` VARCHAR(50) NULL DEFAULT '', + ADD COLUMN `dateofbirth` VARCHAR(25) NULL DEFAULT '', + ADD COLUMN `sex` VARCHAR(10) NULL DEFAULT '', + ADD COLUMN `height` VARCHAR(5) NULL DEFAULT '' ; CREATE TABLE `characters` ( diff --git a/esx_identity_update.sql b/esx_identity_update.sql deleted file mode 100644 index 14a05ed4..00000000 --- a/esx_identity_update.sql +++ /dev/null @@ -1,11 +0,0 @@ -USE `essentialmode`; - -CREATE TABLE `characters` ( - - `identifier` varchar(255) NOT NULL, - `firstname` varchar(255) NOT NULL, - `lastname` varchar(255) NOT NULL, - `dateofbirth` varchar(255) NOT NULL, - `sex` varchar(1) NOT NULL DEFAULT 'f', - `height` varchar(128) NOT NULL -); diff --git a/html/style.css b/html/style.css index e9e8069b..cee5c6c9 100644 --- a/html/style.css +++ b/html/style.css @@ -1,52 +1,52 @@ body { - font-family: sans-serif; - overflow: hidden; - display: none; + font-family: sans-serif; + overflow: hidden; + display: none; } #cursor { - position: absolute; - z-index: 999999; - display: none; + position: absolute; + z-index: 999999; + display: none; } .dialog { - width: 300px; - position: absolute; - left: 50%; - transform: translateX(-50%); - padding: 10px; - background-color: rgba(0, 0, 0, 0.5); + width: 300px; + position: absolute; + left: 50%; + transform: translateX(-50%); + padding: 10px; + background-color: rgba(0, 0, 0, 0.5); } form { - margin: 0; + margin: 0; } input[type=text] { - width: 100%; - padding: 10px; + width: 100%; + padding: 10px; text-align: center; } button { - display: block; - margin-top: 5px; - padding: 10px; - background-color: Blue; - border: 0; - color: #fff; - width: 100%; + display: block; + margin-top: 5px; + padding: 10px; + background-color: Blue; + border: 0; + color: #fff; + width: 100%; } h1 { - display: block; - margin-top: 5px; + display: block; + margin-top: 5px; margin-right: 5px; - padding: 10px; - background-color: Blue; - border: 0; - color: #fff; - width: 93%; + padding: 10px; + background-color: Blue; + border: 0; + color: #fff; + width: 93%; text-align: center; } diff --git a/server.lua b/server/main.lua similarity index 83% rename from server.lua rename to server/main.lua index b09c840a..de143b35 100644 --- a/server.lua +++ b/server/main.lua @@ -1,18 +1,3 @@ ---================================================================================== ---====== ESX_IDENTITY BY ARKSEYONET @Ark ====== ---====== YOU CAN FIND ME ON MY DISCORD @Ark - https://discord.gg/cGHHxPX ====== ---====== IF YOU ALTER THIS VERSION OF THE SCRIPT, PLEASE GIVE ME CREDIT ====== ---====== Special Thanks To COSHAREK FOR THE UI Design ====== ---====== Special Thanks To Alphakush and CMD.Telhada For Help Testing ====== ---================================================================================== - ---=================================================================== ---== MAIN FUNCTIONS == ---=================================================================== - ---=============================================== ---== Get The Player's Identification == ---=============================================== function getIdentity(source, callback) local identifier = GetPlayerIdentifiers(source)[1] MySQL.Async.fetchAll("SELECT * FROM `users` WHERE `identifier` = @identifier", @@ -46,9 +31,6 @@ function getIdentity(source, callback) end) end ---=============================================== ---== Get The Player's Identification == ---=============================================== function getCharacters(source, callback) local identifier = GetPlayerIdentifiers(source)[1] MySQL.Async.fetchAll("SELECT * FROM `characters` WHERE `identifier` = @identifier", @@ -144,9 +126,6 @@ function getCharacters(source, callback) end) end ---=============================================== ---== Set The Player's Identification == ---=============================================== function setIdentity(identifier, data, callback) MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", { @@ -175,9 +154,6 @@ function setIdentity(identifier, data, callback) }) end ---=============================================== ---== Update The Player's Identification == ---=============================================== function updateIdentity(identifier, data, callback) MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", { @@ -195,9 +171,6 @@ function updateIdentity(identifier, data, callback) end) end ---=============================================== ---== Delete The Player's Identification == ---=============================================== function deleteIdentity(identifier, data, callback) MySQL.Async.execute("DELETE FROM `characters` WHERE identifier = @identifier AND firstname = @firstname AND lastname = @lastname AND dateofbirth = @dateofbirth AND sex = @sex AND height = @height", { @@ -215,9 +188,6 @@ function deleteIdentity(identifier, data, callback) end) end ---=============================================== ---== Server Event Set Identity == ---=============================================== RegisterServerEvent('esx_identity:setIdentity') AddEventHandler('esx_identity:setIdentity', function(data) local identifier = GetPlayerIdentifiers(source)[1] @@ -230,9 +200,6 @@ AddEventHandler('esx_identity:setIdentity', function(data) end) end) ---=============================================== ---== Player Loaded Event Handler == ---=============================================== AddEventHandler('es:playerLoaded', function(source) getIdentity(source, function(data) if data.firstname == '' then @@ -243,13 +210,6 @@ AddEventHandler('es:playerLoaded', function(source) end) end) ---=================================================================== ---== MAIN COMMANDS == ---=================================================================== - ---=============================================== ---== /charlist - Show Your Characters == ---=============================================== TriggerEvent('es:addGroupCommand', 'idhelp', "user", function(source, args, user) TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "ESX_IDENTITY Commands") TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/register - Register A New Character") @@ -261,9 +221,6 @@ end, function(source, args, user) end, {help = "List Your Characters"}) ---=============================================== ---== /register - Open Registration == ---=============================================== TriggerEvent('es:addCommand', 'register', function(source, args, user) getCharacters(source, function(data) if data.firstname3 ~= '' then @@ -274,9 +231,6 @@ TriggerEvent('es:addCommand', 'register', function(source, args, user) end) end) ---=============================================== ---== /char - Show Active Character == ---=============================================== TriggerEvent('es:addGroupCommand', 'char', "user", function(source, args, user) getIdentity(source, function(data) if data.firstname == '' then @@ -289,9 +243,6 @@ end, function(source, args, user) TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") end, {help = "List Your Current Active Character"}) ---=============================================== ---== /charlist - Show Your Characters == ---=============================================== TriggerEvent('es:addGroupCommand', 'charlist', "user", function(source, args, user) getCharacters(source, function(data) if data.firstname1 ~= '' then @@ -310,9 +261,6 @@ end, function(source, args, user) TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") end, {help = "List Your Characters"}) ---=============================================== ---== /charselect 1,2,3 Select Your Active Char == ---=============================================== TriggerEvent('es:addCommand', 'charselect', function(source, args, user) table.remove(args, 1) local charNumber = tonumber(table.concat(args, " ")) @@ -387,9 +335,6 @@ TriggerEvent('es:addCommand', 'charselect', function(source, args, user) end) end) ---=============================================== ---== /charselect 1,2,3 Select Your Active Char == ---=============================================== TriggerEvent('es:addCommand', 'delchar', function(source, args, user) table.remove(args, 1) local charNumber = tonumber(table.concat(args, " ")) From 20e0cabe87c7f2efb6f04fbf5bf5287dea20bbb4 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 15 Apr 2018 14:37:30 +0200 Subject: [PATCH 28/78] Initial background styling --- html/index.html | 4 ++++ html/style.css | 26 +++++++++++--------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/html/index.html b/html/index.html index 555b930b..aab43b52 100644 --- a/html/index.html +++ b/html/index.html @@ -19,4 +19,8 @@ + +
+ + diff --git a/html/style.css b/html/style.css index cee5c6c9..84890b15 100644 --- a/html/style.css +++ b/html/style.css @@ -1,9 +1,3 @@ -body { - font-family: sans-serif; - overflow: hidden; - display: none; -} - #cursor { position: absolute; z-index: 999999; @@ -13,10 +7,13 @@ body { .dialog { width: 300px; position: absolute; - left: 50%; - transform: translateX(-50%); + margin-left: auto; + margin-right: auto; + left: 0; + right: 0; padding: 10px; - background-color: rgba(0, 0, 0, 0.5); + box-shadow: 0px 0px 50px 0px #000; + overflow: hidden; } form { @@ -24,8 +21,8 @@ form { } input[type=text] { - width: 100%; - padding: 10px; + width: 93%; + padding: 7px; text-align: center; } @@ -33,7 +30,7 @@ button { display: block; margin-top: 5px; padding: 10px; - background-color: Blue; + background-color: #506be6; border: 0; color: #fff; width: 100%; @@ -44,9 +41,8 @@ h1 { margin-top: 5px; margin-right: 5px; padding: 10px; - background-color: Blue; - border: 0; + background-color: #506be6; color: #fff; width: 93%; text-align: center; -} +} \ No newline at end of file From 76e26374197ba1098d9ca6a425c62e44acf61540 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 15 Apr 2018 14:37:47 +0200 Subject: [PATCH 29/78] Initial styling --- html/index.html | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/html/index.html b/html/index.html index aab43b52..827ec7f5 100644 --- a/html/index.html +++ b/html/index.html @@ -1,24 +1,23 @@ + - - - - - - -
-
-

Registration

-
-
-
-
-
- - -
- - - + + + + + + + + +
+ +

Register

+
+
+
+
+ Male + Female
+
From e5f69f33625c15e6feafb2a52852ee17e9fea077 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 15 Apr 2018 18:42:08 +0200 Subject: [PATCH 30/78] Improved form handling with verifying data --- __resource.lua | 4 +-- client/main.lua | 91 ++++++++++++++++++++++++++++++++++++++++++++++--- html/index.html | 10 +++--- html/script.js | 74 ++++++++++++++++++++++------------------ html/style.css | 15 +++++--- server/main.lua | 13 +++---- 6 files changed, 150 insertions(+), 57 deletions(-) diff --git a/__resource.lua b/__resource.lua index 6b6702e4..86cfa1da 100644 --- a/__resource.lua +++ b/__resource.lua @@ -11,7 +11,7 @@ client_script 'client/main.lua' server_scripts { "@mysql-async/lib/MySQL.lua", "@es_extended/locale.lua", - "server/main.lua", + "server/main.lua" } ui_page 'html/index.html' @@ -20,5 +20,5 @@ files { 'html/index.html', 'html/script.js', 'html/style.css', - 'html/cursor.png', + 'html/cursor.png' } diff --git a/client/main.lua b/client/main.lua index 9d7ba252..2496868f 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,5 +1,13 @@ local guiEnabled = false local myIdentity = {} +ESX = nil + +Citizen.CreateThread(function() + while ESX == nil do + TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + Citizen.Wait(0) + end +end) function EnableGui(enable) SetNuiFocus(enable) @@ -21,11 +29,42 @@ RegisterNUICallback('escape', function(data, cb) end) RegisterNUICallback('register', function(data, cb) + local reason = "" myIdentity = data - TriggerServerEvent('esx_identity:setIdentity', data) - EnableGui(false) - Citizen.Wait(500) - TriggerEvent('esx_skin:openSaveableMenu') + for theData, value in pairs(myIdentity) do + if theData == "firstname" or theData == "lastname" then + reason = verifyName(value) + + if reason ~= "" then + break + end + elseif theData == "dateofbirth" then + if value == "invalid" then + reason = "Invalid date of birth!" + break + end + elseif theData == "height" then + local height = tonumber(value) + if height then + if height > 200 or height < 140 then + reason = "Unacceptable player height!" + break + end + else + reason = "Unacceptable player height!" + break + end + end + end + + if reason == "" then + --TriggerServerEvent('esx_identity:setIdentity', data) + EnableGui(false) + Citizen.Wait(500) + --TriggerEvent('esx_skin:openSaveableMenu') + else + ESX.ShowNotification(reason) + end end) Citizen.CreateThread(function() @@ -44,3 +83,47 @@ Citizen.CreateThread(function() Citizen.Wait(10) end end) + +function verifyName(name) + -- Don't allow short user names + local nameLength = string.len(name) + if nameLength > 25 or nameLength < 5 then + return 'Your player name is either too short or too long.' + end + + -- Don't allow special characters (doesn't always work) + local count = 0 + for i in name:gmatch('[abcdefghijklmnopqrstuvwxyzåäöABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ0123456789 -]') do + count = count + 1 + end + if count ~= nameLength then + return 'Your player name contains special characters that are not allowed on this server.' + end + + -- Does the player carry a first and last name? + -- + -- Example: + -- Allowed: 'Bob Joe' + -- Not allowed: 'Bob' + -- Not allowed: 'Bob joe' + local spacesInName = 0 + local spacesWithUpper = 0 + for word in string.gmatch(name, '%S+') do + + if string.match(word, '%u') then + spacesWithUpper = spacesWithUpper + 1 + end + + spacesInName = spacesInName + 1 + end + + if spacesInName > 2 then + return 'Your name contains more than two spaces' + end + + if spacesWithUpper ~= spacesInName then + return 'your name must start with a capital letter.' + end + + return '' +end diff --git a/html/index.html b/html/index.html index 827ec7f5..1ccd4730 100644 --- a/html/index.html +++ b/html/index.html @@ -1,8 +1,6 @@ - - - + @@ -14,9 +12,9 @@


-
- Male - Female
+
+ Male + Female
diff --git a/html/script.js b/html/script.js index a34ab658..0359d753 100644 --- a/html/script.js +++ b/html/script.js @@ -6,47 +6,53 @@ var cursorX = documentWidth / 2; var cursorY = documentHeight / 2; function UpdateCursorPos() { - cursor.style.left = cursorX; - cursor.style.top = cursorY; + cursor.style.left = cursorX; + cursor.style.top = cursorY; } function Click(x, y) { - var element = $(document.elementFromPoint(x, y)); - element.focus().click(); + var element = $(document.elementFromPoint(x, y)); + element.focus().click(); } $(function() { - window.addEventListener('message', function(event) { - if (event.data.type == "enableui") { - cursor.style.display = event.data.enable ? "block" : "none"; - document.body.style.display = event.data.enable ? "block" : "none"; - } else if (event.data.type == "click") { - // Avoid clicking the cursor itself, click 1px to the top/left; - Click(cursorX - 1, cursorY - 1); - } - }); + window.addEventListener('message', function(event) { + if (event.data.type == "enableui") { + cursor.style.display = event.data.enable ? "block" : "none"; + document.body.style.display = event.data.enable ? "block" : "none"; + } else if (event.data.type == "click") { + // Avoid clicking the cursor itself, click 1px to the top/left; + Click(cursorX - 1, cursorY - 1); + } + }); - $(document).mousemove(function(event) { - cursorX = event.pageX; - cursorY = event.pageY; - UpdateCursorPos(); - }); + $(document).mousemove(function(event) { + cursorX = event.pageX; + cursorY = event.pageY; + UpdateCursorPos(); + }); - document.onkeyup = function (data) { - if (data.which == 27) { // Escape key - $.post('http://esx_identity/escape', JSON.stringify({})); - } - }; + document.onkeyup = function (data) { + if (data.which == 27) { // Escape key + $.post('http://esx_identity/escape', JSON.stringify({})); + } + }; - $("#register").submit(function(e) { - e.preventDefault(); // Prevent form from submitting - - $.post('http://esx_identity/register', JSON.stringify({ - firstname: $("#firstname").val(), - lastname: $("#lastname").val(), - dateofbirth: $("#dateofbirth").val(), - sex: $("#sex").val(), - height: $("#height").val() - })); - }); + $("#register").submit(function(e) { + e.preventDefault(); // Prevent form from submitting + + // Verify date + var date = $("#dateofbirth").val(); + var dateCheck = new Date($("#dateofbirth").val()); + if (dateCheck == "Invalid Date") { + date == "invalid"; + } + $.post('http://esx_identity/register', JSON.stringify({ + firstname: $("#firstname").val(), + lastname: $("#lastname").val(), + dateofbirth: date, + sex: $("input[type='radio'][name='sex']:checked").val(), + height: $("#height").val() + })); + }); }); diff --git a/html/style.css b/html/style.css index 84890b15..b2efe3db 100644 --- a/html/style.css +++ b/html/style.css @@ -4,6 +4,13 @@ display: none; } +/* Required */ +body { + font-family: sans-serif; + overflow: hidden; + display: none; +} + .dialog { width: 300px; position: absolute; @@ -13,15 +20,13 @@ right: 0; padding: 10px; box-shadow: 0px 0px 50px 0px #000; + background-color: #f1f1f1; overflow: hidden; -} - -form { - margin: 0; + opacity: 0.9; } input[type=text] { - width: 93%; + width: 100%; padding: 7px; text-align: center; } diff --git a/server/main.lua b/server/main.lua index de143b35..f403fa8c 100644 --- a/server/main.lua +++ b/server/main.lua @@ -133,7 +133,7 @@ function setIdentity(identifier, data, callback) ['@firstname'] = data.firstname, ['@lastname'] = data.lastname, ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, + ['@sex'] = data.sex, ['@height'] = data.height }, function(done) @@ -203,6 +203,7 @@ end) AddEventHandler('es:playerLoaded', function(source) getIdentity(source, function(data) if data.firstname == '' then + print('do not register!') TriggerClientEvent('esx_identity:showRegisterIdentity', source) else print('Successfully Loaded Identity For ' .. data.firstname .. ' ' .. data.lastname) @@ -220,16 +221,16 @@ end, function(source, args, user) TriggerClientEvent('chatMessage', source, "IDHelp", {255, 0, 0}, "Insufficienct permissions!") end, {help = "List Your Characters"}) - TriggerEvent('es:addCommand', 'register', function(source, args, user) + getCharacters(source, function(data) if data.firstname3 ~= '' then TriggerClientEvent('chatMessage', source, 'REGISTER', {255, 0, 0}, "You Can Only Have 3 Characters.") else - TriggerClientEvent('esx_identity:showRegisterIdentity', source, {}) + TriggerClientEvent('esx_identity:showRegisterIdentity', source) end end) -end) +end, {help = "Register a new character"}) TriggerEvent('es:addGroupCommand', 'char', "user", function(source, args, user) getIdentity(source, function(data) @@ -241,7 +242,7 @@ TriggerEvent('es:addGroupCommand', 'char', "user", function(source, args, user) end) end, function(source, args, user) TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") -end, {help = "List Your Current Active Character"}) +end, {help = "List your current character"}) TriggerEvent('es:addGroupCommand', 'charlist', "user", function(source, args, user) getCharacters(source, function(data) @@ -403,4 +404,4 @@ TriggerEvent('es:addCommand', 'delchar', function(source, args, user) TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") end end) -end) +end, {help = "Delete your character"}) From 853a00bf8e79f85c5380665ab5ffdd8c2ab371b5 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Wed, 18 Apr 2018 22:47:46 +0200 Subject: [PATCH 31/78] Finally implemented ES5 support Co-Authored-By: arkseyonet --- README.md | 4 +- client/main.lua | 46 +++++- esx_identity.sql | 1 - server/main.lua | 411 +++++++++++++++++++++++++---------------------- 4 files changed, 258 insertions(+), 204 deletions(-) diff --git a/README.md b/README.md index 6bb0e8c7..a4b25cd3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,9 @@ # esx_identity -### Important message -This version is not compatible with ES5, use [esx_identity_es5](https://github.com/ArkSeyonet/esx_identity_es5) - [REQUIREMENTS] * Dependencies For Full Functionality + * [esx_skin](https://github.com/ESX-Org/esx_skin) * [esx_policejob](https://github.com/ESX-Org/esx_policejob) * [esx_society](https://github.com/ESX-Org/esx_society) diff --git a/client/main.lua b/client/main.lua index 2496868f..ff8d03d5 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,5 +1,7 @@ local guiEnabled = false local myIdentity = {} +local myIdentifiers = {} +local hasIdentity = false ESX = nil Citizen.CreateThread(function() @@ -24,8 +26,22 @@ AddEventHandler("esx_identity:showRegisterIdentity", function() EnableGui(true) end) +RegisterNetEvent("esx_identity:identityCheck") +AddEventHandler("esx_identity:identityCheck", function(identityCheck) + hasIdentity = identityCheck +end) + +RegisterNetEvent("esx_identity:saveID") +AddEventHandler("esx_identity:saveID", function(data) + myIdentifiers = data +end) + RegisterNUICallback('escape', function(data, cb) - EnableGui(false) + if hasIdentity == true then + EnableGui(false) + else + TriggerEvent("chatMessage", "^1[IDENTITY]", {255, 255, 0}, "You must create your first identity in order to play.") + end end) RegisterNUICallback('register', function(data, cb) @@ -58,10 +74,10 @@ RegisterNUICallback('register', function(data, cb) end if reason == "" then - --TriggerServerEvent('esx_identity:setIdentity', data) + TriggerServerEvent('esx_identity:setIdentity', data, myIdentifiers) EnableGui(false) Citizen.Wait(500) - --TriggerEvent('esx_skin:openSaveableMenu') + TriggerEvent('esx_skin:openSaveableMenu', myIdentifiers.id) else ESX.ShowNotification(reason) end @@ -70,10 +86,26 @@ end) Citizen.CreateThread(function() while true do if guiEnabled then - DisableControlAction(0, 1, guiEnabled) -- LookLeftRight - DisableControlAction(0, 2, guiEnabled) -- LookUpDown - DisableControlAction(0, 142, guiEnabled) -- MeleeAttackAlternate - DisableControlAction(0, 106, guiEnabled) -- VehicleMouseControlOverride + DisableControlAction(0, 1, guiEnabled) -- LookLeftRight + DisableControlAction(0, 2, guiEnabled) -- LookUpDown + DisableControlAction(0, 106, guiEnabled) -- VehicleMouseControlOverride + DisableControlAction(0, 142, true) -- MeleeAttackAlternate + DisableControlAction(0, 30, true) -- MoveLeftRight + DisableControlAction(0, 31, true) -- MoveUpDown + DisableControlAction(0, 21, true) -- disable sprint + DisableControlAction(0, 24, true) -- disable attack + DisableControlAction(0, 25, true) -- disable aim + DisableControlAction(0, 47, true) -- disable weapon + DisableControlAction(0, 58, true) -- disable weapon + DisableControlAction(0, 263, true) -- disable melee + DisableControlAction(0, 264, true) -- disable melee + DisableControlAction(0, 257, true) -- disable melee + DisableControlAction(0, 140, true) -- disable melee + DisableControlAction(0, 141, true) -- disable melee + DisableControlAction(0, 143, true) -- disable melee + DisableControlAction(0, 75, true) -- disable exit vehicle + DisableControlAction(27, 75, true) -- disable exit vehicle + if IsDisabledControlJustReleased(0, 142) then -- MeleeAttackAlternate SendNUIMessage({ type = "click" diff --git a/esx_identity.sql b/esx_identity.sql index dc5b1549..73220965 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -9,7 +9,6 @@ ALTER TABLE `users` ; CREATE TABLE `characters` ( - `identifier` varchar(255) NOT NULL, `firstname` varchar(255) NOT NULL, `lastname` varchar(255) NOT NULL, diff --git a/server/main.lua b/server/main.lua index f403fa8c..3ebb78ea 100644 --- a/server/main.lua +++ b/server/main.lua @@ -189,219 +189,244 @@ function deleteIdentity(identifier, data, callback) end RegisterServerEvent('esx_identity:setIdentity') -AddEventHandler('esx_identity:setIdentity', function(data) - local identifier = GetPlayerIdentifiers(source)[1] - setIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - print('Successfully Set Identity For ' .. identifier) - else - print('Failed To Set Identity.') - end - end) +AddEventHandler('esx_identity:setIdentity', function(data, myIdentifiers) + setIdentity(myIdentifiers.steamid, data, function(callback) + if callback then + TriggerClientEvent('esx_identity:identityCheck', myIdentifiers.playerid, true) + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Set Identity!") + end + end) end) + AddEventHandler('es:playerLoaded', function(source) - getIdentity(source, function(data) - if data.firstname == '' then - print('do not register!') - TriggerClientEvent('esx_identity:showRegisterIdentity', source) - else - print('Successfully Loaded Identity For ' .. data.firstname .. ' ' .. data.lastname) - end - end) + local myID = { + steamid = GetPlayerIdentifiers(source)[1], + playerid = source + } + + TriggerClientEvent('esx_identity:saveID', source, myID) + getIdentity(source, function(data) + if data.firstname == '' then + TriggerClientEvent('esx_identity:identityCheck', source, false) + TriggerClientEvent('esx_identity:showRegisterIdentity', source) + else + TriggerClientEvent('esx_identity:identityCheck', source, true) + end + end) end) TriggerEvent('es:addGroupCommand', 'idhelp', "user", function(source, args, user) - TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "ESX_IDENTITY Commands") - TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/register - Register A New Character") - TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/charlist - List Your Characters") - TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/charselect 1,2,3 - Change Your Active Character") - TriggerClientEvent('chatMessage', source, 'IDHelp', {255, 0, 0}, "/delchar 1,2,3 - Delete A Character") + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "Commands List") + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "/register - Register A New Character") + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "/charlist - List Your Characters") + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "/charselect 1,2,3 - Change Your Active Character") + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "/delchar 1,2,3 - Delete A Character") end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "IDHelp", {255, 0, 0}, "Insufficienct permissions!") -end, {help = "List Your Characters"}) + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") +end, {help = "List all the identity-related commands"}) TriggerEvent('es:addCommand', 'register', function(source, args, user) - - getCharacters(source, function(data) - if data.firstname3 ~= '' then - TriggerClientEvent('chatMessage', source, 'REGISTER', {255, 0, 0}, "You Can Only Have 3 Characters.") - else - TriggerClientEvent('esx_identity:showRegisterIdentity', source) - end - end) + getCharacters(source, function(data) + if data.firstname3 ~= '' then + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You Can Only Have 3 Characters.") + else + TriggerClientEvent('esx_identity:showRegisterIdentity', source, {}) + end + end) end, {help = "Register a new character"}) TriggerEvent('es:addGroupCommand', 'char', "user", function(source, args, user) - getIdentity(source, function(data) - if data.firstname == '' then - TriggerClientEvent('chatMessage', source, 'CHAR', {255, 0, 0}, "You Have No Active Character.") - else - TriggerClientEvent('chatMessage', source, 'CHAR', {255, 0, 0}, "Active Character: " .. data.firstname .. " " .. data.lastname) - end - end) + getIdentity(source, function(data) + if data.firstname == '' then + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You Have No Active Character.") + else + TriggerClientEvent('chatMessage', source, '[IDENTITY] Active Character:', {255, 0, 0}, data.firstname .. " " .. data.lastname) + end + end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") -end, {help = "List your current character"}) + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") +end, {help = "List Your Current Active Character"}) TriggerEvent('es:addGroupCommand', 'charlist', "user", function(source, args, user) - getCharacters(source, function(data) - if data.firstname1 ~= '' then - TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 1: " .. data.firstname1 .. " " .. data.lastname1) - if data.firstname2 ~= '' then - TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 2: " .. data.firstname2 .. " " .. data.lastname2) - if data.firstname3 ~= '' then - TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "Character 3: " .. data.firstname3 .. " " .. data.lastname3) - end - end - else - TriggerClientEvent('chatMessage', source, 'CHARLIST', {255, 0, 0}, "You Have No Characters. Please use the /register command.") - end - end) + getCharacters(source, function(data) + if data.firstname1 ~= '' then + TriggerClientEvent('chatMessage', source, '[IDENTITY] Character 1:', {255, 0, 0}, data.firstname1 .. " " .. data.lastname1) + + if data.firstname2 ~= '' then + TriggerClientEvent('chatMessage', source, '[IDENTITY] Character 2:', {255, 0, 0}, data.firstname2 .. " " .. data.lastname2) + + if dada.firstname3 ~= '' then + TriggerClientEvent('chatMessage', source, '[IDENTITY] Character 3:', {255, 0, 0}, data.firstname3 .. " " .. data.lastname3) + end + end + else + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You Have No Characters. Please use the /register command.") + end + end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") end, {help = "List Your Characters"}) -TriggerEvent('es:addCommand', 'charselect', function(source, args, user) - table.remove(args, 1) - local charNumber = tonumber(table.concat(args, " ")) - getCharacters(source, function(data) - if charNumber == 1 then - local data = { - identifier = data.identifier, - firstname = data.firstname1, - lastname = data.lastname1, - dateofbirth = data.dateofbirth1, - sex = data.sex1, - height = data.height1 - } +TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, user) + local charNumber = tonumber(args[1]) + + getCharacters(source, function(data) + if charNumber == 1 then + local data = { + identifier = data.identifier, + firstname = data.firstname1, + lastname = data.lastname1, + dateofbirth = data.dateofbirth1, + sex = data.sex1, + height = data.height1 + } - if data.firstname ~= '' then - updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 1!") - end - elseif charNumber == 2 then - local data = { - identifier = data.identifier, - firstname = data.firstname2, - lastname = data.lastname2, - dateofbirth = data.dateofbirth2, - sex = data.sex2, - height = data.height2 - } + if data.firstname ~= '' then + updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback then + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Update Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 1!") + end + elseif charNumber == 2 then + + local data = { + identifier = data.identifier, + firstname = data.firstname2, + lastname = data.lastname2, + dateofbirth = data.dateofbirth2, + sex = data.sex2, + height = data.height2 + } - if data.firstname ~= '' then - updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if data.firstname ~= '' then + updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 2!") - end - elseif charNumber == 3 then - local data = { - identifier = data.identifier, - firstname = data.firstname3, - lastname = data.lastname3, - dateofbirth = data.dateofbirth3, - sex = data.sex3, - height = data.height3 - } + if callback then + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Update Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 2!") + end + elseif charNumber == 3 then + + local data = { + identifier = data.identifier, + firstname = data.firstname3, + lastname = data.lastname3, + dateofbirth = data.dateofbirth3, + sex = data.sex3, + height = data.height3 + } - if data.firstname ~= '' then - updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "You don\'t have a character in slot 3!") - end - else - TriggerClientEvent('chatMessage', source, "CHARSELECT", {255, 0, 0}, "Failed To Update Identity!") - end - end) -end) + if data.firstname ~= '' then + updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback then + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Update Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 3!") + end + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Update Identity!") + end -TriggerEvent('es:addCommand', 'delchar', function(source, args, user) - table.remove(args, 1) - local charNumber = tonumber(table.concat(args, " ")) - getCharacters(source, function(data) - if charNumber == 1 then - local data = { - identifier = data.identifier, - firstname = data.firstname1, - lastname = data.lastname1, - dateofbirth = data.dateofbirth1, - sex = data.sex1, - height = data.height1 - } - if data.firstname ~= '' then - deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 1!") - end - elseif charNumber == 2 then - local data = { - identifier = data.identifier, - firstname = data.firstname2, - lastname = data.lastname2, - dateofbirth = data.dateofbirth2, - sex = data.sex2, - height = data.height2 - } - if data.firstname ~= '' then - deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 2!") - end - elseif charNumber == 3 then - local data = { - identifier = data.identifier, - firstname = data.firstname3, - lastname = data.lastname3, - dateofbirth = data.dateofbirth3, - sex = data.sex3, - height = data.height3 - } - if data.firstname ~= '' then - deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback == true then - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") - end - end) - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "You don\'t have a character in slot 3!") - end - else - TriggerClientEvent('chatMessage', source, "DELCHAR", {255, 0, 0}, "Failed To Delete Identity!") - end - end) -end, {help = "Delete your character"}) + end) +end, function(source, args, user) + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") +end, {help = "/charselect 1,2,3"}) + +TriggerEvent('es:addGroupCommand', 'delchar', "user", function(source, args, user) + + local charNumber = tonumber(args[1]) + + getCharacters(source, function(data) + + if charNumber == 1 then + + local data = { + identifier = data.identifier, + firstname = data.firstname1, + lastname = data.lastname1, + dateofbirth = data.dateofbirth1, + sex = data.sex1, + height = data.height1 + } + + if data.firstname ~= '' then + deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback then + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Delete Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 1!") + end + + elseif charNumber == 2 then + + local data = { + identifier = data.identifier, + firstname = data.firstname2, + lastname = data.lastname2, + dateofbirth = data.dateofbirth2, + sex = data.sex2, + height = data.height2 + } + + if data.firstname ~= '' then + deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback then + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Delete Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 2!") + end + + elseif charNumber == 3 then + + local data = { + identifier = data.identifier, + firstname = data.firstname3, + lastname = data.lastname3, + dateofbirth = data.dateofbirth3, + sex = data.sex3, + height = data.height3 + } + + if data.firstname ~= '' then + + deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + if callback then + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Delete Identity!") + end + end) + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 3!") + end + else + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Delete Identity!") + end + end) +end, function(source, args, user) + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") +end, {help = "/delchar 1,2,3"}) \ No newline at end of file From 21ee72ce9fcc1900852ea2aab50747352dcf7ded Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Thu, 19 Apr 2018 18:02:14 +0200 Subject: [PATCH 32/78] Cleanup, improved chat suggestions --- client/main.lua | 6 +- server/main.lua | 466 +++++++++++++++++++++++------------------------- 2 files changed, 228 insertions(+), 244 deletions(-) diff --git a/client/main.lua b/client/main.lua index ff8d03d5..1c0b10c3 100644 --- a/client/main.lua +++ b/client/main.lua @@ -86,9 +86,9 @@ end) Citizen.CreateThread(function() while true do if guiEnabled then - DisableControlAction(0, 1, guiEnabled) -- LookLeftRight - DisableControlAction(0, 2, guiEnabled) -- LookUpDown - DisableControlAction(0, 106, guiEnabled) -- VehicleMouseControlOverride + DisableControlAction(0, 1, true) -- LookLeftRight + DisableControlAction(0, 2, true) -- LookUpDown + DisableControlAction(0, 106, true) -- VehicleMouseControlOverride DisableControlAction(0, 142, true) -- MeleeAttackAlternate DisableControlAction(0, 30, true) -- MoveLeftRight DisableControlAction(0, 31, true) -- MoveUpDown diff --git a/server/main.lua b/server/main.lua index 3ebb78ea..946c83ff 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,191 +1,186 @@ function getIdentity(source, callback) - local identifier = GetPlayerIdentifiers(source)[1] - MySQL.Async.fetchAll("SELECT * FROM `users` WHERE `identifier` = @identifier", - { - ['@identifier'] = identifier - }, - function(result) - if result[1]['firstname'] ~= nil then - local data = { - identifier = result[1]['identifier'], - firstname = result[1]['firstname'], - lastname = result[1]['lastname'], - dateofbirth = result[1]['dateofbirth'], - sex = result[1]['sex'], - height = result[1]['height'] - } - - callback(data) - else - local data = { - identifier = '', - firstname = '', - lastname = '', - dateofbirth = '', - sex = '', - height = '' - } - - callback(data) - end - end) + local identifier = GetPlayerIdentifiers(source)[1] + + MySQL.Async.fetchAll("SELECT * FROM `users` WHERE `identifier` = @identifier", + { + ['@identifier'] = identifier + }, function(result) + if result[1]['firstname'] ~= nil then + local data = { + identifier = result[1]['identifier'], + firstname = result[1]['firstname'], + lastname = result[1]['lastname'], + dateofbirth = result[1]['dateofbirth'], + sex = result[1]['sex'], + height = result[1]['height'] + } + callback(data) + else + local data = { + identifier = '', + firstname = '', + lastname = '', + dateofbirth = '', + sex = '', + height = '' + } + + callback(data) + end + end) end function getCharacters(source, callback) - local identifier = GetPlayerIdentifiers(source)[1] - MySQL.Async.fetchAll("SELECT * FROM `characters` WHERE `identifier` = @identifier", - { - ['@identifier'] = identifier - }, - function(result) - if result[1] and result[2] and result[3] then - local data = { - identifier = result[1]['identifier'], - firstname1 = result[1]['firstname'], - lastname1 = result[1]['lastname'], - dateofbirth1 = result[1]['dateofbirth'], - sex1 = result[1]['sex'], - height1 = result[1]['height'], - firstname2 = result[2]['firstname'], - lastname2 = result[2]['lastname'], - dateofbirth2 = result[2]['dateofbirth'], - sex2 = result[2]['sex'], - height2 = result[2]['height'], - firstname3 = result[3]['firstname'], - lastname3 = result[3]['lastname'], - dateofbirth3 = result[3]['dateofbirth'], - sex3 = result[3]['sex'], - height3 = result[3]['height'] - } + local identifier = GetPlayerIdentifiers(source)[1] + MySQL.Async.fetchAll("SELECT * FROM `characters` WHERE `identifier` = @identifier", + { + ['@identifier'] = identifier + }, function(result) + if result[1] and result[2] and result[3] then + local data = { + identifier = result[1]['identifier'], + firstname1 = result[1]['firstname'], + lastname1 = result[1]['lastname'], + dateofbirth1 = result[1]['dateofbirth'], + sex1 = result[1]['sex'], + height1 = result[1]['height'], + firstname2 = result[2]['firstname'], + lastname2 = result[2]['lastname'], + dateofbirth2 = result[2]['dateofbirth'], + sex2 = result[2]['sex'], + height2 = result[2]['height'], + firstname3 = result[3]['firstname'], + lastname3 = result[3]['lastname'], + dateofbirth3 = result[3]['dateofbirth'], + sex3 = result[3]['sex'], + height3 = result[3]['height'] + } + + callback(data) + elseif result[1] and result[2] and not result[3] then + local data = { + identifier = result[1]['identifier'], + firstname1 = result[1]['firstname'], + lastname1 = result[1]['lastname'], + dateofbirth1 = result[1]['dateofbirth'], + sex1 = result[1]['sex'], + height1 = result[1]['height'], + firstname2 = result[2]['firstname'], + lastname2 = result[2]['lastname'], + dateofbirth2 = result[2]['dateofbirth'], + sex2 = result[2]['sex'], + height2 = result[2]['height'], + firstname3 = '', + lastname3 = '', + dateofbirth3 = '', + sex3 = '', + height3 = '' + } - callback(data) - elseif result[1] and result[2] and not result[3] then - local data = { - identifier = result[1]['identifier'], - firstname1 = result[1]['firstname'], - lastname1 = result[1]['lastname'], - dateofbirth1 = result[1]['dateofbirth'], - sex1 = result[1]['sex'], - height1 = result[1]['height'], - firstname2 = result[2]['firstname'], - lastname2 = result[2]['lastname'], - dateofbirth2 = result[2]['dateofbirth'], - sex2 = result[2]['sex'], - height2 = result[2]['height'], - firstname3 = '', - lastname3 = '', - dateofbirth3 = '', - sex3 = '', - height3 = '' - } + callback(data) + elseif result[1] and not result[2] and not result[3] then + local data = { + identifier = result[1]['identifier'], + firstname1 = result[1]['firstname'], + lastname1 = result[1]['lastname'], + dateofbirth1 = result[1]['dateofbirth'], + sex1 = result[1]['sex'], + height1 = result[1]['height'], + firstname2 = '', + lastname2 = '', + dateofbirth2 = '', + sex2 = '', + height2 = '', + firstname3 = '', + lastname3 = '', + dateofbirth3 = '', + sex3 = '', + height3 = '' + } - callback(data) - elseif result[1] and not result[2] and not result[3] then - local data = { - identifier = result[1]['identifier'], - firstname1 = result[1]['firstname'], - lastname1 = result[1]['lastname'], - dateofbirth1 = result[1]['dateofbirth'], - sex1 = result[1]['sex'], - height1 = result[1]['height'], - firstname2 = '', - lastname2 = '', - dateofbirth2 = '', - sex2 = '', - height2 = '', - firstname3 = '', - lastname3 = '', - dateofbirth3 = '', - sex3 = '', - height3 = '' - } + callback(data) + else + local data = { + identifier = '', + firstname1 = '', + lastname1 = '', + dateofbirth1 = '', + sex1 = '', + height1 = '', + firstname2 = '', + lastname2 = '', + dateofbirth2 = '', + sex2 = '', + height2 = '', + firstname3 = '', + lastname3 = '', + dateofbirth3 = '', + sex3 = '', + height3 = '' + } - callback(data) - else - local data = { - identifier = '', - firstname1 = '', - lastname1 = '', - dateofbirth1 = '', - sex1 = '', - height1 = '', - firstname2 = '', - lastname2 = '', - dateofbirth2 = '', - sex2 = '', - height2 = '', - firstname3 = '', - lastname3 = '', - dateofbirth3 = '', - sex3 = '', - height3 = '' - } - - callback(data) - end - end) + callback(data) + end + end) end function setIdentity(identifier, data, callback) - MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", - { - ['@identifier'] = identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }, - function(done) - if callback then - callback(true) - end - end) + MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", + { + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, + ['@sex'] = data.sex, + ['@height'] = data.height + }, function(done) + if callback then + callback(true) + end + end) - MySQL.Async.execute( - 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', - { - ['@identifier'] = identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }) + MySQL.Async.execute( + 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', + { + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, + ['@sex'] = data.sex, + ['@height'] = data.height + }) end function updateIdentity(identifier, data, callback) - MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", - { - ['@identifier'] = identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }, - function(done) - if callback then - callback(true) - end - end) + MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", + { + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, + ['@sex'] = data.sex, + ['@height'] = data.height + }, function(done) + if callback then + callback(true) + end + end) end function deleteIdentity(identifier, data, callback) - MySQL.Async.execute("DELETE FROM `characters` WHERE identifier = @identifier AND firstname = @firstname AND lastname = @lastname AND dateofbirth = @dateofbirth AND sex = @sex AND height = @height", - { - ['@identifier'] = identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }, - function(done) - if callback then - callback(true) - end - end) + MySQL.Async.execute("DELETE FROM `characters` WHERE identifier = @identifier AND firstname = @firstname AND lastname = @lastname AND dateofbirth = @dateofbirth AND sex = @sex AND height = @height", + { + ['@identifier'] = identifier, + ['@firstname'] = data.firstname, + ['@lastname'] = data.lastname, + ['@dateofbirth'] = data.dateofbirth, + ['@sex'] = data.sex, + ['@height'] = data.height + }, function(done) + if callback then + callback(true) + end + end) end RegisterServerEvent('esx_identity:setIdentity') @@ -194,7 +189,7 @@ AddEventHandler('esx_identity:setIdentity', function(data, myIdentifiers) if callback then TriggerClientEvent('esx_identity:identityCheck', myIdentifiers.playerid, true) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Set Identity!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to set identity, try again!!") end end) end) @@ -217,20 +212,10 @@ AddEventHandler('es:playerLoaded', function(source) end) end) -TriggerEvent('es:addGroupCommand', 'idhelp', "user", function(source, args, user) - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "Commands List") - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "/register - Register A New Character") - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "/charlist - List Your Characters") - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "/charselect 1,2,3 - Change Your Active Character") - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "/delchar 1,2,3 - Delete A Character") -end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") -end, {help = "List all the identity-related commands"}) - TriggerEvent('es:addCommand', 'register', function(source, args, user) getCharacters(source, function(data) if data.firstname3 ~= '' then - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You Can Only Have 3 Characters.") + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You can only have 3 registered characters. Use the ^3/delchar^0 command in order to delete existing characters.") else TriggerClientEvent('esx_identity:showRegisterIdentity', source, {}) end @@ -240,14 +225,14 @@ end, {help = "Register a new character"}) TriggerEvent('es:addGroupCommand', 'char', "user", function(source, args, user) getIdentity(source, function(data) if data.firstname == '' then - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You Have No Active Character.") + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You do not have an active character!") else TriggerClientEvent('chatMessage', source, '[IDENTITY] Active Character:', {255, 0, 0}, data.firstname .. " " .. data.lastname) end end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") -end, {help = "List Your Current Active Character"}) + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") +end, {help = "List your current character"}) TriggerEvent('es:addGroupCommand', 'charlist', "user", function(source, args, user) getCharacters(source, function(data) @@ -262,12 +247,12 @@ TriggerEvent('es:addGroupCommand', 'charlist', "user", function(source, args, us end end else - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You Have No Characters. Please use the /register command.") + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You have no registered characters. Use the ^3/register^0 command to register an character.") end end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") -end, {help = "List Your Characters"}) + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") +end, {help = "List all your registered characters"}) TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, user) local charNumber = tonumber(args[1]) @@ -275,12 +260,12 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, getCharacters(source, function(data) if charNumber == 1 then local data = { - identifier = data.identifier, - firstname = data.firstname1, - lastname = data.lastname1, - dateofbirth = data.dateofbirth1, - sex = data.sex1, - height = data.height1 + identifier = data.identifier, + firstname = data.firstname1, + lastname = data.lastname1, + dateofbirth = data.dateofbirth1, + sex = data.sex1, + height = data.height1 } if data.firstname ~= '' then @@ -288,7 +273,7 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, if callback then TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Update Identity!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") end end) else @@ -297,12 +282,12 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, elseif charNumber == 2 then local data = { - identifier = data.identifier, - firstname = data.firstname2, - lastname = data.lastname2, - dateofbirth = data.dateofbirth2, - sex = data.sex2, - height = data.height2 + identifier = data.identifier, + firstname = data.firstname2, + lastname = data.lastname2, + dateofbirth = data.dateofbirth2, + sex = data.sex2, + height = data.height2 } if data.firstname ~= '' then @@ -311,7 +296,7 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, if callback then TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Update Identity!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") end end) else @@ -320,12 +305,12 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, elseif charNumber == 3 then local data = { - identifier = data.identifier, - firstname = data.firstname3, - lastname = data.lastname3, - dateofbirth = data.dateofbirth3, - sex = data.sex3, - height = data.height3 + identifier = data.identifier, + firstname = data.firstname3, + lastname = data.lastname3, + dateofbirth = data.dateofbirth3, + sex = data.sex3, + height = data.height3 } if data.firstname ~= '' then @@ -333,20 +318,20 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, if callback then TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Update Identity!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") end end) else TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 3!") end else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Update Identity!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") end end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!") -end, {help = "/charselect 1,2,3"}) + TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") +end, {help = "Switch character", params = {{name = "char", help = "character id, ranges from 1-3"}}}) TriggerEvent('es:addGroupCommand', 'delchar', "user", function(source, args, user) @@ -357,20 +342,20 @@ TriggerEvent('es:addGroupCommand', 'delchar', "user", function(source, args, use if charNumber == 1 then local data = { - identifier = data.identifier, - firstname = data.firstname1, - lastname = data.lastname1, - dateofbirth = data.dateofbirth1, - sex = data.sex1, - height = data.height1 + identifier = data.identifier, + firstname = data.firstname1, + lastname = data.lastname1, + dateofbirth = data.dateofbirth1, + sex = data.sex1, + height = data.height1 } if data.firstname ~= '' then deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You have deleted ^3" .. data.firstname .. " " .. data.lastname .. "!") else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Delete Identity!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the identity, try again!") end end) else @@ -380,20 +365,20 @@ TriggerEvent('es:addGroupCommand', 'delchar', "user", function(source, args, use elseif charNumber == 2 then local data = { - identifier = data.identifier, - firstname = data.firstname2, - lastname = data.lastname2, - dateofbirth = data.dateofbirth2, - sex = data.sex2, - height = data.height2 + identifier = data.identifier, + firstname = data.firstname2, + lastname = data.lastname2, + dateofbirth = data.dateofbirth2, + sex = data.sex2, + height = data.height2 } if data.firstname ~= '' then deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You have deleted ^3" .. data.firstname .. " " .. data.lastname .. "!") else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Delete Identity!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the identity, try again!") end end) else @@ -403,30 +388,29 @@ TriggerEvent('es:addGroupCommand', 'delchar', "user", function(source, args, use elseif charNumber == 3 then local data = { - identifier = data.identifier, - firstname = data.firstname3, - lastname = data.lastname3, - dateofbirth = data.dateofbirth3, - sex = data.sex3, - height = data.height3 + identifier = data.identifier, + firstname = data.firstname3, + lastname = data.lastname3, + dateofbirth = data.dateofbirth3, + sex = data.sex3, + height = data.height3 } - + if data.firstname ~= '' then - deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You Have Deleted " .. data.firstname .. " " .. data.lastname .. "!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You have deleted ^3" .. data.firstname .. " " .. data.lastname .. "!") else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Delete Identity!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the identity, try again!") end end) else TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 3!") end else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed To Delete Identity!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the identity, try again!") end end) end, function(source, args, user) TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") -end, {help = "/delchar 1,2,3"}) \ No newline at end of file +end, {help = "Delete an character", params = {{name = "char", help = "character id, ranges from 1-3"}}}) From af88d9b519425df363d72cc2f15f80ea4b4d4f49 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Thu, 19 Apr 2018 19:03:00 +0200 Subject: [PATCH 33/78] Improved restarting script, language improvements, typo fixes and final commit v1.0.3 --- README.md | 5 ++-- __resource.lua | 2 +- client/main.lua | 2 +- server/main.lua | 70 +++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index a4b25cd3..245ce49c 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,10 @@ start esx_identity ### Commands ``` -/identityhelp /register /charlist -/charselect 1,2,3 -/delchar 1,2,3 +/charselect +/chardel ``` ### License diff --git a/__resource.lua b/__resource.lua index 86cfa1da..98d1297c 100644 --- a/__resource.lua +++ b/__resource.lua @@ -4,7 +4,7 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' description 'ESX Identity' -version '1.0.4' +version '1.0.3' client_script 'client/main.lua' diff --git a/client/main.lua b/client/main.lua index 1c0b10c3..0f73ec65 100644 --- a/client/main.lua +++ b/client/main.lua @@ -40,7 +40,7 @@ RegisterNUICallback('escape', function(data, cb) if hasIdentity == true then EnableGui(false) else - TriggerEvent("chatMessage", "^1[IDENTITY]", {255, 255, 0}, "You must create your first identity in order to play.") + TriggerEvent("chatMessage", "^1[IDENTITY]", {255, 255, 0}, "You must create your first character in order to play.") end end) diff --git a/server/main.lua b/server/main.lua index 946c83ff..92b3f062 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,3 +1,7 @@ +ESX = nil + +TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + function getIdentity(source, callback) local identifier = GetPlayerIdentifiers(source)[1] @@ -189,12 +193,11 @@ AddEventHandler('esx_identity:setIdentity', function(data, myIdentifiers) if callback then TriggerClientEvent('esx_identity:identityCheck', myIdentifiers.playerid, true) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to set identity, try again!!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to set character, try again!!") end end) end) - AddEventHandler('es:playerLoaded', function(source) local myID = { steamid = GetPlayerIdentifiers(source)[1], @@ -212,6 +215,35 @@ AddEventHandler('es:playerLoaded', function(source) end) end) +AddEventHandler('onResourceStart', function(resource) + if resource == GetCurrentResourceName() then + Citizen.Wait(3000) + + -- Set all the client side variables for connected users one new time + local xPlayers = ESX.GetPlayers() + for i=1, #xPlayers, 1 do + + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + + local myID = { + steamid = GetPlayerIdentifiers(xPlayer.source)[1], + playerid = xPlayer.source + } + + TriggerClientEvent('esx_identity:saveID', xPlayer.source, myID) + + getIdentity(xPlayer.source, function(data) + if data.firstname == '' then + TriggerClientEvent('esx_identity:identityCheck', xPlayer.source, false) + TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) + else + TriggerClientEvent('esx_identity:identityCheck', xPlayer.source, true) + end + end) + end + end +end) + TriggerEvent('es:addCommand', 'register', function(source, args, user) getCharacters(source, function(data) if data.firstname3 ~= '' then @@ -227,7 +259,7 @@ TriggerEvent('es:addGroupCommand', 'char', "user", function(source, args, user) if data.firstname == '' then TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You do not have an active character!") else - TriggerClientEvent('chatMessage', source, '[IDENTITY] Active Character:', {255, 0, 0}, data.firstname .. " " .. data.lastname) + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "Active Character: ^2" .. data.firstname .. " " .. data.lastname .. "^0") end end) end, function(source, args, user) @@ -242,12 +274,12 @@ TriggerEvent('es:addGroupCommand', 'charlist', "user", function(source, args, us if data.firstname2 ~= '' then TriggerClientEvent('chatMessage', source, '[IDENTITY] Character 2:', {255, 0, 0}, data.firstname2 .. " " .. data.lastname2) - if dada.firstname3 ~= '' then + if data.firstname3 ~= '' then TriggerClientEvent('chatMessage', source, '[IDENTITY] Character 3:', {255, 0, 0}, data.firstname3 .. " " .. data.lastname3) end end else - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You have no registered characters. Use the ^3/register^0 command to register an character.") + TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You have no registered characters. Use the ^3/register^0 command to register a character.") end end) end, function(source, args, user) @@ -257,6 +289,11 @@ end, {help = "List all your registered characters"}) TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, user) local charNumber = tonumber(args[1]) + if charNumber == nil or charNumber > 3 or charNumber < 1 then + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "That's an invalid character!") + return + end + getCharacters(source, function(data) if charNumber == 1 then local data = { @@ -271,7 +308,7 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, if data.firstname ~= '' then updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to ^2" .. data.firstname .. " " .. data.lastname .. "^0!") else TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") end @@ -294,7 +331,7 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to ^2" .. data.firstname .. " " .. data.lastname .. "^0!") else TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") end @@ -316,7 +353,7 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, if data.firstname ~= '' then updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to " .. data.firstname .. " " .. data.lastname .. "!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to ^2" .. data.firstname .. " " .. data.lastname .. "^0!") else TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") end @@ -331,12 +368,17 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, end) end, function(source, args, user) TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") -end, {help = "Switch character", params = {{name = "char", help = "character id, ranges from 1-3"}}}) +end, {help = "Switch character", params = {{name = "char", help = "the character id, ranges from 1-3"}}}) -TriggerEvent('es:addGroupCommand', 'delchar', "user", function(source, args, user) +TriggerEvent('es:addGroupCommand', 'chardel', "user", function(source, args, user) local charNumber = tonumber(args[1]) + if charNumber == nil or charNumber > 3 or charNumber < 1 then + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "That's an invalid character!") + return + end + getCharacters(source, function(data) if charNumber == 1 then @@ -378,7 +420,7 @@ TriggerEvent('es:addGroupCommand', 'delchar', "user", function(source, args, use if callback then TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You have deleted ^3" .. data.firstname .. " " .. data.lastname .. "!") else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the identity, try again!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the character, try again!") end end) else @@ -401,16 +443,16 @@ TriggerEvent('es:addGroupCommand', 'delchar', "user", function(source, args, use if callback then TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You have deleted ^3" .. data.firstname .. " " .. data.lastname .. "!") else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the identity, try again!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the character, try again!") end end) else TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 3!") end else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the identity, try again!") + TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the character, try again!") end end) end, function(source, args, user) TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") -end, {help = "Delete an character", params = {{name = "char", help = "character id, ranges from 1-3"}}}) +end, {help = "Delete a registered character", params = {{name = "char", help = "the character id, ranges from 1-3"}}}) From f23b5458a81a0c34e2f5e5be36da899098e82f67 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 30 Apr 2018 16:12:40 +0200 Subject: [PATCH 34/78] Added ID as primary key --- esx_identity.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/esx_identity.sql b/esx_identity.sql index 73220965..93b31f5a 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -9,10 +9,13 @@ ALTER TABLE `users` ; CREATE TABLE `characters` ( + `id` int(11) NOT NULL AUTO_INCREMENT, `identifier` varchar(255) NOT NULL, `firstname` varchar(255) NOT NULL, `lastname` varchar(255) NOT NULL, `dateofbirth` varchar(255) NOT NULL, `sex` varchar(1) NOT NULL DEFAULT 'f', - `height` varchar(128) NOT NULL + `height` varchar(128) NOT NULL, + + PRIMARY KEY (`id`) ); From 5161c009ba3241754857ae5827cb86efde063948 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 4 Jun 2018 22:15:30 +0200 Subject: [PATCH 35/78] Minor improvements --- README.md | 11 ++++++++++- __resource.lua | 8 +++----- client/main.lua | 6 +++--- esx_identity.sql | 20 ++++++++++---------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 245ce49c..5910aa92 100644 --- a/README.md +++ b/README.md @@ -30,5 +30,14 @@ start esx_identity /chardel ``` +# Legal ### License -This script is licensed under GPLv3, see the [license](LICENSE) +esx_identity - rp characters + +Copyright (C) 2015-2018 Jérémie N'gadi + +This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version. + +This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details. + +You should have received a copy Of the GNU General Public License along with this program. If Not, see http://www.gnu.org/licenses/. diff --git a/__resource.lua b/__resource.lua index 98d1297c..5e0be4f0 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,5 +1,3 @@ --- https://wiki.fivem.net/wiki/Resource_manifest - resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' description 'ESX Identity' @@ -9,9 +7,9 @@ version '1.0.3' client_script 'client/main.lua' server_scripts { - "@mysql-async/lib/MySQL.lua", - "@es_extended/locale.lua", - "server/main.lua" + '@mysql-async/lib/MySQL.lua', + '@es_extended/locale.lua', + 'server/main.lua' } ui_page 'html/index.html' diff --git a/client/main.lua b/client/main.lua index 0f73ec65..30f8ad0a 100644 --- a/client/main.lua +++ b/client/main.lua @@ -37,10 +37,10 @@ AddEventHandler("esx_identity:saveID", function(data) end) RegisterNUICallback('escape', function(data, cb) - if hasIdentity == true then + if hasIdentity then EnableGui(false) else - TriggerEvent("chatMessage", "^1[IDENTITY]", {255, 255, 0}, "You must create your first character in order to play.") + TriggerEvent('chat:addMessage', { args = { '^1[IDENTITY]', '^1You must create your first character in order to play' } }) end end) @@ -119,7 +119,7 @@ end) function verifyName(name) -- Don't allow short user names local nameLength = string.len(name) - if nameLength > 25 or nameLength < 5 then + if nameLength > 25 or nameLength < 2 then return 'Your player name is either too short or too long.' end diff --git a/esx_identity.sql b/esx_identity.sql index 93b31f5a..29e512f6 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -1,21 +1,21 @@ USE `essentialmode`; -ALTER TABLE `users` +ALTER TABLE `users` ( ADD COLUMN `firstname` VARCHAR(50) NULL DEFAULT '', ADD COLUMN `lastname` VARCHAR(50) NULL DEFAULT '', ADD COLUMN `dateofbirth` VARCHAR(25) NULL DEFAULT '', ADD COLUMN `sex` VARCHAR(10) NULL DEFAULT '', ADD COLUMN `height` VARCHAR(5) NULL DEFAULT '' -; +); CREATE TABLE `characters` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `identifier` varchar(255) NOT NULL, - `firstname` varchar(255) NOT NULL, - `lastname` varchar(255) NOT NULL, - `dateofbirth` varchar(255) NOT NULL, - `sex` varchar(1) NOT NULL DEFAULT 'f', - `height` varchar(128) NOT NULL, - + `identifier` VARCHAR(255) NOT NULL, + `firstname` VARCHAR(255) NOT NULL, + `lastname` VARCHAR(255) NOT NULL, + `dateofbirth` VARCHAR(255) NOT NULL, + `sex` VARCHAR(1) NOT NULL DEFAULT 'M', + `height` VARCHAR(128) NOT NULL, + PRIMARY KEY (`id`) -); +); \ No newline at end of file From 934ca309ff97fbd47b408274aa9c62ae06a77a34 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Tue, 5 Jun 2018 20:16:29 +0200 Subject: [PATCH 36/78] Fixed broken sql file --- esx_identity.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esx_identity.sql b/esx_identity.sql index 29e512f6..42d5c152 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -1,12 +1,12 @@ USE `essentialmode`; -ALTER TABLE `users` ( +ALTER TABLE `users` ADD COLUMN `firstname` VARCHAR(50) NULL DEFAULT '', ADD COLUMN `lastname` VARCHAR(50) NULL DEFAULT '', ADD COLUMN `dateofbirth` VARCHAR(25) NULL DEFAULT '', ADD COLUMN `sex` VARCHAR(10) NULL DEFAULT '', ADD COLUMN `height` VARCHAR(5) NULL DEFAULT '' -); +; CREATE TABLE `characters` ( `id` int(11) NOT NULL AUTO_INCREMENT, From 1bc9e5ede663a7bbe6537360c74b0fd15bae2878 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sat, 9 Jun 2018 11:59:54 +0200 Subject: [PATCH 37/78] Fixed buggy UI black screen Co-Authored-By: benjaminbra --- README.md | 28 ++++++++++++++++++++-------- __resource.lua | 14 +++++++++----- client/main.lua | 14 ++++---------- html/cursor.png | Bin 272 -> 0 bytes html/index.html | 1 - html/script.js | 27 --------------------------- html/style.css | 7 ------- 7 files changed, 33 insertions(+), 58 deletions(-) delete mode 100644 html/cursor.png diff --git a/README.md b/README.md index 5910aa92..0f8f41f5 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,37 @@ # esx_identity -[REQUIREMENTS] - +## Requirements * Dependencies For Full Functionality * [esx_skin](https://github.com/ESX-Org/esx_skin) * [esx_policejob](https://github.com/ESX-Org/esx_policejob) * [esx_society](https://github.com/ESX-Org/esx_society) -[INSTALLATION] +## Download & Installation -1) Install To resources/[esx]/esx_identity -`<< MUST BE INSTALLED HERE` -2) Import esx_identity.sql in your database +### Using [fvm](https://github.com/qlaffont/fvm-installer) +``` +fvm install --save --folder=esx esx-org/esx_identity +``` -3) Add this in your server.cfg : +### Using Git +``` +cd resources +git clone https://github.com/ESX-Org/esx_identity [esx]/esx_identity +``` + +### Manually +- Download https://github.com/ESX-Org/esx_identity/archive/master.zip +- Put it in the `[esx]` directory + +## Installation +- Import `esx_identity.sql` in your database +- Add this to your `server.cfg`: ``` start esx_identity ``` -4) If you are using esx_policejob or esx_society, you need to enable the following in the files config.lua: +- If you are using esx_policejob or esx_society, you need to enable the following in the scripts' `config.lua`: ```Config.EnableESXIdentity = true``` ### Commands diff --git a/__resource.lua b/__resource.lua index 5e0be4f0..07f5c207 100644 --- a/__resource.lua +++ b/__resource.lua @@ -2,9 +2,7 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' description 'ESX Identity' -version '1.0.3' - -client_script 'client/main.lua' +version '1.1.0' server_scripts { '@mysql-async/lib/MySQL.lua', @@ -12,11 +10,17 @@ server_scripts { 'server/main.lua' } +client_scripts { + '@es_extended/locale.lua', + 'client/main.lua' +} + ui_page 'html/index.html' files { 'html/index.html', 'html/script.js', - 'html/style.css', - 'html/cursor.png' + 'html/style.css' } + +dependency 'es_extended' \ No newline at end of file diff --git a/client/main.lua b/client/main.lua index 30f8ad0a..f8864a28 100644 --- a/client/main.lua +++ b/client/main.lua @@ -11,13 +11,13 @@ Citizen.CreateThread(function() end end) -function EnableGui(enable) - SetNuiFocus(enable) - guiEnabled = enable +function EnableGui(state) + SetNuiFocus(state, state) + guiEnabled = state SendNUIMessage({ type = "enableui", - enable = enable + enable = state }) end @@ -105,12 +105,6 @@ Citizen.CreateThread(function() DisableControlAction(0, 143, true) -- disable melee DisableControlAction(0, 75, true) -- disable exit vehicle DisableControlAction(27, 75, true) -- disable exit vehicle - - if IsDisabledControlJustReleased(0, 142) then -- MeleeAttackAlternate - SendNUIMessage({ - type = "click" - }) - end end Citizen.Wait(10) end diff --git a/html/cursor.png b/html/cursor.png deleted file mode 100644 index 39536f953d701b36a90dc56084bafd988371a2fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^q9Dw{1|(OCFP#RYSkfJR9T^xl_H+M9WCij$3p^r= z85sBufiR<}hF1enP_o1|q9iy!t)x7$D3zfgF*C13FE6!3!9>qM&(L5k7uNxxqFzrI z#}Etut!FreS`>I(0^ikVp5f1PInc0ibrsXWO3z8Ee_BE>W<&%Ean9H1Y|@_Ma)5tI zP3vrppG@U}o4EJ`H!a-_TKCSz%v`zHX&3lrYRgJzbSuAt9 z@6PvoS_%Jm+&BGp_A+yZ?Fo&SwU@JtJ?kA`YTb#E`^&mC!8qZZWp1Mjt5em&H79@$ OWAJqKb6Mw<&;$S!<6)ox diff --git a/html/index.html b/html/index.html index 1ccd4730..6fc5dfc7 100644 --- a/html/index.html +++ b/html/index.html @@ -5,7 +5,6 @@ -

Register

diff --git a/html/script.js b/html/script.js index 0359d753..32140b19 100644 --- a/html/script.js +++ b/html/script.js @@ -1,37 +1,10 @@ -var documentWidth = document.documentElement.clientWidth; -var documentHeight = document.documentElement.clientHeight; - -var cursor = document.getElementById("cursor"); -var cursorX = documentWidth / 2; -var cursorY = documentHeight / 2; - -function UpdateCursorPos() { - cursor.style.left = cursorX; - cursor.style.top = cursorY; -} - -function Click(x, y) { - var element = $(document.elementFromPoint(x, y)); - element.focus().click(); -} - $(function() { window.addEventListener('message', function(event) { if (event.data.type == "enableui") { - cursor.style.display = event.data.enable ? "block" : "none"; document.body.style.display = event.data.enable ? "block" : "none"; - } else if (event.data.type == "click") { - // Avoid clicking the cursor itself, click 1px to the top/left; - Click(cursorX - 1, cursorY - 1); } }); - $(document).mousemove(function(event) { - cursorX = event.pageX; - cursorY = event.pageY; - UpdateCursorPos(); - }); - document.onkeyup = function (data) { if (data.which == 27) { // Escape key $.post('http://esx_identity/escape', JSON.stringify({})); diff --git a/html/style.css b/html/style.css index b2efe3db..79a6b347 100644 --- a/html/style.css +++ b/html/style.css @@ -1,10 +1,3 @@ -#cursor { - position: absolute; - z-index: 999999; - display: none; -} - -/* Required */ body { font-family: sans-serif; overflow: hidden; From 3346db2bd9d4f4ae4bdd829014dae75c06dcd830 Mon Sep 17 00:00:00 2001 From: AdrineX Date: Tue, 12 Jun 2018 20:18:06 +0300 Subject: [PATCH 38/78] Add Finnish lang... --- html/fi_index.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 html/fi_index.html diff --git a/html/fi_index.html b/html/fi_index.html new file mode 100644 index 00000000..87ca250a --- /dev/null +++ b/html/fi_index.html @@ -0,0 +1,22 @@ + + + + + + + +
+ +

Rekistöröinti

+
+
+
+
+ Mies + Nainen
+ + +
+ + + From bbadc0aa6be86e4c7bd6e2a4ea4835bf5d623cf2 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Fri, 29 Jun 2018 22:16:03 +0200 Subject: [PATCH 39/78] Cleanup --- client/main.lua | 12 ++-- html/sv_index.html | 22 ++++++ server/main.lua | 169 ++++++++++++++++++++++----------------------- 3 files changed, 112 insertions(+), 91 deletions(-) create mode 100644 html/sv_index.html diff --git a/client/main.lua b/client/main.lua index f8864a28..acc400fe 100644 --- a/client/main.lua +++ b/client/main.lua @@ -21,18 +21,18 @@ function EnableGui(state) }) end -RegisterNetEvent("esx_identity:showRegisterIdentity") -AddEventHandler("esx_identity:showRegisterIdentity", function() +RegisterNetEvent('esx_identity:showRegisterIdentity') +AddEventHandler('esx_identity:showRegisterIdentity', function() EnableGui(true) end) -RegisterNetEvent("esx_identity:identityCheck") -AddEventHandler("esx_identity:identityCheck", function(identityCheck) +RegisterNetEvent('esx_identity:identityCheck') +AddEventHandler('esx_identity:identityCheck', function(identityCheck) hasIdentity = identityCheck end) -RegisterNetEvent("esx_identity:saveID") -AddEventHandler("esx_identity:saveID", function(data) +RegisterNetEvent('esx_identity:saveID') +AddEventHandler('esx_identity:saveID', function(data) myIdentifiers = data end) diff --git a/html/sv_index.html b/html/sv_index.html new file mode 100644 index 00000000..7706c17b --- /dev/null +++ b/html/sv_index.html @@ -0,0 +1,22 @@ + + + + + + + +
+
+

Registrera

+
+
+
+
+ Man + Kvinna
+ +
+
+ + + diff --git a/server/main.lua b/server/main.lua index 92b3f062..135c7eb9 100644 --- a/server/main.lua +++ b/server/main.lua @@ -9,14 +9,14 @@ function getIdentity(source, callback) { ['@identifier'] = identifier }, function(result) - if result[1]['firstname'] ~= nil then + if result[1].firstname ~= nil then local data = { - identifier = result[1]['identifier'], - firstname = result[1]['firstname'], - lastname = result[1]['lastname'], - dateofbirth = result[1]['dateofbirth'], - sex = result[1]['sex'], - height = result[1]['height'] + identifier = result[1].identifier, + firstname = result[1].firstname, + lastname = result[1].lastname, + dateofbirth = result[1].dateofbirth, + sex = result[1].sex, + height = result[1].height } callback(data) else @@ -42,38 +42,38 @@ function getCharacters(source, callback) }, function(result) if result[1] and result[2] and result[3] then local data = { - identifier = result[1]['identifier'], - firstname1 = result[1]['firstname'], - lastname1 = result[1]['lastname'], - dateofbirth1 = result[1]['dateofbirth'], - sex1 = result[1]['sex'], - height1 = result[1]['height'], - firstname2 = result[2]['firstname'], - lastname2 = result[2]['lastname'], - dateofbirth2 = result[2]['dateofbirth'], - sex2 = result[2]['sex'], - height2 = result[2]['height'], - firstname3 = result[3]['firstname'], - lastname3 = result[3]['lastname'], - dateofbirth3 = result[3]['dateofbirth'], - sex3 = result[3]['sex'], - height3 = result[3]['height'] + identifier = result[1].identifier, + firstname1 = result[1].firstname, + lastname1 = result[1].lastname, + dateofbirth1 = result[1].dateofbirth, + sex1 = result[1].sex, + height1 = result[1].height, + firstname2 = result[2].firstname, + lastname2 = result[2].lastname, + dateofbirth2 = result[2].dateofbirth, + sex2 = result[2].sex, + height2 = result[2].height, + firstname3 = result[3].firstname, + lastname3 = result[3].lastname, + dateofbirth3 = result[3].dateofbirth, + sex3 = result[3].sex, + height3 = result[3].height } callback(data) elseif result[1] and result[2] and not result[3] then local data = { - identifier = result[1]['identifier'], - firstname1 = result[1]['firstname'], - lastname1 = result[1]['lastname'], - dateofbirth1 = result[1]['dateofbirth'], - sex1 = result[1]['sex'], - height1 = result[1]['height'], - firstname2 = result[2]['firstname'], - lastname2 = result[2]['lastname'], - dateofbirth2 = result[2]['dateofbirth'], - sex2 = result[2]['sex'], - height2 = result[2]['height'], + identifier = result[1].identifier, + firstname1 = result[1].firstname, + lastname1 = result[1].lastname, + dateofbirth1 = result[1].dateofbirth, + sex1 = result[1].sex, + height1 = result[1].height, + firstname2 = result[2].firstname, + lastname2 = result[2].lastname, + dateofbirth2 = result[2].dateofbirth, + sex2 = result[2].sex, + height2 = result[2].height, firstname3 = '', lastname3 = '', dateofbirth3 = '', @@ -84,12 +84,12 @@ function getCharacters(source, callback) callback(data) elseif result[1] and not result[2] and not result[3] then local data = { - identifier = result[1]['identifier'], - firstname1 = result[1]['firstname'], - lastname1 = result[1]['lastname'], - dateofbirth1 = result[1]['dateofbirth'], - sex1 = result[1]['sex'], - height1 = result[1]['height'], + identifier = result[1].identifier, + firstname1 = result[1].firstname, + lastname1 = result[1].lastname, + dateofbirth1 = result[1].dateofbirth, + sex1 = result[1].sex, + height1 = result[1].height, firstname2 = '', lastname2 = '', dateofbirth2 = '', @@ -193,7 +193,7 @@ AddEventHandler('esx_identity:setIdentity', function(data, myIdentifiers) if callback then TriggerClientEvent('esx_identity:identityCheck', myIdentifiers.playerid, true) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to set character, try again!!") + TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'Failed to set character, try again later or contact the server admin!' } }) end end) end) @@ -226,7 +226,7 @@ AddEventHandler('onResourceStart', function(resource) local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) local myID = { - steamid = GetPlayerIdentifiers(xPlayer.source)[1], + steamid = xPlayer.identifier, playerid = xPlayer.source } @@ -247,50 +247,50 @@ end) TriggerEvent('es:addCommand', 'register', function(source, args, user) getCharacters(source, function(data) if data.firstname3 ~= '' then - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You can only have 3 registered characters. Use the ^3/delchar^0 command in order to delete existing characters.") + TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'You can only have 3 registered characters. Use the ^3/chardel^0 command in order to delete existing characters.' } }) else TriggerClientEvent('esx_identity:showRegisterIdentity', source, {}) end end) end, {help = "Register a new character"}) -TriggerEvent('es:addGroupCommand', 'char', "user", function(source, args, user) +TriggerEvent('es:addGroupCommand', 'char', 'user', function(source, args, user) getIdentity(source, function(data) if data.firstname == '' then - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You do not have an active character!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You do not have an active character!' } }) else - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "Active Character: ^2" .. data.firstname .. " " .. data.lastname .. "^0") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Active character: ^2' .. data.firstname .. ' ' .. data.lastname } }) end end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient permissions!' } }) end, {help = "List your current character"}) -TriggerEvent('es:addGroupCommand', 'charlist', "user", function(source, args, user) +TriggerEvent('es:addGroupCommand', 'charlist', 'user', function(source, args, user) getCharacters(source, function(data) if data.firstname1 ~= '' then - TriggerClientEvent('chatMessage', source, '[IDENTITY] Character 1:', {255, 0, 0}, data.firstname1 .. " " .. data.lastname1) + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY] Character 1:', data.firstname1 .. ' ' .. data.lastname1 } }) if data.firstname2 ~= '' then - TriggerClientEvent('chatMessage', source, '[IDENTITY] Character 2:', {255, 0, 0}, data.firstname2 .. " " .. data.lastname2) + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY] Character 2:', data.firstname2 .. ' ' .. data.lastname2 } }) if data.firstname3 ~= '' then - TriggerClientEvent('chatMessage', source, '[IDENTITY] Character 3:', {255, 0, 0}, data.firstname3 .. " " .. data.lastname3) + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY] Character 3:', data.firstname3 .. ' ' .. data.lastname3 } }) end end else - TriggerClientEvent('chatMessage', source, '[IDENTITY]', {255, 0, 0}, "You have no registered characters. Use the ^3/register^0 command to register a character.") + TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'You have no registered characters. Use the ^3/register^0 command to register a character.' } }) end end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient permissions!' } }) end, {help = "List all your registered characters"}) -TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, user) +TriggerEvent('es:addGroupCommand', 'charselect', 'user', function(source, args, user) local charNumber = tonumber(args[1]) - + if charNumber == nil or charNumber > 3 or charNumber < 1 then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "That's an invalid character!") + TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'That\'s an invalid character!' } }) return end @@ -308,13 +308,13 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, if data.firstname ~= '' then updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to ^2" .. data.firstname .. " " .. data.lastname .. "^0!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Updated your active character to ^2' .. data.firstname .. ' ' .. data.lastname } }) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to update your identity, try again later or contact the server admin!' } }) end end) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 1!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 1!' } }) end elseif charNumber == 2 then @@ -331,13 +331,13 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to ^2" .. data.firstname .. " " .. data.lastname .. "^0!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Updated your active character to ^2' .. data.firstname .. ' ' .. data.lastname } }) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to update your identity, try again later or contact the server admin!' } }) end end) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 2!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 2!' } }) end elseif charNumber == 3 then @@ -353,32 +353,31 @@ TriggerEvent('es:addGroupCommand', 'charselect', "user", function(source, args, if data.firstname ~= '' then updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Updated your active character to ^2" .. data.firstname .. " " .. data.lastname .. "^0!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Updated your active character to ^2' .. data.firstname .. ' ' .. data.lastname } }) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to update your identity, try again later or contact the server admin!' } }) end end) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 3!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 3!' } }) end else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to update your identity, try again!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to update your identity, try again later or contact the server admin!' } }) end end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") -end, {help = "Switch character", params = {{name = "char", help = "the character id, ranges from 1-3"}}}) - -TriggerEvent('es:addGroupCommand', 'chardel', "user", function(source, args, user) + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient permissions!' } }) +end, {help = "Switch between character", params = {{name = "char", help = "the character id, ranges from 1-3"}}}) +TriggerEvent('es:addGroupCommand', 'chardel', 'user', function(source, args, user) local charNumber = tonumber(args[1]) - + if charNumber == nil or charNumber > 3 or charNumber < 1 then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "That's an invalid character!") + TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'That\'s an invalid character!' } }) return end - + getCharacters(source, function(data) if charNumber == 1 then @@ -395,13 +394,13 @@ TriggerEvent('es:addGroupCommand', 'chardel', "user", function(source, args, use if data.firstname ~= '' then deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You have deleted ^3" .. data.firstname .. " " .. data.lastname .. "!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You have deleted ^1' .. data.firstname .. ' ' .. data.lastname } }) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the identity, try again!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to delete the character, try again later or contact the server admin!' } }) end end) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 1!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 1!' } }) end elseif charNumber == 2 then @@ -418,13 +417,13 @@ TriggerEvent('es:addGroupCommand', 'chardel', "user", function(source, args, use if data.firstname ~= '' then deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You have deleted ^3" .. data.firstname .. " " .. data.lastname .. "!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You have deleted ^1' .. data.firstname .. ' ' .. data.lastname } }) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the character, try again!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to delete the character, try again later or contact the server admin!' } }) end end) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 2!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 2!' } }) end elseif charNumber == 3 then @@ -441,18 +440,18 @@ TriggerEvent('es:addGroupCommand', 'chardel', "user", function(source, args, use if data.firstname ~= '' then deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You have deleted ^3" .. data.firstname .. " " .. data.lastname .. "!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You have deleted ^1' .. data.firstname .. ' ' .. data.lastname } }) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the character, try again!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to delete the character, try again later or contact the server admin!' } }) end end) else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "You don\'t have a character in slot 3!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 3!' } }) end else - TriggerClientEvent('chatMessage', source, "[IDENTITY]", {255, 0, 0}, "Failed to delete the character, try again!") + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to delete the character, try again!' } }) end end) end, function(source, args, user) - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!") -end, {help = "Delete a registered character", params = {{name = "char", help = "the character id, ranges from 1-3"}}}) + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient permissions!' } }) +end, {help = "Delete a registered character", params = {{name = "char", help = "the character id, ranges from 1-3"}}}) \ No newline at end of file From cb89d4edb67726ac6854000a2aa4d110d28cd2de Mon Sep 17 00:00:00 2001 From: nearbyplayer Date: Fri, 10 Aug 2018 00:53:42 -0400 Subject: [PATCH 40/78] Repo Update --- .editorconfig | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..9b425256 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_size = 4 +indent_style = tab +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file From 91954ae0255b360d1f0b3309b36a3fb5448c6911 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 10 Dec 2018 21:42:10 +0100 Subject: [PATCH 41/78] Minor cleanups --- client/main.lua | 8 ++--- html/script.js | 6 ++-- server/main.lua | 81 +++++++++++++++++++++++++------------------------ 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/client/main.lua b/client/main.lua index acc400fe..c4b0fa49 100644 --- a/client/main.lua +++ b/client/main.lua @@ -135,14 +135,14 @@ function verifyName(name) local spacesInName = 0 local spacesWithUpper = 0 for word in string.gmatch(name, '%S+') do - + if string.match(word, '%u') then spacesWithUpper = spacesWithUpper + 1 end - + spacesInName = spacesInName + 1 end - + if spacesInName > 2 then return 'Your name contains more than two spaces' end @@ -150,6 +150,6 @@ function verifyName(name) if spacesWithUpper ~= spacesInName then return 'your name must start with a capital letter.' end - + return '' end diff --git a/html/script.js b/html/script.js index 32140b19..b4d4d5b4 100644 --- a/html/script.js +++ b/html/script.js @@ -11,15 +11,17 @@ $(function() { } }; - $("#register").submit(function(e) { - e.preventDefault(); // Prevent form from submitting + $("#register").submit(function(event) { + event.preventDefault(); // Prevent form from submitting // Verify date var date = $("#dateofbirth").val(); var dateCheck = new Date($("#dateofbirth").val()); + if (dateCheck == "Invalid Date") { date == "invalid"; } + $.post('http://esx_identity/register', JSON.stringify({ firstname: $("#firstname").val(), lastname: $("#lastname").val(), diff --git a/server/main.lua b/server/main.lua index 135c7eb9..7fc76471 100644 --- a/server/main.lua +++ b/server/main.lua @@ -4,9 +4,8 @@ TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) function getIdentity(source, callback) local identifier = GetPlayerIdentifiers(source)[1] - - MySQL.Async.fetchAll("SELECT * FROM `users` WHERE `identifier` = @identifier", - { + + MySQL.Async.fetchAll('SELECT identifier, firstname, lastname, dateofbirth, sex, height FROM `users` WHERE `identifier` = @identifier', { ['@identifier'] = identifier }, function(result) if result[1].firstname ~= nil then @@ -18,6 +17,7 @@ function getIdentity(source, callback) sex = result[1].sex, height = result[1].height } + callback(data) else local data = { @@ -28,7 +28,7 @@ function getIdentity(source, callback) sex = '', height = '' } - + callback(data) end end) @@ -36,11 +36,11 @@ end function getCharacters(source, callback) local identifier = GetPlayerIdentifiers(source)[1] - MySQL.Async.fetchAll("SELECT * FROM `characters` WHERE `identifier` = @identifier", - { + MySQL.Async.fetchAll('SELECT * FROM `characters` WHERE `identifier` = @identifier', { ['@identifier'] = identifier }, function(result) if result[1] and result[2] and result[3] then + local data = { identifier = result[1].identifier, firstname1 = result[1].firstname, @@ -59,9 +59,11 @@ function getCharacters(source, callback) sex3 = result[3].sex, height3 = result[3].height } - + callback(data) + elseif result[1] and result[2] and not result[3] then + local data = { identifier = result[1].identifier, firstname1 = result[1].firstname, @@ -82,7 +84,9 @@ function getCharacters(source, callback) } callback(data) + elseif result[1] and not result[2] and not result[3] then + local data = { identifier = result[1].identifier, firstname1 = result[1].firstname, @@ -103,7 +107,9 @@ function getCharacters(source, callback) } callback(data) + else + local data = { identifier = '', firstname1 = '', @@ -124,28 +130,26 @@ function getCharacters(source, callback) } callback(data) + end end) end function setIdentity(identifier, data, callback) - MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", - { + MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { ['@identifier'] = identifier, ['@firstname'] = data.firstname, ['@lastname'] = data.lastname, ['@dateofbirth'] = data.dateofbirth, ['@sex'] = data.sex, ['@height'] = data.height - }, function(done) + }, function(rowsChanged) if callback then callback(true) end end) - MySQL.Async.execute( - 'INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', - { + MySQL.Async.execute('INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', { ['@identifier'] = identifier, ['@firstname'] = data.firstname, ['@lastname'] = data.lastname, @@ -156,15 +160,14 @@ function setIdentity(identifier, data, callback) end function updateIdentity(identifier, data, callback) - MySQL.Async.execute("UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier", - { + MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { ['@identifier'] = identifier, ['@firstname'] = data.firstname, ['@lastname'] = data.lastname, ['@dateofbirth'] = data.dateofbirth, ['@sex'] = data.sex, ['@height'] = data.height - }, function(done) + }, function(rowsChanged) if callback then callback(true) end @@ -172,15 +175,14 @@ function updateIdentity(identifier, data, callback) end function deleteIdentity(identifier, data, callback) - MySQL.Async.execute("DELETE FROM `characters` WHERE identifier = @identifier AND firstname = @firstname AND lastname = @lastname AND dateofbirth = @dateofbirth AND sex = @sex AND height = @height", - { + MySQL.Async.execute('DELETE FROM `characters` WHERE identifier = @identifier AND firstname = @firstname AND lastname = @lastname AND dateofbirth = @dateofbirth AND sex = @sex AND height = @height', { ['@identifier'] = identifier, ['@firstname'] = data.firstname, ['@lastname'] = data.lastname, ['@dateofbirth'] = data.dateofbirth, ['@sex'] = data.sex, ['@height'] = data.height - }, function(done) + }, function(rowsChanged) if callback then callback(true) end @@ -203,7 +205,7 @@ AddEventHandler('es:playerLoaded', function(source) steamid = GetPlayerIdentifiers(source)[1], playerid = source } - + TriggerClientEvent('esx_identity:saveID', source, myID) getIdentity(source, function(data) if data.firstname == '' then @@ -218,20 +220,19 @@ end) AddEventHandler('onResourceStart', function(resource) if resource == GetCurrentResourceName() then Citizen.Wait(3000) - + -- Set all the client side variables for connected users one new time - local xPlayers = ESX.GetPlayers() + local xPlayers, xPlayer = ESX.GetPlayers() for i=1, #xPlayers, 1 do - - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) - + xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + local myID = { steamid = xPlayer.identifier, playerid = xPlayer.source } - + TriggerClientEvent('esx_identity:saveID', xPlayer.source, myID) - + getIdentity(xPlayer.source, function(data) if data.firstname == '' then TriggerClientEvent('esx_identity:identityCheck', xPlayer.source, false) @@ -293,7 +294,7 @@ TriggerEvent('es:addGroupCommand', 'charselect', 'user', function(source, args, TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'That\'s an invalid character!' } }) return end - + getCharacters(source, function(data) if charNumber == 1 then local data = { @@ -317,7 +318,7 @@ TriggerEvent('es:addGroupCommand', 'charselect', 'user', function(source, args, TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 1!' } }) end elseif charNumber == 2 then - + local data = { identifier = data.identifier, firstname = data.firstname2, @@ -340,7 +341,7 @@ TriggerEvent('es:addGroupCommand', 'charselect', 'user', function(source, args, TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 2!' } }) end elseif charNumber == 3 then - + local data = { identifier = data.identifier, firstname = data.firstname3, @@ -379,9 +380,9 @@ TriggerEvent('es:addGroupCommand', 'chardel', 'user', function(source, args, use end getCharacters(source, function(data) - + if charNumber == 1 then - + local data = { identifier = data.identifier, firstname = data.firstname1, @@ -390,7 +391,7 @@ TriggerEvent('es:addGroupCommand', 'chardel', 'user', function(source, args, use sex = data.sex1, height = data.height1 } - + if data.firstname ~= '' then deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then @@ -402,9 +403,9 @@ TriggerEvent('es:addGroupCommand', 'chardel', 'user', function(source, args, use else TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 1!' } }) end - + elseif charNumber == 2 then - + local data = { identifier = data.identifier, firstname = data.firstname2, @@ -413,7 +414,7 @@ TriggerEvent('es:addGroupCommand', 'chardel', 'user', function(source, args, use sex = data.sex2, height = data.height2 } - + if data.firstname ~= '' then deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then @@ -425,9 +426,9 @@ TriggerEvent('es:addGroupCommand', 'chardel', 'user', function(source, args, use else TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 2!' } }) end - + elseif charNumber == 3 then - + local data = { identifier = data.identifier, firstname = data.firstname3, @@ -436,7 +437,7 @@ TriggerEvent('es:addGroupCommand', 'chardel', 'user', function(source, args, use sex = data.sex3, height = data.height3 } - + if data.firstname ~= '' then deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) if callback then @@ -454,4 +455,4 @@ TriggerEvent('es:addGroupCommand', 'chardel', 'user', function(source, args, use end) end, function(source, args, user) TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient permissions!' } }) -end, {help = "Delete a registered character", params = {{name = "char", help = "the character id, ranges from 1-3"}}}) \ No newline at end of file +end, {help = "Delete a registered character", params = {{name = "char", help = "the character id, ranges from 1-3"}}}) From c94f6c45cd111debdc4bb62e3e6ed22a6aa7f75a Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Thu, 13 Dec 2018 21:11:56 +0100 Subject: [PATCH 42/78] Don't show register menu if dead --- client/main.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/main.lua b/client/main.lua index c4b0fa49..f95ab368 100644 --- a/client/main.lua +++ b/client/main.lua @@ -2,6 +2,8 @@ local guiEnabled = false local myIdentity = {} local myIdentifiers = {} local hasIdentity = false +local isDead = false + ESX = nil Citizen.CreateThread(function() @@ -11,6 +13,14 @@ Citizen.CreateThread(function() end end) +AddEventHandler('esx:onPlayerDeath', function(data) + isDead = true +end) + +AddEventHandler('playerSpawned', function(spawn) + isDead = false +end) + function EnableGui(state) SetNuiFocus(state, state) guiEnabled = state @@ -23,7 +33,9 @@ end RegisterNetEvent('esx_identity:showRegisterIdentity') AddEventHandler('esx_identity:showRegisterIdentity', function() - EnableGui(true) + if not isDead then + EnableGui(true) + end end) RegisterNetEvent('esx_identity:identityCheck') From 01d2768df9e1afcdf57a8dc43e027dfcf3ffcc84 Mon Sep 17 00:00:00 2001 From: JHyeok Date: Sun, 1 Sep 2019 16:23:48 +0900 Subject: [PATCH 43/78] Added Korean Language --- html/ko_index.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 html/ko_index.html diff --git a/html/ko_index.html b/html/ko_index.html new file mode 100644 index 00000000..c04fe9b7 --- /dev/null +++ b/html/ko_index.html @@ -0,0 +1,22 @@ + + + + + + + +
+
+

등록

+
+
+
+
+ 남자 + 여자
+ +
+
+ + + \ No newline at end of file From 10665aff53ea592e8d6165eefd34b3953bc99aeb Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Wed, 15 Jan 2020 11:03:16 +0100 Subject: [PATCH 44/78] Update xPlayer name --- README.md | 2 +- client/main.lua | 5 ++- server/main.lua | 96 ++++++++++++++++++++++++++++++------------------- 3 files changed, 65 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 0f8f41f5..c2edec3f 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ start esx_identity ### License esx_identity - rp characters -Copyright (C) 2015-2018 Jérémie N'gadi +Copyright (C) 2015-2020 Jérémie N'gadi This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version. diff --git a/client/main.lua b/client/main.lua index f95ab368..9b1f08f0 100644 --- a/client/main.lua +++ b/client/main.lua @@ -97,6 +97,8 @@ end) Citizen.CreateThread(function() while true do + Citizen.Wait(0) + if guiEnabled then DisableControlAction(0, 1, true) -- LookLeftRight DisableControlAction(0, 2, true) -- LookUpDown @@ -117,8 +119,9 @@ Citizen.CreateThread(function() DisableControlAction(0, 143, true) -- disable melee DisableControlAction(0, 75, true) -- disable exit vehicle DisableControlAction(27, 75, true) -- disable exit vehicle + else + Citizen.Wait(500) end - Citizen.Wait(10) end end) diff --git a/server/main.lua b/server/main.lua index 7fc76471..d3112b89 100644 --- a/server/main.lua +++ b/server/main.lua @@ -36,6 +36,7 @@ end function getCharacters(source, callback) local identifier = GetPlayerIdentifiers(source)[1] + MySQL.Async.fetchAll('SELECT * FROM `characters` WHERE `identifier` = @identifier', { ['@identifier'] = identifier }, function(result) @@ -159,9 +160,11 @@ function setIdentity(identifier, data, callback) }) end -function updateIdentity(identifier, data, callback) +function updateIdentity(playerId, data, callback) + local xPlayer = ESX.GetPlayerFromId(playerId) + MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { - ['@identifier'] = identifier, + ['@identifier'] = xPlayer.identifier, ['@firstname'] = data.firstname, ['@lastname'] = data.lastname, ['@dateofbirth'] = data.dateofbirth, @@ -169,6 +172,9 @@ function updateIdentity(identifier, data, callback) ['@height'] = data.height }, function(rowsChanged) if callback then + xPlayer.set('firstName', data.firstname) + xPlayer.set('lastName', data.lastname) + xPlayer.setName(('%s %s'):format(data.firstname, data.lastname)) callback(true) end end) @@ -194,53 +200,69 @@ AddEventHandler('esx_identity:setIdentity', function(data, myIdentifiers) setIdentity(myIdentifiers.steamid, data, function(callback) if callback then TriggerClientEvent('esx_identity:identityCheck', myIdentifiers.playerid, true) + + local xPlayer = ESX.GetPlayerFromId(myIdentifiers.playerid) + xPlayer.set('firstName', data.firstname) + xPlayer.set('lastName', data.lastname) + xPlayer.setName(('%s %s'):format(data.firstname, data.lastname)) else - TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'Failed to set character, try again later or contact the server admin!' } }) + TriggerClientEvent('chat:addMessage', myIdentifiers.playerid, { args = { '^1[IDENTITY]', 'Failed to set character, try again later or contact the server admin!' } }) end end) end) -AddEventHandler('es:playerLoaded', function(source) +AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) local myID = { - steamid = GetPlayerIdentifiers(source)[1], - playerid = source + steamid = xPlayer.identifier, + playerid = playerId } - TriggerClientEvent('esx_identity:saveID', source, myID) - getIdentity(source, function(data) + TriggerClientEvent('esx_identity:saveID', playerId, myID) + + getIdentity(playerId, function(data) if data.firstname == '' then - TriggerClientEvent('esx_identity:identityCheck', source, false) - TriggerClientEvent('esx_identity:showRegisterIdentity', source) + TriggerClientEvent('esx_identity:identityCheck', playerId, false) + TriggerClientEvent('esx_identity:showRegisterIdentity', playerId) else - TriggerClientEvent('esx_identity:identityCheck', source, true) + TriggerClientEvent('esx_identity:identityCheck', playerId, true) + + xPlayer.set('firstName', data.firstname) + xPlayer.set('lastName', data.lastname) + xPlayer.setName(('%s %s'):format(data.firstname, data.lastname)) end end) end) +-- Set all the client side variables for connected users one new time AddEventHandler('onResourceStart', function(resource) if resource == GetCurrentResourceName() then Citizen.Wait(3000) + local xPlayers = ESX.GetPlayers() - -- Set all the client side variables for connected users one new time - local xPlayers, xPlayer = ESX.GetPlayers() for i=1, #xPlayers, 1 do - xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) - local myID = { - steamid = xPlayer.identifier, - playerid = xPlayer.source - } + if xPlayer then + local myID = { + steamid = xPlayer.identifier, + playerid = xPlayer.source + } + + TriggerClientEvent('esx_identity:saveID', xPlayer.source, myID) + + getIdentity(xPlayer.source, function(data) + if data.firstname == '' then + TriggerClientEvent('esx_identity:identityCheck', xPlayer.source, false) + TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) + else + TriggerClientEvent('esx_identity:identityCheck', xPlayer.source, true) - TriggerClientEvent('esx_identity:saveID', xPlayer.source, myID) - - getIdentity(xPlayer.source, function(data) - if data.firstname == '' then - TriggerClientEvent('esx_identity:identityCheck', xPlayer.source, false) - TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) - else - TriggerClientEvent('esx_identity:identityCheck', xPlayer.source, true) - end - end) + xPlayer.set('firstName', data.firstname) + xPlayer.set('lastName', data.lastname) + xPlayer.setName(('%s %s'):format(data.firstname, data.lastname)) + end + end) + end end end end) @@ -248,9 +270,9 @@ end) TriggerEvent('es:addCommand', 'register', function(source, args, user) getCharacters(source, function(data) if data.firstname3 ~= '' then - TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'You can only have 3 registered characters. Use the ^3/chardel^0 command in order to delete existing characters.' } }) + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You can only have 3 registered characters. Use the ^3/chardel^0 command in order to delete existing characters.' } }) else - TriggerClientEvent('esx_identity:showRegisterIdentity', source, {}) + TriggerClientEvent('esx_identity:showRegisterIdentity', source) end end) end, {help = "Register a new character"}) @@ -280,7 +302,7 @@ TriggerEvent('es:addGroupCommand', 'charlist', 'user', function(source, args, us end end else - TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'You have no registered characters. Use the ^3/register^0 command to register a character.' } }) + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You have no registered characters. Use the ^3/register^0 command to register a character.' } }) end end) end, function(source, args, user) @@ -291,7 +313,7 @@ TriggerEvent('es:addGroupCommand', 'charselect', 'user', function(source, args, local charNumber = tonumber(args[1]) if charNumber == nil or charNumber > 3 or charNumber < 1 then - TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'That\'s an invalid character!' } }) + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'That\'s an invalid character!' } }) return end @@ -307,7 +329,8 @@ TriggerEvent('es:addGroupCommand', 'charselect', 'user', function(source, args, } if data.firstname ~= '' then - updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + updateIdentity(source, data, function(callback) + if callback then TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Updated your active character to ^2' .. data.firstname .. ' ' .. data.lastname } }) else @@ -329,7 +352,7 @@ TriggerEvent('es:addGroupCommand', 'charselect', 'user', function(source, args, } if data.firstname ~= '' then - updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + updateIdentity(source, data, function(callback) if callback then TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Updated your active character to ^2' .. data.firstname .. ' ' .. data.lastname } }) @@ -352,7 +375,8 @@ TriggerEvent('es:addGroupCommand', 'charselect', 'user', function(source, args, } if data.firstname ~= '' then - updateIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) + updateIdentity(source, data, function(callback) + if callback then TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Updated your active character to ^2' .. data.firstname .. ' ' .. data.lastname } }) else @@ -375,7 +399,7 @@ TriggerEvent('es:addGroupCommand', 'chardel', 'user', function(source, args, use local charNumber = tonumber(args[1]) if charNumber == nil or charNumber > 3 or charNumber < 1 then - TriggerClientEvent('chat:addMessage', source, { args = { '^[IDENTITY]', 'That\'s an invalid character!' } }) + TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'That\'s an invalid character!' } }) return end From 5f4a78330b509af2b94cac058ff2a2d0057b80ac Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Wed, 15 Jan 2020 11:08:08 +0100 Subject: [PATCH 45/78] Set missing info and added new event handler --- server/main.lua | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/server/main.lua b/server/main.lua index d3112b89..27c243c2 100644 --- a/server/main.lua +++ b/server/main.lua @@ -172,9 +172,7 @@ function updateIdentity(playerId, data, callback) ['@height'] = data.height }, function(rowsChanged) if callback then - xPlayer.set('firstName', data.firstname) - xPlayer.set('lastName', data.lastname) - xPlayer.setName(('%s %s'):format(data.firstname, data.lastname)) + TriggerEvent('esx_identity:characterUpdated', playerId, data) callback(true) end end) @@ -200,11 +198,7 @@ AddEventHandler('esx_identity:setIdentity', function(data, myIdentifiers) setIdentity(myIdentifiers.steamid, data, function(callback) if callback then TriggerClientEvent('esx_identity:identityCheck', myIdentifiers.playerid, true) - - local xPlayer = ESX.GetPlayerFromId(myIdentifiers.playerid) - xPlayer.set('firstName', data.firstname) - xPlayer.set('lastName', data.lastname) - xPlayer.setName(('%s %s'):format(data.firstname, data.lastname)) + TriggerEvent('esx_identity:characterUpdated', myIdentifiers.playerid, data) else TriggerClientEvent('chat:addMessage', myIdentifiers.playerid, { args = { '^1[IDENTITY]', 'Failed to set character, try again later or contact the server admin!' } }) end @@ -225,14 +219,24 @@ AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) TriggerClientEvent('esx_identity:showRegisterIdentity', playerId) else TriggerClientEvent('esx_identity:identityCheck', playerId, true) - - xPlayer.set('firstName', data.firstname) - xPlayer.set('lastName', data.lastname) - xPlayer.setName(('%s %s'):format(data.firstname, data.lastname)) + TriggerEvent('esx_identity:characterUpdated', playerId, data) end end) end) +AddEventHandler('esx_identity:characterUpdated', function(playerId, data) + local xPlayer = ESX.GetPlayerFromId(playerId) + + if xPlayer then + xPlayer.setName(('%s %s'):format(data.firstname, data.lastname)) + xPlayer.set('firstName', data.firstname) + xPlayer.set('lastName', data.lastname) + xPlayer.set('dateofbirth', data.dateofbirth) + xPlayer.set('sex', data.sex) + xPlayer.set('height', data.height) + end +end) + -- Set all the client side variables for connected users one new time AddEventHandler('onResourceStart', function(resource) if resource == GetCurrentResourceName() then @@ -256,10 +260,7 @@ AddEventHandler('onResourceStart', function(resource) TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) else TriggerClientEvent('esx_identity:identityCheck', xPlayer.source, true) - - xPlayer.set('firstName', data.firstname) - xPlayer.set('lastName', data.lastname) - xPlayer.setName(('%s %s'):format(data.firstname, data.lastname)) + TriggerEvent('esx_identity:characterUpdated', xPlayer.source, data) end end) end From 322ecdcb8565450cf886692a3f2cdd997f511010 Mon Sep 17 00:00:00 2001 From: rex2630 Date: Sun, 19 Jan 2020 17:05:28 +0100 Subject: [PATCH 46/78] Replace __resource.lua with fxmanifest.lua --- __resource.lua => fxmanifest.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename __resource.lua => fxmanifest.lua (77%) diff --git a/__resource.lua b/fxmanifest.lua similarity index 77% rename from __resource.lua rename to fxmanifest.lua index 07f5c207..fdf64c89 100644 --- a/__resource.lua +++ b/fxmanifest.lua @@ -1,4 +1,6 @@ -resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' +fx_version 'adamant' + +game 'gta5' description 'ESX Identity' @@ -23,4 +25,4 @@ files { 'html/style.css' } -dependency 'es_extended' \ No newline at end of file +dependency 'es_extended' From 66b14d2300db2b664a13e1af74d885c50c97a324 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Wed, 19 Feb 2020 13:37:25 -0600 Subject: [PATCH 47/78] Update ESX Identity For The New ESX (#61) * Update ESX Identity For New ESX Updated ESX Identity For The New ESX - Added locales - Added ESX.RegisterCommand support - Removed Multiple Characters * Update main.lua --- client/main.lua | 2 +- config.lua | 3 + esx_identity.sql | 14 +- fxmanifest.lua | 8 +- locales/en.lua | 11 ++ server/main.lua | 362 +++++------------------------------------------ 6 files changed, 56 insertions(+), 344 deletions(-) create mode 100644 config.lua create mode 100644 locales/en.lua diff --git a/client/main.lua b/client/main.lua index 9b1f08f0..791f84f7 100644 --- a/client/main.lua +++ b/client/main.lua @@ -52,7 +52,7 @@ RegisterNUICallback('escape', function(data, cb) if hasIdentity then EnableGui(false) else - TriggerEvent('chat:addMessage', { args = { '^1[IDENTITY]', '^1You must create your first character in order to play' } }) + ESX.ShowNotification(_U('create_a_character')) end end) diff --git a/config.lua b/config.lua new file mode 100644 index 00000000..aaec53d7 --- /dev/null +++ b/config.lua @@ -0,0 +1,3 @@ +Config = {} + +Config.Locale = 'en' \ No newline at end of file diff --git a/esx_identity.sql b/esx_identity.sql index 42d5c152..e6a39cc3 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -6,16 +6,4 @@ ALTER TABLE `users` ADD COLUMN `dateofbirth` VARCHAR(25) NULL DEFAULT '', ADD COLUMN `sex` VARCHAR(10) NULL DEFAULT '', ADD COLUMN `height` VARCHAR(5) NULL DEFAULT '' -; - -CREATE TABLE `characters` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `identifier` VARCHAR(255) NOT NULL, - `firstname` VARCHAR(255) NOT NULL, - `lastname` VARCHAR(255) NOT NULL, - `dateofbirth` VARCHAR(255) NOT NULL, - `sex` VARCHAR(1) NOT NULL DEFAULT 'M', - `height` VARCHAR(128) NOT NULL, - - PRIMARY KEY (`id`) -); \ No newline at end of file +; \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index fdf64c89..55dd13ec 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,16 +4,20 @@ game 'gta5' description 'ESX Identity' -version '1.1.0' +version '1.2.0' server_scripts { - '@mysql-async/lib/MySQL.lua', '@es_extended/locale.lua', + '@mysql-async/lib/MySQL.lua', + 'locales/en.lua', + 'config.lua', 'server/main.lua' } client_scripts { '@es_extended/locale.lua', + 'locales/en.lua', + 'config.lua', 'client/main.lua' } diff --git a/locales/en.lua b/locales/en.lua new file mode 100644 index 00000000..99a27f34 --- /dev/null +++ b/locales/en.lua @@ -0,0 +1,11 @@ +Locales['en'] = { + ['show_registration'] = 'Show Registration Menu', + ['show_active_character'] = 'Show Active Character', + ['delete_character'] = 'Delete Your Character And Create A New One', + ['deleted_character'] = 'Your character has been deleted.', + ['not_registered'] = 'You do not have a character reistered.', + ['active_character'] = '~b~Active Character:~s~ %s %s', + ['already_registered'] = 'You already have a character registered.', + ['failed_identity'] = 'Failed to set your character, try again later or contact the server admin!', + ['create_a_character'] = 'You have to create a character in order to play.' +} \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index 27c243c2..f96f4495 100644 --- a/server/main.lua +++ b/server/main.lua @@ -3,10 +3,10 @@ ESX = nil TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) function getIdentity(source, callback) - local identifier = GetPlayerIdentifiers(source)[1] + local xPlayer = ESX.GetPlayerFromId(source) MySQL.Async.fetchAll('SELECT identifier, firstname, lastname, dateofbirth, sex, height FROM `users` WHERE `identifier` = @identifier', { - ['@identifier'] = identifier + ['@identifier'] = xPlayer.identifier }, function(result) if result[1].firstname ~= nil then local data = { @@ -34,108 +34,6 @@ function getIdentity(source, callback) end) end -function getCharacters(source, callback) - local identifier = GetPlayerIdentifiers(source)[1] - - MySQL.Async.fetchAll('SELECT * FROM `characters` WHERE `identifier` = @identifier', { - ['@identifier'] = identifier - }, function(result) - if result[1] and result[2] and result[3] then - - local data = { - identifier = result[1].identifier, - firstname1 = result[1].firstname, - lastname1 = result[1].lastname, - dateofbirth1 = result[1].dateofbirth, - sex1 = result[1].sex, - height1 = result[1].height, - firstname2 = result[2].firstname, - lastname2 = result[2].lastname, - dateofbirth2 = result[2].dateofbirth, - sex2 = result[2].sex, - height2 = result[2].height, - firstname3 = result[3].firstname, - lastname3 = result[3].lastname, - dateofbirth3 = result[3].dateofbirth, - sex3 = result[3].sex, - height3 = result[3].height - } - - callback(data) - - elseif result[1] and result[2] and not result[3] then - - local data = { - identifier = result[1].identifier, - firstname1 = result[1].firstname, - lastname1 = result[1].lastname, - dateofbirth1 = result[1].dateofbirth, - sex1 = result[1].sex, - height1 = result[1].height, - firstname2 = result[2].firstname, - lastname2 = result[2].lastname, - dateofbirth2 = result[2].dateofbirth, - sex2 = result[2].sex, - height2 = result[2].height, - firstname3 = '', - lastname3 = '', - dateofbirth3 = '', - sex3 = '', - height3 = '' - } - - callback(data) - - elseif result[1] and not result[2] and not result[3] then - - local data = { - identifier = result[1].identifier, - firstname1 = result[1].firstname, - lastname1 = result[1].lastname, - dateofbirth1 = result[1].dateofbirth, - sex1 = result[1].sex, - height1 = result[1].height, - firstname2 = '', - lastname2 = '', - dateofbirth2 = '', - sex2 = '', - height2 = '', - firstname3 = '', - lastname3 = '', - dateofbirth3 = '', - sex3 = '', - height3 = '' - } - - callback(data) - - else - - local data = { - identifier = '', - firstname1 = '', - lastname1 = '', - dateofbirth1 = '', - sex1 = '', - height1 = '', - firstname2 = '', - lastname2 = '', - dateofbirth2 = '', - sex2 = '', - height2 = '', - firstname3 = '', - lastname3 = '', - dateofbirth3 = '', - sex3 = '', - height3 = '' - } - - callback(data) - - end - end) -end - function setIdentity(identifier, data, callback) MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { ['@identifier'] = identifier, @@ -149,15 +47,6 @@ function setIdentity(identifier, data, callback) callback(true) end end) - - MySQL.Async.execute('INSERT INTO characters (identifier, firstname, lastname, dateofbirth, sex, height) VALUES (@identifier, @firstname, @lastname, @dateofbirth, @sex, @height)', { - ['@identifier'] = identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }) end function updateIdentity(playerId, data, callback) @@ -178,29 +67,28 @@ function updateIdentity(playerId, data, callback) end) end -function deleteIdentity(identifier, data, callback) - MySQL.Async.execute('DELETE FROM `characters` WHERE identifier = @identifier AND firstname = @firstname AND lastname = @lastname AND dateofbirth = @dateofbirth AND sex = @sex AND height = @height', { - ['@identifier'] = identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }, function(rowsChanged) - if callback then - callback(true) - end - end) +function deleteIdentity(source) + local xPlayer = ESX.GetPlayerFromId(source) + + MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { + ['@identifier'] = xPlayer.identifier, + ['@firstname'] = '', + ['@lastname'] = '', + ['@dateofbirth'] = '', + ['@sex'] = '', + ['@height'] = '', + }) end RegisterServerEvent('esx_identity:setIdentity') AddEventHandler('esx_identity:setIdentity', function(data, myIdentifiers) + local xPlayer = ESX.GetPlayerFromId(source) setIdentity(myIdentifiers.steamid, data, function(callback) if callback then TriggerClientEvent('esx_identity:identityCheck', myIdentifiers.playerid, true) TriggerEvent('esx_identity:characterUpdated', myIdentifiers.playerid, data) else - TriggerClientEvent('chat:addMessage', myIdentifiers.playerid, { args = { '^1[IDENTITY]', 'Failed to set character, try again later or contact the server admin!' } }) + xPlayer.showNotification(_U('failed_identity')) end end) end) @@ -268,216 +156,34 @@ AddEventHandler('onResourceStart', function(resource) end end) -TriggerEvent('es:addCommand', 'register', function(source, args, user) - getCharacters(source, function(data) - if data.firstname3 ~= '' then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You can only have 3 registered characters. Use the ^3/chardel^0 command in order to delete existing characters.' } }) +ESX.RegisterCommand('register', 'user', function(xPlayer, args, showError) + getIdentity(xPlayer.source, function(data) + if data.firstname ~= '' then + xPlayer.showNotification(_U('already_registered')) else - TriggerClientEvent('esx_identity:showRegisterIdentity', source) + TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) end end) -end, {help = "Register a new character"}) +end, false, {help = _U('show_registration')}) -TriggerEvent('es:addGroupCommand', 'char', 'user', function(source, args, user) - getIdentity(source, function(data) +ESX.RegisterCommand('char', 'user', function(xPlayer, args, showError) + getIdentity(xPlayer.source, function(data) if data.firstname == '' then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You do not have an active character!' } }) + xPlayer.showNotification(_U('not_registered')) else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Active character: ^2' .. data.firstname .. ' ' .. data.lastname } }) + xPlayer.showNotification(_U('active_character', data.firstname, data.lastname)) end end) -end, function(source, args, user) - TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient permissions!' } }) -end, {help = "List your current character"}) +end, false, {help = _U('show_active_character')}) -TriggerEvent('es:addGroupCommand', 'charlist', 'user', function(source, args, user) - getCharacters(source, function(data) - if data.firstname1 ~= '' then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY] Character 1:', data.firstname1 .. ' ' .. data.lastname1 } }) - - if data.firstname2 ~= '' then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY] Character 2:', data.firstname2 .. ' ' .. data.lastname2 } }) - - if data.firstname3 ~= '' then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY] Character 3:', data.firstname3 .. ' ' .. data.lastname3 } }) - end - end +ESX.RegisterCommand('chardel', 'user', function(xPlayer, args, showError) + getIdentity(xPlayer.source, function(data) + if data.firstname == '' then + xPlayer.showNotification(_U('not_registered')) else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You have no registered characters. Use the ^3/register^0 command to register a character.' } }) + deleteIdentity(xPlayer.source) + xPlayer.showNotification(_U('deleted_character')) + TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) end end) -end, function(source, args, user) - TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient permissions!' } }) -end, {help = "List all your registered characters"}) - -TriggerEvent('es:addGroupCommand', 'charselect', 'user', function(source, args, user) - local charNumber = tonumber(args[1]) - - if charNumber == nil or charNumber > 3 or charNumber < 1 then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'That\'s an invalid character!' } }) - return - end - - getCharacters(source, function(data) - if charNumber == 1 then - local data = { - identifier = data.identifier, - firstname = data.firstname1, - lastname = data.lastname1, - dateofbirth = data.dateofbirth1, - sex = data.sex1, - height = data.height1 - } - - if data.firstname ~= '' then - updateIdentity(source, data, function(callback) - - if callback then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Updated your active character to ^2' .. data.firstname .. ' ' .. data.lastname } }) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to update your identity, try again later or contact the server admin!' } }) - end - end) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 1!' } }) - end - elseif charNumber == 2 then - - local data = { - identifier = data.identifier, - firstname = data.firstname2, - lastname = data.lastname2, - dateofbirth = data.dateofbirth2, - sex = data.sex2, - height = data.height2 - } - - if data.firstname ~= '' then - updateIdentity(source, data, function(callback) - - if callback then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Updated your active character to ^2' .. data.firstname .. ' ' .. data.lastname } }) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to update your identity, try again later or contact the server admin!' } }) - end - end) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 2!' } }) - end - elseif charNumber == 3 then - - local data = { - identifier = data.identifier, - firstname = data.firstname3, - lastname = data.lastname3, - dateofbirth = data.dateofbirth3, - sex = data.sex3, - height = data.height3 - } - - if data.firstname ~= '' then - updateIdentity(source, data, function(callback) - - if callback then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Updated your active character to ^2' .. data.firstname .. ' ' .. data.lastname } }) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to update your identity, try again later or contact the server admin!' } }) - end - end) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 3!' } }) - end - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to update your identity, try again later or contact the server admin!' } }) - end - - end) -end, function(source, args, user) - TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient permissions!' } }) -end, {help = "Switch between character", params = {{name = "char", help = "the character id, ranges from 1-3"}}}) - -TriggerEvent('es:addGroupCommand', 'chardel', 'user', function(source, args, user) - local charNumber = tonumber(args[1]) - - if charNumber == nil or charNumber > 3 or charNumber < 1 then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'That\'s an invalid character!' } }) - return - end - - getCharacters(source, function(data) - - if charNumber == 1 then - - local data = { - identifier = data.identifier, - firstname = data.firstname1, - lastname = data.lastname1, - dateofbirth = data.dateofbirth1, - sex = data.sex1, - height = data.height1 - } - - if data.firstname ~= '' then - deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You have deleted ^1' .. data.firstname .. ' ' .. data.lastname } }) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to delete the character, try again later or contact the server admin!' } }) - end - end) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 1!' } }) - end - - elseif charNumber == 2 then - - local data = { - identifier = data.identifier, - firstname = data.firstname2, - lastname = data.lastname2, - dateofbirth = data.dateofbirth2, - sex = data.sex2, - height = data.height2 - } - - if data.firstname ~= '' then - deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You have deleted ^1' .. data.firstname .. ' ' .. data.lastname } }) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to delete the character, try again later or contact the server admin!' } }) - end - end) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 2!' } }) - end - - elseif charNumber == 3 then - - local data = { - identifier = data.identifier, - firstname = data.firstname3, - lastname = data.lastname3, - dateofbirth = data.dateofbirth3, - sex = data.sex3, - height = data.height3 - } - - if data.firstname ~= '' then - deleteIdentity(GetPlayerIdentifiers(source)[1], data, function(callback) - if callback then - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You have deleted ^1' .. data.firstname .. ' ' .. data.lastname } }) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to delete the character, try again later or contact the server admin!' } }) - end - end) - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'You don\'t have a character in slot 3!' } }) - end - else - TriggerClientEvent('chat:addMessage', source, { args = { '^1[IDENTITY]', 'Failed to delete the character, try again!' } }) - end - end) -end, function(source, args, user) - TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient permissions!' } }) -end, {help = "Delete a registered character", params = {{name = "char", help = "the character id, ranges from 1-3"}}}) +end, false, {help = _U('delete_character')}) \ No newline at end of file From 133f21190631e0fb1e21c350f9f722c524de8924 Mon Sep 17 00:00:00 2001 From: rex2630 Date: Fri, 21 Feb 2020 10:15:53 +0100 Subject: [PATCH 48/78] Added czech locale + Minor changes (#62) * Fixed upper case * Added czech locale * Update fxmanifest.lua * Minor cleanup * Added czech UI * Fixed name --- client/main.lua | 7 ++----- fxmanifest.lua | 2 ++ html/cs_index.html | 22 ++++++++++++++++++++++ locales/cs.lua | 11 +++++++++++ locales/en.lua | 20 ++++++++++---------- 5 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 html/cs_index.html create mode 100644 locales/cs.lua diff --git a/client/main.lua b/client/main.lua index 791f84f7..45d474e8 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,8 +1,5 @@ -local guiEnabled = false -local myIdentity = {} -local myIdentifiers = {} -local hasIdentity = false -local isDead = false +local guiEnabled, hasIdentity, isDead = false, false, false +local myIdentity, myIdentifiers = {}, {} ESX = nil diff --git a/fxmanifest.lua b/fxmanifest.lua index 55dd13ec..256ab072 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -10,6 +10,7 @@ server_scripts { '@es_extended/locale.lua', '@mysql-async/lib/MySQL.lua', 'locales/en.lua', + 'locales/cs.lua', 'config.lua', 'server/main.lua' } @@ -17,6 +18,7 @@ server_scripts { client_scripts { '@es_extended/locale.lua', 'locales/en.lua', + 'locales/cs.lua', 'config.lua', 'client/main.lua' } diff --git a/html/cs_index.html b/html/cs_index.html new file mode 100644 index 00000000..1dd357a9 --- /dev/null +++ b/html/cs_index.html @@ -0,0 +1,22 @@ + + + + + + + +
+
+

Register

+
+
+
+
+ Male + Female
+ +
+
+ + + diff --git a/locales/cs.lua b/locales/cs.lua new file mode 100644 index 00000000..80c6a267 --- /dev/null +++ b/locales/cs.lua @@ -0,0 +1,11 @@ +Locales['cs'] = { + ['show_registration'] = 'zobrazit registracni menu', + ['show_active_character'] = 'zobrazit aktivni postavy', + ['delete_character'] = 'smazat svou stavajici postavu a vytvorit novou', + ['deleted_character'] = 'vase postava byla smazana.', + ['not_registered'] = 'nemas zaregistrovanou postavu.', + ['active_character'] = '~b~aktivni postava:~s~ %s %s', + ['already_registered'] = 'jiz mas zaregistrovanou postavu.', + ['failed_identity'] = 'nastaveni vasi postavy selhalo, zkus to prosim znovu pozdeji nebo kontaktuj majitele serveru!', + ['create_a_character'] = 'aby jsi mohl/a hrat, tak se musis registrovat.' +} diff --git a/locales/en.lua b/locales/en.lua index 99a27f34..53fac161 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,11 +1,11 @@ Locales['en'] = { - ['show_registration'] = 'Show Registration Menu', - ['show_active_character'] = 'Show Active Character', - ['delete_character'] = 'Delete Your Character And Create A New One', - ['deleted_character'] = 'Your character has been deleted.', - ['not_registered'] = 'You do not have a character reistered.', - ['active_character'] = '~b~Active Character:~s~ %s %s', - ['already_registered'] = 'You already have a character registered.', - ['failed_identity'] = 'Failed to set your character, try again later or contact the server admin!', - ['create_a_character'] = 'You have to create a character in order to play.' -} \ No newline at end of file + ['show_registration'] = 'show Registration Menu', + ['show_active_character'] = 'show Active Character', + ['delete_character'] = 'delete Your Character And Create A New One', + ['deleted_character'] = 'your character has been deleted.', + ['not_registered'] = 'you do not have a character reistered.', + ['active_character'] = '~b~active Character:~s~ %s %s', + ['already_registered'] = 'you already have a character registered.', + ['failed_identity'] = 'failed to set your character, try again later or contact the server admin!', + ['create_a_character'] = 'you have to create a character in order to play.' +} From c67e4b96c1eea94a2502e9d462605faa8289ccb9 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Mon, 6 Apr 2020 08:38:00 -0500 Subject: [PATCH 49/78] Update ESX Identity --- README.md | 8 - client/main.lua | 167 -------------------- config.lua | 11 +- esx_identity.sql | 10 +- fxmanifest.lua | 18 +-- html/cs_index.html | 22 --- html/fi_index.html | 22 --- html/index.html | 22 --- html/ko_index.html | 22 --- html/script.js | 33 ---- html/style.css | 46 ------ html/sv_index.html | 22 --- locales/cs.lua | 12 +- locales/en.lua | 12 +- server/main.lua | 373 +++++++++++++++++++++++++-------------------- 15 files changed, 225 insertions(+), 575 deletions(-) delete mode 100644 client/main.lua delete mode 100644 html/cs_index.html delete mode 100644 html/fi_index.html delete mode 100644 html/index.html delete mode 100644 html/ko_index.html delete mode 100644 html/script.js delete mode 100644 html/style.css delete mode 100644 html/sv_index.html diff --git a/README.md b/README.md index c2edec3f..cec80b0c 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,6 @@ start esx_identity - If you are using esx_policejob or esx_society, you need to enable the following in the scripts' `config.lua`: ```Config.EnableESXIdentity = true``` -### Commands -``` -/register -/charlist -/charselect -/chardel -``` - # Legal ### License esx_identity - rp characters diff --git a/client/main.lua b/client/main.lua deleted file mode 100644 index 45d474e8..00000000 --- a/client/main.lua +++ /dev/null @@ -1,167 +0,0 @@ -local guiEnabled, hasIdentity, isDead = false, false, false -local myIdentity, myIdentifiers = {}, {} - -ESX = nil - -Citizen.CreateThread(function() - while ESX == nil do - TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) - Citizen.Wait(0) - end -end) - -AddEventHandler('esx:onPlayerDeath', function(data) - isDead = true -end) - -AddEventHandler('playerSpawned', function(spawn) - isDead = false -end) - -function EnableGui(state) - SetNuiFocus(state, state) - guiEnabled = state - - SendNUIMessage({ - type = "enableui", - enable = state - }) -end - -RegisterNetEvent('esx_identity:showRegisterIdentity') -AddEventHandler('esx_identity:showRegisterIdentity', function() - if not isDead then - EnableGui(true) - end -end) - -RegisterNetEvent('esx_identity:identityCheck') -AddEventHandler('esx_identity:identityCheck', function(identityCheck) - hasIdentity = identityCheck -end) - -RegisterNetEvent('esx_identity:saveID') -AddEventHandler('esx_identity:saveID', function(data) - myIdentifiers = data -end) - -RegisterNUICallback('escape', function(data, cb) - if hasIdentity then - EnableGui(false) - else - ESX.ShowNotification(_U('create_a_character')) - end -end) - -RegisterNUICallback('register', function(data, cb) - local reason = "" - myIdentity = data - for theData, value in pairs(myIdentity) do - if theData == "firstname" or theData == "lastname" then - reason = verifyName(value) - - if reason ~= "" then - break - end - elseif theData == "dateofbirth" then - if value == "invalid" then - reason = "Invalid date of birth!" - break - end - elseif theData == "height" then - local height = tonumber(value) - if height then - if height > 200 or height < 140 then - reason = "Unacceptable player height!" - break - end - else - reason = "Unacceptable player height!" - break - end - end - end - - if reason == "" then - TriggerServerEvent('esx_identity:setIdentity', data, myIdentifiers) - EnableGui(false) - Citizen.Wait(500) - TriggerEvent('esx_skin:openSaveableMenu', myIdentifiers.id) - else - ESX.ShowNotification(reason) - end -end) - -Citizen.CreateThread(function() - while true do - Citizen.Wait(0) - - if guiEnabled then - DisableControlAction(0, 1, true) -- LookLeftRight - DisableControlAction(0, 2, true) -- LookUpDown - DisableControlAction(0, 106, true) -- VehicleMouseControlOverride - DisableControlAction(0, 142, true) -- MeleeAttackAlternate - DisableControlAction(0, 30, true) -- MoveLeftRight - DisableControlAction(0, 31, true) -- MoveUpDown - DisableControlAction(0, 21, true) -- disable sprint - DisableControlAction(0, 24, true) -- disable attack - DisableControlAction(0, 25, true) -- disable aim - DisableControlAction(0, 47, true) -- disable weapon - DisableControlAction(0, 58, true) -- disable weapon - DisableControlAction(0, 263, true) -- disable melee - DisableControlAction(0, 264, true) -- disable melee - DisableControlAction(0, 257, true) -- disable melee - DisableControlAction(0, 140, true) -- disable melee - DisableControlAction(0, 141, true) -- disable melee - DisableControlAction(0, 143, true) -- disable melee - DisableControlAction(0, 75, true) -- disable exit vehicle - DisableControlAction(27, 75, true) -- disable exit vehicle - else - Citizen.Wait(500) - end - end -end) - -function verifyName(name) - -- Don't allow short user names - local nameLength = string.len(name) - if nameLength > 25 or nameLength < 2 then - return 'Your player name is either too short or too long.' - end - - -- Don't allow special characters (doesn't always work) - local count = 0 - for i in name:gmatch('[abcdefghijklmnopqrstuvwxyzåäöABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ0123456789 -]') do - count = count + 1 - end - if count ~= nameLength then - return 'Your player name contains special characters that are not allowed on this server.' - end - - -- Does the player carry a first and last name? - -- - -- Example: - -- Allowed: 'Bob Joe' - -- Not allowed: 'Bob' - -- Not allowed: 'Bob joe' - local spacesInName = 0 - local spacesWithUpper = 0 - for word in string.gmatch(name, '%S+') do - - if string.match(word, '%u') then - spacesWithUpper = spacesWithUpper + 1 - end - - spacesInName = spacesInName + 1 - end - - if spacesInName > 2 then - return 'Your name contains more than two spaces' - end - - if spacesWithUpper ~= spacesInName then - return 'your name must start with a capital letter.' - end - - return '' -end diff --git a/config.lua b/config.lua index aaec53d7..4266ca75 100644 --- a/config.lua +++ b/config.lua @@ -1,3 +1,8 @@ -Config = {} - -Config.Locale = 'en' \ No newline at end of file +Config = {} +Config.Locale = 'en' +Config.StartingAccountMoney = {bank = 50000} +Config.MinHeight = 24 -- Minimum Height +Config.MaxHeight = 96 -- Maximum Height +Config.HighestYear = 2020 -- The highest year that can be used in date of birth +Config.LowestYear = 1900 -- The lowest year that can be used in date of birth +Config.MaxNameLength = 15 -- You must also change the SQL structure for 'firstname' and 'lastname' in the `users` table \ No newline at end of file diff --git a/esx_identity.sql b/esx_identity.sql index e6a39cc3..b8eeb2ee 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -1,9 +1,9 @@ USE `essentialmode`; ALTER TABLE `users` - ADD COLUMN `firstname` VARCHAR(50) NULL DEFAULT '', - ADD COLUMN `lastname` VARCHAR(50) NULL DEFAULT '', - ADD COLUMN `dateofbirth` VARCHAR(25) NULL DEFAULT '', - ADD COLUMN `sex` VARCHAR(10) NULL DEFAULT '', - ADD COLUMN `height` VARCHAR(5) NULL DEFAULT '' + ADD COLUMN `firstname` VARCHAR(15) NULL DEFAULT NULL, + ADD COLUMN `lastname` VARCHAR(15) NULL DEFAULT NULL, + ADD COLUMN `dateofbirth` VARCHAR(10) NULL DEFAULT NULL, + ADD COLUMN `sex` VARCHAR(1) NULL DEFAULT NULL, + ADD COLUMN `height` VARCHAR(3) NULL DEFAULT NULL ; \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index 256ab072..4917c8cb 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,7 +4,7 @@ game 'gta5' description 'ESX Identity' -version '1.2.0' +version '1.3.0' server_scripts { '@es_extended/locale.lua', @@ -15,20 +15,4 @@ server_scripts { 'server/main.lua' } -client_scripts { - '@es_extended/locale.lua', - 'locales/en.lua', - 'locales/cs.lua', - 'config.lua', - 'client/main.lua' -} - -ui_page 'html/index.html' - -files { - 'html/index.html', - 'html/script.js', - 'html/style.css' -} - dependency 'es_extended' diff --git a/html/cs_index.html b/html/cs_index.html deleted file mode 100644 index 1dd357a9..00000000 --- a/html/cs_index.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - -
-
-

Register

-
-
-
-
- Male - Female
- -
-
- - - diff --git a/html/fi_index.html b/html/fi_index.html deleted file mode 100644 index 87ca250a..00000000 --- a/html/fi_index.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - -
-
-

Rekistöröinti

-
-
-
-
- Mies - Nainen
- -
-
- - - diff --git a/html/index.html b/html/index.html deleted file mode 100644 index 6fc5dfc7..00000000 --- a/html/index.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - -
-
-

Register

-
-
-
-
- Male - Female
- -
-
- - - diff --git a/html/ko_index.html b/html/ko_index.html deleted file mode 100644 index c04fe9b7..00000000 --- a/html/ko_index.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - -
-
-

등록

-
-
-
-
- 남자 - 여자
- -
-
- - - \ No newline at end of file diff --git a/html/script.js b/html/script.js deleted file mode 100644 index b4d4d5b4..00000000 --- a/html/script.js +++ /dev/null @@ -1,33 +0,0 @@ -$(function() { - window.addEventListener('message', function(event) { - if (event.data.type == "enableui") { - document.body.style.display = event.data.enable ? "block" : "none"; - } - }); - - document.onkeyup = function (data) { - if (data.which == 27) { // Escape key - $.post('http://esx_identity/escape', JSON.stringify({})); - } - }; - - $("#register").submit(function(event) { - event.preventDefault(); // Prevent form from submitting - - // Verify date - var date = $("#dateofbirth").val(); - var dateCheck = new Date($("#dateofbirth").val()); - - if (dateCheck == "Invalid Date") { - date == "invalid"; - } - - $.post('http://esx_identity/register', JSON.stringify({ - firstname: $("#firstname").val(), - lastname: $("#lastname").val(), - dateofbirth: date, - sex: $("input[type='radio'][name='sex']:checked").val(), - height: $("#height").val() - })); - }); -}); diff --git a/html/style.css b/html/style.css deleted file mode 100644 index 79a6b347..00000000 --- a/html/style.css +++ /dev/null @@ -1,46 +0,0 @@ -body { - font-family: sans-serif; - overflow: hidden; - display: none; -} - -.dialog { - width: 300px; - position: absolute; - margin-left: auto; - margin-right: auto; - left: 0; - right: 0; - padding: 10px; - box-shadow: 0px 0px 50px 0px #000; - background-color: #f1f1f1; - overflow: hidden; - opacity: 0.9; -} - -input[type=text] { - width: 100%; - padding: 7px; - text-align: center; -} - -button { - display: block; - margin-top: 5px; - padding: 10px; - background-color: #506be6; - border: 0; - color: #fff; - width: 100%; -} - -h1 { - display: block; - margin-top: 5px; - margin-right: 5px; - padding: 10px; - background-color: #506be6; - color: #fff; - width: 93%; - text-align: center; -} \ No newline at end of file diff --git a/html/sv_index.html b/html/sv_index.html deleted file mode 100644 index 7706c17b..00000000 --- a/html/sv_index.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - -
-
-

Registrera

-
-
-
-
- Man - Kvinna
- -
-
- - - diff --git a/locales/cs.lua b/locales/cs.lua index 80c6a267..f32a8888 100644 --- a/locales/cs.lua +++ b/locales/cs.lua @@ -1,11 +1,5 @@ Locales['cs'] = { - ['show_registration'] = 'zobrazit registracni menu', - ['show_active_character'] = 'zobrazit aktivni postavy', - ['delete_character'] = 'smazat svou stavajici postavu a vytvorit novou', - ['deleted_character'] = 'vase postava byla smazana.', - ['not_registered'] = 'nemas zaregistrovanou postavu.', - ['active_character'] = '~b~aktivni postava:~s~ %s %s', - ['already_registered'] = 'jiz mas zaregistrovanou postavu.', - ['failed_identity'] = 'nastaveni vasi postavy selhalo, zkus to prosim znovu pozdeji nebo kontaktuj majitele serveru!', - ['create_a_character'] = 'aby jsi mohl/a hrat, tak se musis registrovat.' + ['data_incorrect'] = 'Data byla zadána nesprávně. Prosím zkuste to znovu.', + ['invalid_format'] = 'Data byla nesprávně naformátována. Prosím zkuste to znovu.', + ['no_identifiers'] = '[Chyba] Nelze najít identifikátory.' } diff --git a/locales/en.lua b/locales/en.lua index 53fac161..8ab2f5b2 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,11 +1,5 @@ Locales['en'] = { - ['show_registration'] = 'show Registration Menu', - ['show_active_character'] = 'show Active Character', - ['delete_character'] = 'delete Your Character And Create A New One', - ['deleted_character'] = 'your character has been deleted.', - ['not_registered'] = 'you do not have a character reistered.', - ['active_character'] = '~b~active Character:~s~ %s %s', - ['already_registered'] = 'you already have a character registered.', - ['failed_identity'] = 'failed to set your character, try again later or contact the server admin!', - ['create_a_character'] = 'you have to create a character in order to play.' + ['data_incorrect'] = 'Data entered incorrectly. Please try again.', + ['invalid_format'] = 'Data formatted incorrectly. Please try again.', + ['no_identifiers'] = '[Error] Could not find identifiers.' } diff --git a/server/main.lua b/server/main.lua index f96f4495..01215420 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,189 +1,226 @@ ESX = nil +local registered = false +local data = { + firstName, + lastName, + dateOfBirth, + sex, + height +} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -function getIdentity(source, callback) - local xPlayer = ESX.GetPlayerFromId(source) +AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) + local player = source + local identifiers = GetPlayerIdentifiers(player) + local identifier + deferrals.defer() - MySQL.Async.fetchAll('SELECT identifier, firstname, lastname, dateofbirth, sex, height FROM `users` WHERE `identifier` = @identifier', { - ['@identifier'] = xPlayer.identifier - }, function(result) - if result[1].firstname ~= nil then - local data = { - identifier = result[1].identifier, - firstname = result[1].firstname, - lastname = result[1].lastname, - dateofbirth = result[1].dateofbirth, - sex = result[1].sex, - height = result[1].height - } + Citizen.Wait(0) - callback(data) - else - local data = { - identifier = '', - firstname = '', - lastname = '', - dateofbirth = '', - sex = '', - height = '' - } + for k, v in pairs(identifiers) do + if string.match(v, 'license:') then + identifier = string.sub(v, 9) + break + end + end - callback(data) - end - end) -end + Citizen.Wait(0) + + if identifier then + MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM `users` WHERE `identifier` = @identifier', { + ['@identifier'] = identifier + }, function(result) + if result[1] then + if result[1].firstname ~= nil then + data = { + firstName = result[1].firstname, + lastName = result[1].lastname, + dateOfBirth = result[1.].dateofbirth, + sex = result[1].sex, + height = result[1].height + } + end + end + end) -function setIdentity(identifier, data, callback) - MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { - ['@identifier'] = identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }, function(rowsChanged) - if callback then - callback(true) - end - end) -end - -function updateIdentity(playerId, data, callback) - local xPlayer = ESX.GetPlayerFromId(playerId) - - MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { - ['@identifier'] = xPlayer.identifier, - ['@firstname'] = data.firstname, - ['@lastname'] = data.lastname, - ['@dateofbirth'] = data.dateofbirth, - ['@sex'] = data.sex, - ['@height'] = data.height - }, function(rowsChanged) - if callback then - TriggerEvent('esx_identity:characterUpdated', playerId, data) - callback(true) - end - end) -end - -function deleteIdentity(source) - local xPlayer = ESX.GetPlayerFromId(source) - - MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { - ['@identifier'] = xPlayer.identifier, - ['@firstname'] = '', - ['@lastname'] = '', - ['@dateofbirth'] = '', - ['@sex'] = '', - ['@height'] = '', - }) -end - -RegisterServerEvent('esx_identity:setIdentity') -AddEventHandler('esx_identity:setIdentity', function(data, myIdentifiers) - local xPlayer = ESX.GetPlayerFromId(source) - setIdentity(myIdentifiers.steamid, data, function(callback) - if callback then - TriggerClientEvent('esx_identity:identityCheck', myIdentifiers.playerid, true) - TriggerEvent('esx_identity:characterUpdated', myIdentifiers.playerid, data) - else - xPlayer.showNotification(_U('failed_identity')) - end - end) + Citizen.Wait(500) + if data.firstName ~= nil then + registered = true + deferrals.done() + else + deferrals.presentCard([==[{"type": "AdaptiveCard", "body": [{ "type": "ColumnSet", "columns": [{ "type": "Column", "items": [ + { "type": "Input.Text", "placeholder": "First Name (Max 15 Characters)", "id": "firstname" }], "width": "stretch" }]}, + { "type": "Input.Text", "placeholder": "Last Name (Max 15 Characters)", "id": "lastname" }, + { "type": "Input.Text", "placeholder": "Height (24-96 Inches)", "id": "height" }, + { "type": "Input.Date", "id": "dateofbirth" }, + { "type": "Input.ChoiceSet", "placeholder": "Sex", "choices": [{ "title": "Male", "value": "m" }, { "title": "Female", "value": "f" }], "style": "expanded", "value": "m", "id": "sex" }], + "actions": [{ "type": "Action.Submit", "title": "Submit" }], + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "version": "1.0" + }]==], function(submittedData, rawData) + if submittedData.firstname == "" or submittedData.lastname == "" or submittedData.dateofbirth == "" or submittedData.sex == "" or submittedData.height == "" then + deferrals.done(_U('data_incorrect')) + else + if checkNameFormat(submittedData.firstname) and checkNameFormat(submittedData.lastname) and checkDOBFormat(submittedData.dateofbirth) and checkSexFormat(submittedData.sex) and checkHeightFormat(submittedData.height) then + local formattedFirstName = formatName(submittedData.firstname) + local formattedLastName = formatName(submittedData.lastname) + local formattedHeight = tonumber(submittedData.height) + data = { + firstName = formattedFirstName, + lastName = formattedLastName, + dateOfBirth = submittedData.dateofbirth, + sex = submittedData.sex, + height = formattedHeight + } + Citizen.Wait(500) + deferrals.done() + else + deferrals.done(_U('invalid_format')) + end + end + end) + end + else + deferrals.done(_U('no_identifiers')) + end end) -AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) - local myID = { - steamid = xPlayer.identifier, - playerid = playerId - } +RegisterServerEvent('esx:onPlayerSpawn') +AddEventHandler('esx:onPlayerSpawn', function() + local playerId = source + local xPlayer = ESX.GetPlayerFromId(playerId) - TriggerClientEvent('esx_identity:saveID', playerId, myID) + Citizen.Wait(4000) + + if xPlayer then + xPlayer.setName(('%s %s'):format(data.firstName, data.lastName)) + xPlayer.set('firstName', data.firstName) + xPlayer.set('lastName', data.lastName) + xPlayer.set('dateofbirth', data.dateOfBirth) + xPlayer.set('sex', data.sex) + xPlayer.set('height', data.height) + end - getIdentity(playerId, function(data) - if data.firstname == '' then - TriggerClientEvent('esx_identity:identityCheck', playerId, false) - TriggerClientEvent('esx_identity:showRegisterIdentity', playerId) - else - TriggerClientEvent('esx_identity:identityCheck', playerId, true) - TriggerEvent('esx_identity:characterUpdated', playerId, data) - end - end) + if not registered then + registered = true + SetIdentity(xPlayer.identifier, data.firstName, data.lastName, data.dateOfBirth, data.sex, data.height) + end end) -AddEventHandler('esx_identity:characterUpdated', function(playerId, data) - local xPlayer = ESX.GetPlayerFromId(playerId) - if xPlayer then - xPlayer.setName(('%s %s'):format(data.firstname, data.lastname)) - xPlayer.set('firstName', data.firstname) - xPlayer.set('lastName', data.lastname) - xPlayer.set('dateofbirth', data.dateofbirth) - xPlayer.set('sex', data.sex) - xPlayer.set('height', data.height) - end -end) +function checkNameFormat(name) + if checkAlphanumeric(name) == nil then + if checkForNumbers(name) == nil then + local stringLength = string.len(name) + if stringLength > 0 and stringLength < Config.MaxNameLength then + return true + else + return false + end + else + return false + end + else + return false + end +end --- Set all the client side variables for connected users one new time -AddEventHandler('onResourceStart', function(resource) - if resource == GetCurrentResourceName() then - Citizen.Wait(3000) - local xPlayers = ESX.GetPlayers() +function checkDOBFormat(dob) + local date = tostring(dob) + if checkDate(date) == true then + return true + else + return false + end +end - for i=1, #xPlayers, 1 do - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) +function checkSexFormat(sex) + if sex == "m" or sex == "M" or sex == "f" or sex == "F" then + return true + else + return false + end +end - if xPlayer then - local myID = { - steamid = xPlayer.identifier, - playerid = xPlayer.source - } - - TriggerClientEvent('esx_identity:saveID', xPlayer.source, myID) - - getIdentity(xPlayer.source, function(data) - if data.firstname == '' then - TriggerClientEvent('esx_identity:identityCheck', xPlayer.source, false) - TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) - else - TriggerClientEvent('esx_identity:identityCheck', xPlayer.source, true) - TriggerEvent('esx_identity:characterUpdated', xPlayer.source, data) - end - end) - end - end - end -end) +function checkHeightFormat(height) + local numHeight = tonumber(height) + if numHeight < Config.MinHeight and numHeight > Config.MaxHeight then + return false + else + return true + end +end -ESX.RegisterCommand('register', 'user', function(xPlayer, args, showError) - getIdentity(xPlayer.source, function(data) - if data.firstname ~= '' then - xPlayer.showNotification(_U('already_registered')) - else - TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) - end - end) -end, false, {help = _U('show_registration')}) +function formatName(name) + local loweredName = convertToLowerCase(name) + local formattedName = convertFirstLetterToUpper(loweredName) + return formattedName +end -ESX.RegisterCommand('char', 'user', function(xPlayer, args, showError) - getIdentity(xPlayer.source, function(data) - if data.firstname == '' then - xPlayer.showNotification(_U('not_registered')) - else - xPlayer.showNotification(_U('active_character', data.firstname, data.lastname)) - end - end) -end, false, {help = _U('show_active_character')}) +function convertToLowerCase(str) + return string.lower(str) +end -ESX.RegisterCommand('chardel', 'user', function(xPlayer, args, showError) - getIdentity(xPlayer.source, function(data) - if data.firstname == '' then - xPlayer.showNotification(_U('not_registered')) - else - deleteIdentity(xPlayer.source) - xPlayer.showNotification(_U('deleted_character')) - TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) - end - end) -end, false, {help = _U('delete_character')}) \ No newline at end of file +function convertFirstLetterToUpper(str) + return str:gsub("^%l", string.upper) +end + +function checkAlphanumeric(str) + return (string.match(str, "%W")) +end + +function checkForNumbers(str) + return (string.match(str,"%d")) +end + +function checkDate(str) + if string.match(str, '(%d%d%d%d)-(%d%d)-(%d%d)') ~= nil then + local y, m, d = string.match(str, '(%d+)-(%d+)-(%d+)') + y = tonumber(y) + m = tonumber(m) + d = tonumber(d) + if ((d <= 0) or (d > 31)) or ((m <= 0) or (m > 12)) or ((y <= Config.LowestYear) or (y > Config.HighestYear)) then + return false + elseif m == 4 or m == 6 or m == 9 or m == 11 then + if d > 30 then + return false + else + return true + end + elseif m == 2 then + if y%400 == 0 or (y%100 ~= 0 and y%4 == 0) then + if d > 29 then + return false + else + return true + end + else + if d > 28 then + return false + else + return true + end + end + else + if d > 31 then + return false + else + return true + end + end + else + return false + end +end + +function SetIdentity(identifier, firstName, lastName, dateOfBirth, sex, height) + MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { + ['@identifier'] = identifier, + ['@firstname'] = firstName, + ['@lastname'] = lastName, + ['@dateofbirth'] = dateOfBirth, + ['@sex'] = sex, + ['@height'] = height + }) +end \ No newline at end of file From bfb6e3631a52769c5d29ad2eccc19ab048a4839f Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Mon, 6 Apr 2020 09:09:19 -0500 Subject: [PATCH 50/78] Update ESX Identity --- server/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/main.lua b/server/main.lua index 01215420..4293b824 100644 --- a/server/main.lua +++ b/server/main.lua @@ -86,8 +86,8 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) end end) -RegisterServerEvent('esx:onPlayerSpawn') -AddEventHandler('esx:onPlayerSpawn', function() +RegisterServerEvent('esx:playerLoaded') +AddEventHandler('esx:playerLoaded', function() local playerId = source local xPlayer = ESX.GetPlayerFromId(playerId) From fb3f24827692e736c6fac129253f6c95711d3017 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Mon, 6 Apr 2020 10:12:05 -0500 Subject: [PATCH 51/78] Update main.lua --- server/main.lua | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/server/main.lua b/server/main.lua index 4293b824..d9e54b79 100644 --- a/server/main.lua +++ b/server/main.lua @@ -45,6 +45,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) end) Citizen.Wait(500) + if data.firstName ~= nil then registered = true deferrals.done() @@ -73,7 +74,6 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) sex = submittedData.sex, height = formattedHeight } - Citizen.Wait(500) deferrals.done() else deferrals.done(_U('invalid_format')) @@ -87,12 +87,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) end) RegisterServerEvent('esx:playerLoaded') -AddEventHandler('esx:playerLoaded', function() - local playerId = source - local xPlayer = ESX.GetPlayerFromId(playerId) - - Citizen.Wait(4000) - +AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) if xPlayer then xPlayer.setName(('%s %s'):format(data.firstName, data.lastName)) xPlayer.set('firstName', data.firstName) From 6c1bcd330bbbc60517c38921b65afb84cbb1f55d Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Mon, 6 Apr 2020 10:14:55 -0500 Subject: [PATCH 52/78] Fix Indent For Locales --- locales/cs.lua | 6 +++--- locales/en.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/locales/cs.lua b/locales/cs.lua index f32a8888..e7d2ed38 100644 --- a/locales/cs.lua +++ b/locales/cs.lua @@ -1,5 +1,5 @@ Locales['cs'] = { - ['data_incorrect'] = 'Data byla zadána nesprávně. Prosím zkuste to znovu.', - ['invalid_format'] = 'Data byla nesprávně naformátována. Prosím zkuste to znovu.', - ['no_identifiers'] = '[Chyba] Nelze najít identifikátory.' + ['data_incorrect'] = 'Data byla zadána nesprávně. Prosím zkuste to znovu.', + ['invalid_format'] = 'Data byla nesprávně naformátována. Prosím zkuste to znovu.', + ['no_identifiers'] = '[Chyba] Nelze najít identifikátory.' } diff --git a/locales/en.lua b/locales/en.lua index 8ab2f5b2..64237849 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,5 +1,5 @@ Locales['en'] = { - ['data_incorrect'] = 'Data entered incorrectly. Please try again.', - ['invalid_format'] = 'Data formatted incorrectly. Please try again.', - ['no_identifiers'] = '[Error] Could not find identifiers.' + ['data_incorrect'] = 'Data entered incorrectly. Please try again.', + ['invalid_format'] = 'Data formatted incorrectly. Please try again.', + ['no_identifiers'] = '[Error] Could not find identifiers.' } From ab15b64fad0b933e53f6b291e83c807d5093642d Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Mon, 6 Apr 2020 10:29:04 -0500 Subject: [PATCH 53/78] Update main.lua --- server/main.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/server/main.lua b/server/main.lua index d9e54b79..77eb011a 100644 --- a/server/main.lua +++ b/server/main.lua @@ -32,7 +32,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) ['@identifier'] = identifier }, function(result) if result[1] then - if result[1].firstname ~= nil then + if result[1].firstname then data = { firstName = result[1].firstname, lastName = result[1].lastname, @@ -46,7 +46,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) Citizen.Wait(500) - if data.firstName ~= nil then + if data.firstName then registered = true deferrals.done() else @@ -88,14 +88,12 @@ end) RegisterServerEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) - if xPlayer then - xPlayer.setName(('%s %s'):format(data.firstName, data.lastName)) - xPlayer.set('firstName', data.firstName) - xPlayer.set('lastName', data.lastName) - xPlayer.set('dateofbirth', data.dateOfBirth) - xPlayer.set('sex', data.sex) - xPlayer.set('height', data.height) - end + xPlayer.setName(('%s %s'):format(data.firstName, data.lastName)) + xPlayer.set('firstName', data.firstName) + xPlayer.set('lastName', data.lastName) + xPlayer.set('dateofbirth', data.dateOfBirth) + xPlayer.set('sex', data.sex) + xPlayer.set('height', data.height) if not registered then registered = true From ea3a450576ec1c06f6449a1f1b1219efdfe4b9a1 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Mon, 6 Apr 2020 11:25:25 -0500 Subject: [PATCH 54/78] Fix error, removed unused config --- config.lua | 1 - server/main.lua | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/config.lua b/config.lua index 4266ca75..96b0472d 100644 --- a/config.lua +++ b/config.lua @@ -1,6 +1,5 @@ Config = {} Config.Locale = 'en' -Config.StartingAccountMoney = {bank = 50000} Config.MinHeight = 24 -- Minimum Height Config.MaxHeight = 96 -- Maximum Height Config.HighestYear = 2020 -- The highest year that can be used in date of birth diff --git a/server/main.lua b/server/main.lua index 77eb011a..5aed770a 100644 --- a/server/main.lua +++ b/server/main.lua @@ -36,7 +36,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) data = { firstName = result[1].firstname, lastName = result[1].lastname, - dateOfBirth = result[1.].dateofbirth, + dateOfBirth = result[1].dateofbirth, sex = result[1].sex, height = result[1].height } @@ -86,7 +86,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) end end) -RegisterServerEvent('esx:playerLoaded') +RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) xPlayer.setName(('%s %s'):format(data.firstName, data.lastName)) xPlayer.set('firstName', data.firstName) From b34b08eee3ad613991335fd93452967ec8d7f1e6 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Mon, 6 Apr 2020 11:29:04 -0500 Subject: [PATCH 55/78] Update main.lua --- server/main.lua | 332 ++++++++++++++++++++++++------------------------ 1 file changed, 166 insertions(+), 166 deletions(-) diff --git a/server/main.lua b/server/main.lua index 5aed770a..d0569c9b 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,219 +1,219 @@ ESX = nil local registered = false local data = { - firstName, - lastName, - dateOfBirth, - sex, - height + firstName, + lastName, + dateOfBirth, + sex, + height } TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) - local player = source - local identifiers = GetPlayerIdentifiers(player) - local identifier - deferrals.defer() + local player = source + local identifiers = GetPlayerIdentifiers(player) + local identifier + deferrals.defer() - Citizen.Wait(0) + Citizen.Wait(0) - for k, v in pairs(identifiers) do - if string.match(v, 'license:') then - identifier = string.sub(v, 9) - break - end - end + for k, v in pairs(identifiers) do + if string.match(v, 'license:') then + identifier = string.sub(v, 9) + break + end + end - Citizen.Wait(0) - - if identifier then - MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM `users` WHERE `identifier` = @identifier', { - ['@identifier'] = identifier - }, function(result) - if result[1] then - if result[1].firstname then - data = { - firstName = result[1].firstname, - lastName = result[1].lastname, - dateOfBirth = result[1].dateofbirth, - sex = result[1].sex, - height = result[1].height - } - end - end - end) + Citizen.Wait(0) + + if identifier then + MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM `users` WHERE `identifier` = @identifier', { + ['@identifier'] = identifier + }, function(result) + if result[1] then + if result[1].firstname then + data = { + firstName = result[1].firstname, + lastName = result[1].lastname, + dateOfBirth = result[1].dateofbirth, + sex = result[1].sex, + height = result[1].height + } + end + end + end) - Citizen.Wait(500) + Citizen.Wait(500) - if data.firstName then - registered = true - deferrals.done() - else - deferrals.presentCard([==[{"type": "AdaptiveCard", "body": [{ "type": "ColumnSet", "columns": [{ "type": "Column", "items": [ - { "type": "Input.Text", "placeholder": "First Name (Max 15 Characters)", "id": "firstname" }], "width": "stretch" }]}, - { "type": "Input.Text", "placeholder": "Last Name (Max 15 Characters)", "id": "lastname" }, - { "type": "Input.Text", "placeholder": "Height (24-96 Inches)", "id": "height" }, - { "type": "Input.Date", "id": "dateofbirth" }, - { "type": "Input.ChoiceSet", "placeholder": "Sex", "choices": [{ "title": "Male", "value": "m" }, { "title": "Female", "value": "f" }], "style": "expanded", "value": "m", "id": "sex" }], - "actions": [{ "type": "Action.Submit", "title": "Submit" }], - "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", - "version": "1.0" - }]==], function(submittedData, rawData) - if submittedData.firstname == "" or submittedData.lastname == "" or submittedData.dateofbirth == "" or submittedData.sex == "" or submittedData.height == "" then - deferrals.done(_U('data_incorrect')) - else - if checkNameFormat(submittedData.firstname) and checkNameFormat(submittedData.lastname) and checkDOBFormat(submittedData.dateofbirth) and checkSexFormat(submittedData.sex) and checkHeightFormat(submittedData.height) then - local formattedFirstName = formatName(submittedData.firstname) - local formattedLastName = formatName(submittedData.lastname) - local formattedHeight = tonumber(submittedData.height) - data = { - firstName = formattedFirstName, - lastName = formattedLastName, - dateOfBirth = submittedData.dateofbirth, - sex = submittedData.sex, - height = formattedHeight - } - deferrals.done() - else - deferrals.done(_U('invalid_format')) - end - end - end) - end - else - deferrals.done(_U('no_identifiers')) - end + if data.firstName then + registered = true + deferrals.done() + else + deferrals.presentCard([==[{"type": "AdaptiveCard", "body": [{ "type": "ColumnSet", "columns": [{ "type": "Column", "items": [ + { "type": "Input.Text", "placeholder": "First Name (Max 15 Characters)", "id": "firstname" }], "width": "stretch" }]}, + { "type": "Input.Text", "placeholder": "Last Name (Max 15 Characters)", "id": "lastname" }, + { "type": "Input.Text", "placeholder": "Height (24-96 Inches)", "id": "height" }, + { "type": "Input.Date", "id": "dateofbirth" }, + { "type": "Input.ChoiceSet", "placeholder": "Sex", "choices": [{ "title": "Male", "value": "m" }, { "title": "Female", "value": "f" }], "style": "expanded", "value": "m", "id": "sex" }], + "actions": [{ "type": "Action.Submit", "title": "Submit" }], + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "version": "1.0" + }]==], function(submittedData, rawData) + if submittedData.firstname == "" or submittedData.lastname == "" or submittedData.dateofbirth == "" or submittedData.sex == "" or submittedData.height == "" then + deferrals.done(_U('data_incorrect')) + else + if checkNameFormat(submittedData.firstname) and checkNameFormat(submittedData.lastname) and checkDOBFormat(submittedData.dateofbirth) and checkSexFormat(submittedData.sex) and checkHeightFormat(submittedData.height) then + local formattedFirstName = formatName(submittedData.firstname) + local formattedLastName = formatName(submittedData.lastname) + local formattedHeight = tonumber(submittedData.height) + data = { + firstName = formattedFirstName, + lastName = formattedLastName, + dateOfBirth = submittedData.dateofbirth, + sex = submittedData.sex, + height = formattedHeight + } + deferrals.done() + else + deferrals.done(_U('invalid_format')) + end + end + end) + end + else + deferrals.done(_U('no_identifiers')) + end end) RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) - xPlayer.setName(('%s %s'):format(data.firstName, data.lastName)) - xPlayer.set('firstName', data.firstName) - xPlayer.set('lastName', data.lastName) - xPlayer.set('dateofbirth', data.dateOfBirth) - xPlayer.set('sex', data.sex) - xPlayer.set('height', data.height) + xPlayer.setName(('%s %s'):format(data.firstName, data.lastName)) + xPlayer.set('firstName', data.firstName) + xPlayer.set('lastName', data.lastName) + xPlayer.set('dateofbirth', data.dateOfBirth) + xPlayer.set('sex', data.sex) + xPlayer.set('height', data.height) - if not registered then - registered = true - SetIdentity(xPlayer.identifier, data.firstName, data.lastName, data.dateOfBirth, data.sex, data.height) - end + if not registered then + registered = true + SetIdentity(xPlayer.identifier, data.firstName, data.lastName, data.dateOfBirth, data.sex, data.height) + end end) function checkNameFormat(name) - if checkAlphanumeric(name) == nil then - if checkForNumbers(name) == nil then - local stringLength = string.len(name) - if stringLength > 0 and stringLength < Config.MaxNameLength then - return true - else - return false - end - else - return false - end - else - return false - end + if checkAlphanumeric(name) == nil then + if checkForNumbers(name) == nil then + local stringLength = string.len(name) + if stringLength > 0 and stringLength < Config.MaxNameLength then + return true + else + return false + end + else + return false + end + else + return false + end end function checkDOBFormat(dob) - local date = tostring(dob) - if checkDate(date) == true then - return true - else - return false - end + local date = tostring(dob) + if checkDate(date) == true then + return true + else + return false + end end function checkSexFormat(sex) - if sex == "m" or sex == "M" or sex == "f" or sex == "F" then - return true - else - return false - end + if sex == "m" or sex == "M" or sex == "f" or sex == "F" then + return true + else + return false + end end function checkHeightFormat(height) - local numHeight = tonumber(height) - if numHeight < Config.MinHeight and numHeight > Config.MaxHeight then - return false - else - return true - end + local numHeight = tonumber(height) + if numHeight < Config.MinHeight and numHeight > Config.MaxHeight then + return false + else + return true + end end function formatName(name) - local loweredName = convertToLowerCase(name) - local formattedName = convertFirstLetterToUpper(loweredName) - return formattedName + local loweredName = convertToLowerCase(name) + local formattedName = convertFirstLetterToUpper(loweredName) + return formattedName end function convertToLowerCase(str) - return string.lower(str) + return string.lower(str) end function convertFirstLetterToUpper(str) - return str:gsub("^%l", string.upper) + return str:gsub("^%l", string.upper) end function checkAlphanumeric(str) - return (string.match(str, "%W")) + return (string.match(str, "%W")) end function checkForNumbers(str) - return (string.match(str,"%d")) + return (string.match(str,"%d")) end function checkDate(str) - if string.match(str, '(%d%d%d%d)-(%d%d)-(%d%d)') ~= nil then - local y, m, d = string.match(str, '(%d+)-(%d+)-(%d+)') - y = tonumber(y) - m = tonumber(m) - d = tonumber(d) - if ((d <= 0) or (d > 31)) or ((m <= 0) or (m > 12)) or ((y <= Config.LowestYear) or (y > Config.HighestYear)) then - return false - elseif m == 4 or m == 6 or m == 9 or m == 11 then - if d > 30 then - return false - else - return true - end - elseif m == 2 then - if y%400 == 0 or (y%100 ~= 0 and y%4 == 0) then - if d > 29 then - return false - else - return true - end - else - if d > 28 then - return false - else - return true - end - end - else - if d > 31 then - return false - else - return true - end - end - else - return false - end + if string.match(str, '(%d%d%d%d)-(%d%d)-(%d%d)') ~= nil then + local y, m, d = string.match(str, '(%d+)-(%d+)-(%d+)') + y = tonumber(y) + m = tonumber(m) + d = tonumber(d) + if ((d <= 0) or (d > 31)) or ((m <= 0) or (m > 12)) or ((y <= Config.LowestYear) or (y > Config.HighestYear)) then + return false + elseif m == 4 or m == 6 or m == 9 or m == 11 then + if d > 30 then + return false + else + return true + end + elseif m == 2 then + if y%400 == 0 or (y%100 ~= 0 and y%4 == 0) then + if d > 29 then + return false + else + return true + end + else + if d > 28 then + return false + else + return true + end + end + else + if d > 31 then + return false + else + return true + end + end + else + return false + end end function SetIdentity(identifier, firstName, lastName, dateOfBirth, sex, height) - MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { - ['@identifier'] = identifier, - ['@firstname'] = firstName, - ['@lastname'] = lastName, - ['@dateofbirth'] = dateOfBirth, - ['@sex'] = sex, - ['@height'] = height - }) + MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { + ['@identifier'] = identifier, + ['@firstname'] = firstName, + ['@lastname'] = lastName, + ['@dateofbirth'] = dateOfBirth, + ['@sex'] = sex, + ['@height'] = height + }) end \ No newline at end of file From 3b4fd6b2f2d8b6787dae7344afdf5882e0eba574 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Mon, 6 Apr 2020 12:48:49 -0500 Subject: [PATCH 56/78] Update ESX Identity ( tempVariable) --- server/main.lua | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/server/main.lua b/server/main.lua index d0569c9b..19e0e03e 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,12 +1,6 @@ -ESX = nil -local registered = false -local data = { - firstName, - lastName, - dateOfBirth, - sex, - height -} +ESX = nil +local registered = false +local tempIdentity = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) @@ -33,12 +27,12 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) }, function(result) if result[1] then if result[1].firstname then - data = { + tempIdentity[identifier] = { firstName = result[1].firstname, lastName = result[1].lastname, dateOfBirth = result[1].dateofbirth, sex = result[1].sex, - height = result[1].height + height = result[1].height } end end @@ -46,7 +40,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) Citizen.Wait(500) - if data.firstName then + if tempIdentity[identifier] and tempIdentity[identifier].firstName then registered = true deferrals.done() else @@ -67,7 +61,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) local formattedFirstName = formatName(submittedData.firstname) local formattedLastName = formatName(submittedData.lastname) local formattedHeight = tonumber(submittedData.height) - data = { + tempIdentity[identifier] = { firstName = formattedFirstName, lastName = formattedLastName, dateOfBirth = submittedData.dateofbirth, @@ -88,16 +82,18 @@ end) RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) - xPlayer.setName(('%s %s'):format(data.firstName, data.lastName)) - xPlayer.set('firstName', data.firstName) - xPlayer.set('lastName', data.lastName) - xPlayer.set('dateofbirth', data.dateOfBirth) - xPlayer.set('sex', data.sex) - xPlayer.set('height', data.height) + xPlayer.setName(('%s %s'):format(tempIdentity[xPlayer.identifier].firstName, tempIdentity[xPlayer.identifier].lastName)) + xPlayer.set('firstName', tempIdentity[xPlayer.identifier].firstName) + xPlayer.set('lastName', tempIdentity[xPlayer.identifier].lastName) + xPlayer.set('dateofbirth', tempIdentity[xPlayer.identifier].dateOfBirth) + xPlayer.set('sex', tempIdentity[xPlayer.identifier].sex) + xPlayer.set('height', tempIdentity[xPlayer.identifier].height) if not registered then registered = true - SetIdentity(xPlayer.identifier, data.firstName, data.lastName, data.dateOfBirth, data.sex, data.height) + SetIdentity(xPlayer.identifier, tempIdentity[xPlayer.identifier].firstName, tempIdentity[xPlayer.identifier].lastName, tempIdentity[xPlayer.identifier].dateOfBirth, tempIdentity[xPlayer.identifier].sex, tempIdentity[xPlayer.identifier].height) + else + tempIdentity[xPlayer.identifier] = nil end end) @@ -208,7 +204,7 @@ function checkDate(str) end function SetIdentity(identifier, firstName, lastName, dateOfBirth, sex, height) - MySQL.Async.execute('UPDATE `users` SET `firstname` = @firstname, `lastname` = @lastname, `dateofbirth` = @dateofbirth, `sex` = @sex, `height` = @height WHERE identifier = @identifier', { + MySQL.Async.execute('UPDATE `users` SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', { ['@identifier'] = identifier, ['@firstname'] = firstName, ['@lastname'] = lastName, @@ -216,4 +212,6 @@ function SetIdentity(identifier, firstName, lastName, dateOfBirth, sex, height) ['@sex'] = sex, ['@height'] = height }) + + tempIdentity[identifier] = nil end \ No newline at end of file From 2c557591b138ddf2b05d2a23da292fc5fc718f2f Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Mon, 6 Apr 2020 12:51:19 -0500 Subject: [PATCH 57/78] Update main.lua --- server/main.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/main.lua b/server/main.lua index 19e0e03e..f195e228 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,6 +1,6 @@ -ESX = nil -local registered = false -local tempIdentity = {} +ESX = nil +local registered = false +local tempIdentity = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) From 54534f196278fe0495d718aeaeea19bbcff33463 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Mon, 6 Apr 2020 13:06:04 -0500 Subject: [PATCH 58/78] Fix spacing --- server/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/main.lua b/server/main.lua index f195e228..6e3e2099 100644 --- a/server/main.lua +++ b/server/main.lua @@ -22,7 +22,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) Citizen.Wait(0) if identifier then - MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM `users` WHERE `identifier` = @identifier', { + MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { ['@identifier'] = identifier }, function(result) if result[1] then @@ -204,7 +204,7 @@ function checkDate(str) end function SetIdentity(identifier, firstName, lastName, dateOfBirth, sex, height) - MySQL.Async.execute('UPDATE `users` SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', { + MySQL.Async.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', { ['@identifier'] = identifier, ['@firstname'] = firstName, ['@lastname'] = lastName, From 028af54c31ce556bd90c62d29cbae650f3066bf7 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 7 Apr 2020 11:14:53 -0500 Subject: [PATCH 59/78] Update main.lua --- server/main.lua | 52 +++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/server/main.lua b/server/main.lua index 6e3e2099..447cec78 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,5 +1,4 @@ ESX = nil -local registered = false local tempIdentity = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) @@ -32,7 +31,8 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) lastName = result[1].lastname, dateOfBirth = result[1].dateofbirth, sex = result[1].sex, - height = result[1].height + height = result[1].height, + registered = false } end end @@ -41,7 +41,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) Citizen.Wait(500) if tempIdentity[identifier] and tempIdentity[identifier].firstName then - registered = true + tempIdentity[identifier].registered = true deferrals.done() else deferrals.presentCard([==[{"type": "AdaptiveCard", "body": [{ "type": "ColumnSet", "columns": [{ "type": "Column", "items": [ @@ -82,25 +82,27 @@ end) RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) - xPlayer.setName(('%s %s'):format(tempIdentity[xPlayer.identifier].firstName, tempIdentity[xPlayer.identifier].lastName)) - xPlayer.set('firstName', tempIdentity[xPlayer.identifier].firstName) - xPlayer.set('lastName', tempIdentity[xPlayer.identifier].lastName) - xPlayer.set('dateofbirth', tempIdentity[xPlayer.identifier].dateOfBirth) - xPlayer.set('sex', tempIdentity[xPlayer.identifier].sex) - xPlayer.set('height', tempIdentity[xPlayer.identifier].height) - - if not registered then - registered = true - SetIdentity(xPlayer.identifier, tempIdentity[xPlayer.identifier].firstName, tempIdentity[xPlayer.identifier].lastName, tempIdentity[xPlayer.identifier].dateOfBirth, tempIdentity[xPlayer.identifier].sex, tempIdentity[xPlayer.identifier].height) - else - tempIdentity[xPlayer.identifier] = nil + if tempIdentity[xPlayer.identifier] then + local currentIdentity = tempIdentity[xPlayer.identifier] + xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName)) + xPlayer.set('firstName', currentIdentity.firstName) + xPlayer.set('lastName', currentIdentity.lastName) + xPlayer.set('dateofbirth', currentIdentity.dateOfBirth) + xPlayer.set('sex', currentIdentity.sex) + xPlayer.set('height', currentIdentity.height) + if not currentIdentity.registered then + currentIdentity.registered = true + SetIdentity(xPlayer.identifier, currentIdentity) + else + tempIdentity[xPlayer.identifier] = nil + end end end) function checkNameFormat(name) - if checkAlphanumeric(name) == nil then - if checkForNumbers(name) == nil then + if not checkAlphanumeric(name) then + if not checkForNumbers(name) then local stringLength = string.len(name) if stringLength > 0 and stringLength < Config.MaxNameLength then return true @@ -117,7 +119,7 @@ end function checkDOBFormat(dob) local date = tostring(dob) - if checkDate(date) == true then + if not checkDate(date) then return true else return false @@ -203,15 +205,15 @@ function checkDate(str) end end -function SetIdentity(identifier, firstName, lastName, dateOfBirth, sex, height) +function SetIdentity(identifier, identity) MySQL.Async.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', { ['@identifier'] = identifier, - ['@firstname'] = firstName, - ['@lastname'] = lastName, - ['@dateofbirth'] = dateOfBirth, - ['@sex'] = sex, - ['@height'] = height + ['@firstname'] = identity.firstName, + ['@lastname'] = identity.lastName, + ['@dateofbirth'] = identity.dateOfBirth, + ['@sex'] = identity.sex, + ['@height'] = identity.height }) tempIdentity[identifier] = nil -end \ No newline at end of file +end From d69c1e0d8b91c3f16944634cf5baffbe780823c4 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 7 Apr 2020 14:57:07 -0500 Subject: [PATCH 60/78] Update main.lua --- server/main.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/main.lua b/server/main.lua index 447cec78..e64b525a 100644 --- a/server/main.lua +++ b/server/main.lua @@ -9,7 +9,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) local identifier deferrals.defer() - Citizen.Wait(0) + Citizen.Wait(500) for k, v in pairs(identifiers) do if string.match(v, 'license:') then @@ -18,7 +18,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) end end - Citizen.Wait(0) + Citizen.Wait(500) if identifier then MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { @@ -66,11 +66,12 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) lastName = formattedLastName, dateOfBirth = submittedData.dateofbirth, sex = submittedData.sex, - height = formattedHeight + height = formattedHeight, + registered = false } deferrals.done() else - deferrals.done(_U('invalid_format')) + deferrals.done(_U('invalid_format') end end end) @@ -119,7 +120,7 @@ end function checkDOBFormat(dob) local date = tostring(dob) - if not checkDate(date) then + if checkDate(date) then return true else return false From 2e04fd92b996ca347d6b9d87c15e88d95acce2fd Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Tue, 7 Apr 2020 19:38:10 -0500 Subject: [PATCH 61/78] Fix errors, fixing spacing --- server/main.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/main.lua b/server/main.lua index e64b525a..b8b9dbc0 100644 --- a/server/main.lua +++ b/server/main.lua @@ -71,7 +71,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) } deferrals.done() else - deferrals.done(_U('invalid_format') + deferrals.done(_U('invalid_format')) end end end) @@ -208,12 +208,12 @@ end function SetIdentity(identifier, identity) MySQL.Async.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', { - ['@identifier'] = identifier, - ['@firstname'] = identity.firstName, - ['@lastname'] = identity.lastName, - ['@dateofbirth'] = identity.dateOfBirth, - ['@sex'] = identity.sex, - ['@height'] = identity.height + ['@identifier'] = identifier, + ['@firstname'] = identity.firstName, + ['@lastname'] = identity.lastName, + ['@dateofbirth'] = identity.dateOfBirth, + ['@sex'] = identity.sex, + ['@height'] = identity.height }) tempIdentity[identifier] = nil From f4829871adafd76d7980d711f7d7b05765ca3b83 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Tue, 14 Apr 2020 16:49:28 +0200 Subject: [PATCH 62/78] Initial improvements --- esx_identity.sql | 2 +- locales/cs.lua | 7 ++- locales/en.lua | 7 ++- server/main.lua | 144 ++++++++++++++++++++++------------------------- 4 files changed, 75 insertions(+), 85 deletions(-) diff --git a/esx_identity.sql b/esx_identity.sql index b8eeb2ee..56b88ae4 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -1,4 +1,4 @@ -USE `essentialmode`; +USE `es_extended`; ALTER TABLE `users` ADD COLUMN `firstname` VARCHAR(15) NULL DEFAULT NULL, diff --git a/locales/cs.lua b/locales/cs.lua index e7d2ed38..98172461 100644 --- a/locales/cs.lua +++ b/locales/cs.lua @@ -1,5 +1,6 @@ Locales['cs'] = { - ['data_incorrect'] = 'Data byla zadána nesprávně. Prosím zkuste to znovu.', - ['invalid_format'] = 'Data byla nesprávně naformátována. Prosím zkuste to znovu.', - ['no_identifiers'] = '[Chyba] Nelze najít identifikátory.' + ['data_incorrect'] = 'data byla zadána nesprávně. Prosím zkuste to znovu.', + ['invalid_format'] = 'data byla nesprávně naformátována. Prosím zkuste to znovu.', + ['no_identifier'] = 'there was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.', + ['missing_identity'] = 'there was an error loading your character!\nError code: identity-missing\n\nIt seems like your identity is missing, try connecting again.', } diff --git a/locales/en.lua b/locales/en.lua index 64237849..a8e381e4 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,5 +1,6 @@ Locales['en'] = { - ['data_incorrect'] = 'Data entered incorrectly. Please try again.', - ['invalid_format'] = 'Data formatted incorrectly. Please try again.', - ['no_identifiers'] = '[Error] Could not find identifiers.' + ['data_incorrect'] = 'data entered incorrectly. Please try again.', + ['invalid_format'] = 'data formatted incorrectly. Please try again.', + ['no_identifier'] = 'there was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.', + ['missing_identity'] = 'there was an error loading your character!\nError code: identity-missing\n\nIt seems like your identity is missing, try connecting again.', } diff --git a/server/main.lua b/server/main.lua index b8b9dbc0..3fbc4962 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,106 +1,96 @@ -ESX = nil -local tempIdentity = {} +ESX = nil +local playerIdentity = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) - local player = source - local identifiers = GetPlayerIdentifiers(player) - local identifier +AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) deferrals.defer() + local playerId, identifier = source + Citizen.Wait(100) - Citizen.Wait(500) - - for k, v in pairs(identifiers) do + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do if string.match(v, 'license:') then identifier = string.sub(v, 9) break end end - Citizen.Wait(500) - if identifier then MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { ['@identifier'] = identifier }, function(result) if result[1] then - if result[1].firstname then - tempIdentity[identifier] = { - firstName = result[1].firstname, - lastName = result[1].lastname, - dateOfBirth = result[1].dateofbirth, - sex = result[1].sex, - height = result[1].height, - registered = false - } - end - end - end) + playerIdentity[identifier] = { + firstName = result[1].firstname, + lastName = result[1].lastname, + dateOfBirth = result[1].dateofbirth, + sex = result[1].sex, + height = result[1].height + } - Citizen.Wait(500) - - if tempIdentity[identifier] and tempIdentity[identifier].firstName then - tempIdentity[identifier].registered = true - deferrals.done() - else - deferrals.presentCard([==[{"type": "AdaptiveCard", "body": [{ "type": "ColumnSet", "columns": [{ "type": "Column", "items": [ - { "type": "Input.Text", "placeholder": "First Name (Max 15 Characters)", "id": "firstname" }], "width": "stretch" }]}, - { "type": "Input.Text", "placeholder": "Last Name (Max 15 Characters)", "id": "lastname" }, - { "type": "Input.Text", "placeholder": "Height (24-96 Inches)", "id": "height" }, - { "type": "Input.Date", "id": "dateofbirth" }, - { "type": "Input.ChoiceSet", "placeholder": "Sex", "choices": [{ "title": "Male", "value": "m" }, { "title": "Female", "value": "f" }], "style": "expanded", "value": "m", "id": "sex" }], - "actions": [{ "type": "Action.Submit", "title": "Submit" }], - "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", - "version": "1.0" - }]==], function(submittedData, rawData) - if submittedData.firstname == "" or submittedData.lastname == "" or submittedData.dateofbirth == "" or submittedData.sex == "" or submittedData.height == "" then - deferrals.done(_U('data_incorrect')) - else - if checkNameFormat(submittedData.firstname) and checkNameFormat(submittedData.lastname) and checkDOBFormat(submittedData.dateofbirth) and checkSexFormat(submittedData.sex) and checkHeightFormat(submittedData.height) then - local formattedFirstName = formatName(submittedData.firstname) - local formattedLastName = formatName(submittedData.lastname) - local formattedHeight = tonumber(submittedData.height) - tempIdentity[identifier] = { - firstName = formattedFirstName, - lastName = formattedLastName, - dateOfBirth = submittedData.dateofbirth, - sex = submittedData.sex, - height = formattedHeight, - registered = false - } - deferrals.done() + deferrals.done() + else + deferrals.presentCard([==[{"type":"AdaptiveCard","body":[{"type":"Container","items":[{"type":"TextBlock","text":"Identity Registration","horizontalAlignment":"Center","size":"Large","weight":"Bolder"},{"type":"ColumnSet","columns":[{"type":"Column","items":[{"type":"Input.Text","placeholder":"First Name","id":"firstname","maxLength":15}],"width":"stretch"},{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Last Name","id":"lastname","maxLength":15}]}]},{"type":"ColumnSet","columns":[{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Date of Birth (YYYY-MM-DD)","id":"dateofbirth","maxLength":10}],"style":"default"},{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Height (24-96 inches)","id":"height","maxLength":2}]}]},{"type":"Input.ChoiceSet","placeholder":"Sex","choices":[{"title":"Male","value":"m"},{"title":"Female","value":"f"}],"style":"expanded","id":"sex"}],"style":"default","backgroundImage":"https://nischat.se/wp-content/uploads/Light-grey-background-1024x683.jpg"}],"actions":[{"type":"Action.Submit","title":"Submit"}],"$schema":"http://adaptivecards.io/schemas/adaptive-card.json","version":"1.0"}]==], function(data, rawData) + if + data.firstname == '' or + data.lastname == '' or + data.dateofbirth == '' or + data.sex == '' or + data.height == '' + then + deferrals.done(_U('data_incorrect')) else - deferrals.done(_U('invalid_format')) + if + checkNameFormat(data.firstname) and + checkNameFormat(data.lastname) and + checkDOBFormat(data.dateofbirth) and + checkSexFormat(data.sex) and + checkHeightFormat(data.height) + then + playerIdentity[identifier] = { + firstName = formatName(data.firstname), + lastName = formatName(data.lastname), + dateOfBirth = data.dateofbirth, + sex = data.sex, + height = tonumber(data.height), + saveToDatabase = true + } + + deferrals.done() + else + deferrals.done(_U('invalid_format')) + end end - end - end) - end + end) + end + end) else - deferrals.done(_U('no_identifiers')) + deferrals.done(_U('no_identifier')) end end) RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) - if tempIdentity[xPlayer.identifier] then - local currentIdentity = tempIdentity[xPlayer.identifier] + if playerIdentity[xPlayer.identifier] then + local currentIdentity = playerIdentity[xPlayer.identifier] + xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName)) xPlayer.set('firstName', currentIdentity.firstName) xPlayer.set('lastName', currentIdentity.lastName) xPlayer.set('dateofbirth', currentIdentity.dateOfBirth) xPlayer.set('sex', currentIdentity.sex) xPlayer.set('height', currentIdentity.height) - if not currentIdentity.registered then - currentIdentity.registered = true - SetIdentity(xPlayer.identifier, currentIdentity) - else - tempIdentity[xPlayer.identifier] = nil + + if currentIdentity.saveToDatabase then + SaveIdentityToDatabase(xPlayer.identifier, currentIdentity) end + + playerIdentity[xPlayer.identifier] = nil + else + xPlayer.kick(_('missing_identity')) end end) - function checkNameFormat(name) if not checkAlphanumeric(name) then if not checkForNumbers(name) then @@ -174,7 +164,7 @@ function checkDate(str) d = tonumber(d) if ((d <= 0) or (d > 31)) or ((m <= 0) or (m > 12)) or ((y <= Config.LowestYear) or (y > Config.HighestYear)) then return false - elseif m == 4 or m == 6 or m == 9 or m == 11 then + elseif m == 4 or m == 6 or m == 9 or m == 11 then if d > 30 then return false else @@ -194,7 +184,7 @@ function checkDate(str) return true end end - else + else if d > 31 then return false else @@ -206,15 +196,13 @@ function checkDate(str) end end -function SetIdentity(identifier, identity) - MySQL.Async.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', { +function SaveIdentityToDatabase(identifier, identity) + MySQL.Sync.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', { ['@identifier'] = identifier, - ['@firstname'] = identity.firstName, - ['@lastname'] = identity.lastName, + ['@firstname'] = identity.firstName, + ['@lastname'] = identity.lastName, ['@dateofbirth'] = identity.dateOfBirth, - ['@sex'] = identity.sex, - ['@height'] = identity.height + ['@sex'] = identity.sex, + ['@height'] = identity.height }) - - tempIdentity[identifier] = nil end From 363aeb3416b7f318bbfe5da68c50e26f28243395 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Fri, 15 May 2020 19:27:31 -0500 Subject: [PATCH 63/78] Update ESX Identity - Finalized Update For ESX Identity That Gives Access To The Deferrals Update + The two optional UI based updates. --- README.md | 6 + client/main.lua | 95 ++++ config.lua | 15 +- esx_identity.sql | 6 +- fxmanifest.lua | 19 +- html/css/style.css | 127 +++++ html/img/esx_identity.png | Bin 0 -> 14230 bytes html/index.html | 163 +++++++ html/index_heightslider.html | 163 +++++++ html/index_heighttext.html | 150 ++++++ html/index_options/index_heightslider.html | 163 +++++++ html/index_options/index_heighttext.html | 150 ++++++ html/js/script.js | 34 ++ html/localization/cs_index(outofdate).html | 22 + html/localization/fi_index(outofdate).html | 22 + html/localization/ko_index(outofdate).html | 22 + html/localization/sv_index(outofdate).html | 22 + locales/cs.lua | 13 +- locales/en.lua | 35 +- server/main.lua | 523 +++++++++++++++++---- 20 files changed, 1646 insertions(+), 104 deletions(-) create mode 100644 client/main.lua create mode 100644 html/css/style.css create mode 100644 html/img/esx_identity.png create mode 100644 html/index.html create mode 100644 html/index_heightslider.html create mode 100644 html/index_heighttext.html create mode 100644 html/index_options/index_heightslider.html create mode 100644 html/index_options/index_heighttext.html create mode 100644 html/js/script.js create mode 100644 html/localization/cs_index(outofdate).html create mode 100644 html/localization/fi_index(outofdate).html create mode 100644 html/localization/ko_index(outofdate).html create mode 100644 html/localization/sv_index(outofdate).html diff --git a/README.md b/README.md index cec80b0c..2d466b10 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,12 @@ start esx_identity - If you are using esx_policejob or esx_society, you need to enable the following in the scripts' `config.lua`: ```Config.EnableESXIdentity = true``` +### Commands +``` +/char +/chardel +``` + # Legal ### License esx_identity - rp characters diff --git a/client/main.lua b/client/main.lua new file mode 100644 index 00000000..238a485e --- /dev/null +++ b/client/main.lua @@ -0,0 +1,95 @@ +ESX = nil +local loadingScreenFinished = false + +Citizen.CreateThread(function() + while ESX == nil do + TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + Citizen.Wait(0) + end +end) + +RegisterNetEvent('esx_identity:alreadyRegistered') +AddEventHandler('esx_identity:alreadyRegistered', function() + while not loadingScreenFinished do + Citizen.Wait(100) + end + + TriggerEvent('esx_skin:playerRegistered') +end) + +AddEventHandler('esx:loadingScreenOff', function() + loadingScreenFinished = true +end) + +if not Config.UseDeferrals then + local guiEnabled, isDead = false, false + + AddEventHandler('esx:onPlayerDeath', function(data) + isDead = true + end) + + AddEventHandler('esx:onPlayerSpawn', function(spawn) + isDead = false + end) + + function EnableGui(state) + SetNuiFocus(state, state) + guiEnabled = state + + SendNUIMessage({ + type = "enableui", + enable = state + }) + end + + RegisterNetEvent('esx_identity:showRegisterIdentity') + AddEventHandler('esx_identity:showRegisterIdentity', function() + TriggerEvent('esx_skin:resetFirstSpawn') + + if not isDead then + EnableGui(true) + end + end) + + RegisterNUICallback('register', function(data, cb) + ESX.TriggerServerCallback('esx_identity:registerIdentity', function(callback) + if callback then + ESX.ShowNotification(_U('thank_you_for_registering')) + EnableGui(false) + TriggerEvent('esx_skin:playerRegistered') + else + ESX.ShowNotification(_U('registration_error')) + end + end, data) + end) + + Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + + if guiEnabled then + DisableControlAction(0, 1, true) -- LookLeftRight + DisableControlAction(0, 2, true) -- LookUpDown + DisableControlAction(0, 106, true) -- VehicleMouseControlOverride + DisableControlAction(0, 142, true) -- MeleeAttackAlternate + DisableControlAction(0, 30, true) -- MoveLeftRight + DisableControlAction(0, 31, true) -- MoveUpDown + DisableControlAction(0, 21, true) -- disable sprint + DisableControlAction(0, 24, true) -- disable attack + DisableControlAction(0, 25, true) -- disable aim + DisableControlAction(0, 47, true) -- disable weapon + DisableControlAction(0, 58, true) -- disable weapon + DisableControlAction(0, 263, true) -- disable melee + DisableControlAction(0, 264, true) -- disable melee + DisableControlAction(0, 257, true) -- disable melee + DisableControlAction(0, 140, true) -- disable melee + DisableControlAction(0, 141, true) -- disable melee + DisableControlAction(0, 143, true) -- disable melee + DisableControlAction(0, 75, true) -- disable exit vehicle + DisableControlAction(27, 75, true) -- disable exit vehicle + else + Citizen.Wait(500) + end + end + end) +end diff --git a/config.lua b/config.lua index 96b0472d..3d37568a 100644 --- a/config.lua +++ b/config.lua @@ -1,7 +1,12 @@ Config = {} Config.Locale = 'en' -Config.MinHeight = 24 -- Minimum Height -Config.MaxHeight = 96 -- Maximum Height -Config.HighestYear = 2020 -- The highest year that can be used in date of birth -Config.LowestYear = 1900 -- The lowest year that can be used in date of birth -Config.MaxNameLength = 15 -- You must also change the SQL structure for 'firstname' and 'lastname' in the `users` table \ No newline at end of file +Config.EnableCommands = true +Config.UseSteamID = false +Config.UseDeferrals = true +Config.MaxNameLength = 16 +Config.MinHeight = 48 +Config.MaxHeight = 96 +Config.LowestYear = 1900 +Config.HighestYear = 2020 + +Config.EnableDebugging = false \ No newline at end of file diff --git a/esx_identity.sql b/esx_identity.sql index 56b88ae4..c9e411d5 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -1,9 +1,9 @@ USE `es_extended`; ALTER TABLE `users` - ADD COLUMN `firstname` VARCHAR(15) NULL DEFAULT NULL, - ADD COLUMN `lastname` VARCHAR(15) NULL DEFAULT NULL, + ADD COLUMN `firstname` VARCHAR(16) NULL DEFAULT NULL, + ADD COLUMN `lastname` VARCHAR(16) NULL DEFAULT NULL, ADD COLUMN `dateofbirth` VARCHAR(10) NULL DEFAULT NULL, ADD COLUMN `sex` VARCHAR(1) NULL DEFAULT NULL, - ADD COLUMN `height` VARCHAR(3) NULL DEFAULT NULL + ADD COLUMN `height` INT(2) NULL DEFAULT NULL ; \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index 4917c8cb..09853b6a 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,7 +4,7 @@ game 'gta5' description 'ESX Identity' -version '1.3.0' +version '1.4.0' server_scripts { '@es_extended/locale.lua', @@ -15,4 +15,21 @@ server_scripts { 'server/main.lua' } +client_scripts { + '@es_extended/locale.lua', + 'locales/en.lua', + 'locales/cs.lua', + 'config.lua', + 'client/main.lua' +} + +ui_page 'html/index.html' + +files { + 'html/index.html', + 'html/js/script.js', + 'html/css/style.css', + 'html/img/esx_identity.png' +} + dependency 'es_extended' diff --git a/html/css/style.css b/html/css/style.css new file mode 100644 index 00000000..eaa2535e --- /dev/null +++ b/html/css/style.css @@ -0,0 +1,127 @@ +body { + font-family: sans-serif; + overflow: hidden; + display: none; + color: #000000; +} + +.dialog { + width: 332px; + opacity : 0.95; + position : absolute; + margin-left: auto; + margin-right: auto; + top : 30.0%; + padding: 10px; + left : 50%; /* à 50%/50% du parent référent */ + transform : translate(-50%); /* décalage de 50% de sa propre taille */ + background-color: #B7B7B7; + border-radius : 4px; + box-shadow: 0px 0px 50px 0px #000; + border-left:5px solid #000; + border:1px inset; + margin:5px; + margin-bottom:20px; + color: #000000; +} + +input { + width: 100%; + padding: 10px; + text-align:left; + color: #000000; +} + +::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ + color: black; + opacity: 1; /* Firefox */ +} + +.radio-toolbar input[type="radio"] { + opacity: 0; + position: absolute; + width: 36%; +} + +.radio-toolbar label { + display: inline-block; + margin-top: 5px; + background-color: #ddd; + padding: 10px 20px; + font-family: sans-serif, Arial; + font-size: 16px; + color: #000000; + border: 2px solid #444; + border-radius: 4px; + width: 36%; +} + +.radio-toolbar input[type="radio"]:checked + label { + width: 36%; + background-color:#3399FF; + border-color: #0033FF; + color: #000000; +} + +.radio-toolbar input[type="radio"]:focus + label { + border: 2px solid #444; + width: 36%; + color: #000000; +} + +.radio-toolbar label:hover { + background-color: #dfd; + width: 36%; + color: #000000; +} + +button { + display: block; + margin-top: 5px; + padding: 10px; + background-color: #373737; + border: 2px solid #444; + color: #FFFFFF; + width: 100%; +} + +h1 { + display: block; + margin-top: 5px; + margin-right: 5px; + padding: 10px; + background-color: #506be6; + color: #000000; + width: 93%; + text-align: center; +} + +.range-wrap { + position: relative; + margin: 0 auto 3rem; +} + +.range { + width: 100%; +} + +.bubble { + background: #3399FF; + color: black; + padding: 4px 12px; + position: absolute; + border-radius: 4px; + left: 50%; + transform: translateX(-50%); +} + +.bubble::after { + content: ""; + position: absolute; + width: 2px; + height: 2px; + background: #3399FF; + color: black; + top: -1px; + left: 50%; +} \ No newline at end of file diff --git a/html/img/esx_identity.png b/html/img/esx_identity.png new file mode 100644 index 0000000000000000000000000000000000000000..dcfc17c43bfb7332914c1d90657eab4991947c29 GIT binary patch literal 14230 zcmZvjWmsEH*S2wYiffVJ5ZoP#1$T$y&;mt^1uvzz2P^LG?(SX+g#yJjxXYLO`To8? zlASp+J3BLLWX*N16{(@7fQ>0+OAysx%y2T^#1KB{Hmx?y6|$4hM%b_}>dYg$;)S4o;9wNlseltJ!HbD&(E~ zYEaL*O=Ji&9rO1>c|1HqfJQWFUs%4K5MpTry8KX3$PaX0MFJxEi|fHGwRggc83b%&r`cRvl-iKB)x zv$7~1W^;qBr!oa=?rGlcBd+R)KGqqm?dStzVj`uwN zB`?mNg6jR})8EdOhnZWIeieGQ{P}Xdsv|KK9F)D`7z&$-RE{H`FJJ1cZETdhyqb+J zb*hZ`ZxrA4v@14sMs9M-YHB95lbp?j`FU-F)qNT)`Vf3}Q}mltLwSCB|Mi(K)ui|Q zTqcytY05ey`PNBJFZCzu%P`q|y^V@zS65!z2LL-TaC}u>pi!*U1l9PjAlG=T=-Gh@ zveoW*O1+zQLZ$PfT65zG^U5g>Nm)bGyXC)zKO9flSB~|RZ!hH&Z}w$a9s{~Z7vqYi z|CMRA=wX*>m&EGSn5{nm0>NbqTEF=0iF8TW=Sw<8PijN2lphW1K8CZOcq9-clK&LU zc}X})>>Bcsw;uS0?Kb*8V$`|gbgz@{a!PPx^m2ECO~;-?a4Lh}z4{rw0xKo55P7dLKihh{_b$8QT6=eY zrf_$m3lVd2Bk;{M^_LUl`~y3S$O(vL&C+gP@?z|7y=FP+Nu$14Es?4_gZ9R8IWgO7 zb?m{#5Km6BSzPtUOvi!`qf8U3pK=6tPq8j(9`~C;L)p9a+izFOVdS_!Ii5a6pB*G$ zMKb-2AHd~G=c7F9yi&7FV`T%jPysW!I!<_2yf*@}_2rz~4*}}Obkt)Qph_X6iEt9L zgHAeS?QDsFcK4L@Pwts6w9F+$iwPT?4-6SS~)ZT0&6P=7u8xBg-} zvcAnqaDS=Z`m+g>a3H&ek<;xD#_5W`@6J-0!bz}FZ$c&FY06IxKM>BJ)K73~K{r~I zZ|mn*T1yA7%{}|@9=78ov-JDJ(*w1kd0GY~-B-#=vf!s`zPHN7XVrY&RNf-4?|^O;<(RTrSFg-2<#gj761h{phn?Sc~otFl|(%gWYvgJ8z;G{Z3S;Q)J^_ zc}likl^)_ddtHQk`Xn^_2^^!l{^}bTv5#p~=y3>dg%R!)CaG!R{v5g7cj2;b#C5kB z5THvFJAjP{v&)8)TPeX6yTdfC7H8A_B?~+Q$0luTho?j4vX|cUqYgep7cq8KuiHD+ zJWIix+x8v*$3)nG=g`MWYjf%h$c@Z@&JP$7(Z@eG-mA*mH8Eu0>NPNEa!h%?SvEiF zb5D*w&5kC5952_THDymH{BxWGT*eZjlzf_Bsx;KT{hP(r5!0$zPdt;Hm7b%#aOm=R zO6e*TNB1qpkI~Md434c@(^${^(qQ}*wA<3@-}-K;bh}e){_93J8%Gayjt)-Q&_|^# z*b^pw=P%yvvm&hOO)R-*RV+G~(5qzN2+JRVeAFIXLTc^SGqhgP!PB~7{Q}uGmdnT1 zu+?LlEi!n+Z6z|mMx}#3TVMI?=I&vBGexvA-MTKBo{SBsFK|XH-&CL)MiuxZTulsN zz85#`<2C^;YUSswd&04v+iyS!&DyK z`vB{)L`GKCC^W}7YH=OqiBipiLc5uttWDv)@OQauOuI-j5s!>1N3{bu+AN$ePj~ve z?QgG7y2316Dh4c){o;lKpH~Y33iWbd8yyP9-6l9%Mi1r+bjdnA zkBiw0b6*hOPq-XyFfm5ibOB)9|K~CAE_7_r<)eF`;0*e6>zAGy%YkpK*t3NW3&qB7 zQ1EP=0~x8Z@GV=*q3gzwUOszdoA{0=sU(Gq*o zl>TN%Fj11J3-Y>qrSJ>(XlnJ&x3L_*%+1?g&O$1HI^Db6`YO^bS_=|(V<3m~!SH&8 zD%NSXJ~Uq3B&bpIr*xyoUnS}}JfQYwE=Fk5=wpTYeHj1szo(j(b81OG&2XyL zyd%Xt3RhJ$IHswP)P8+__TOjyG8*UqblS4CvjwoH282YI99TcV)|K7zifXNjy&&Jm z!xAl$-$zRoySbq_80-3R@q+HMhTX!}qj)K5yYe5nVyuZd&FU80erV{FbU&N6Type{ z|ABA`tKWE5)4j|2+BUh~kW?e7{lG!t9Zis`WkAbsPL@?$i$%ys!}p!5=UL0a=^~7g zmXg~4T$&%vpm{_NPXKEbhe~8Lf(Bd~CWU8-o{SAI;CZAYyr1PR#$Woim5H(imnv`I z(K(Fv22b4pK?PIt>4f)izDNZWZ16VS&Zs-5 zmTyckSV>{bv|+N1b+^X!&h4izH6-0=I)ixy8u#DU^)Sw4bM^s>Bjjyb_ip_>-<>FL ze1fP$&3`&e*zI~wVFH!LA5UMyH@yh*LtXNvkw61H0ZM{*e}nB~+D7@tq?$NT`kltNH+7 z1vywuxqR{wX6^nXwx8_VH8O-Ni{4r8MDLw0F%$0wkaoE$(SEbWNyllpg=)xHSf$5=B+5YwQ%m~h9CvH(>dZ2PpKoFW|9*GlhqI+d%!j#%%6Q#RXC33$ z!$|)PycF}R%}`uDXLQ2n0BFx!w^3NUvg`MmdYRL!8A<((vb<_n_1yK7re(A8ZXEGz zjorVSo?Nar_e)D>9nk9LlWi{CwU28ZV|63c9XD@hs1o}+O*)ev4Oj-WAPvA`!$Zd& zVqlAC+T#ZSzdSjA__OuRl*@Pv6<4b85=9YXe=7TU&ckyRY%}^- z-DRz|FrX{EFDNO45!W;Mpsu9AhF{%eMnf0lRJ`H6gW64RYas};MjL@IT8=?CN8?A7 z%R;3j9S@_-0ink@kt60CF-_nM%)H&qr`UNTcb54Jf+0cYi<)3QVQky?d#*fl0Z6$l z?4E72&$WEdM?c(hl?Yh8LyOOd3;&4N@9&B89v<~-u;yZCN;tD8%c&`%$y>}T^@EY% z;gi=TS1A!wX2EVW568p$Hp36i<$4b`k_XPv$J! zC|xwo0l2^uUB3V{!5|{r?X7``v^i(LyR$0WUAaaxBxEB={7)Qw+;N2R&~H{4#3;m^ zh)5PZ7UUbg$5onppZ+v|PI;o$l)jmj#Vwmb=ufmD*u^Lx!zcQH$-iaRfkDcy*RQgeaM~;SylpExC!%)U!JouCny#4C=^55W&LZi7AfOJYG;O z$ND`EvVhHaa-phTqu}(n_r6)*dzWU-5K(bFs_B4e zT1^bDjOXITL2?#=Bf(#yF}y6a?1ZYiG8&LoP7U=loubcFjopG9{tInC&SwH&wcC6W z!^dtHwbebV2{3Q%`^jS7NEwFqaj>9s)lpYN7kRu*8;u4>SO;`%+o+0XG_T}_TR%^W zTA!NgABxj#PHV~P8)w{ko;ERek1J7l=mXmba?fOk=A{d$%ExhB#MxJzl(jzzoUQiz z=;g<}T(o#)R4}?B1Q+VO8cHZIFhx4zt^e`TOc&2+;?q=u3>5>Dl znrJiHl@R{QY%u(udD0X(hT|f^9K$;6f{w&E8p!)zNwjh*{>x?@1xYqG9`2;>Bu^4P z{fDr219>b)Qj{`bzzw$$WEhDTr@pZAkq zD4-wFrXNbdhDVG$>4wsZZbdh_a|*KjRcUA(@K?$@JGoL$T2`I$cLBP*#V_$dCI=6n z?OAGU8cD$-vWyu5Y^N64giAyLvOfw(H&ABXoCA)Pq@O7#MHekWf7T8^t+?%@CI-#{ zAIfYOlKq*?CaYI9e)y(}>xBj_t!ld@7ag;4a$rclS2_aRa}eI_57FamlUUBxSt-CA z<%b+lqGf2RgWIY@3G!vxfGD(+P^e@EH$+bIS)&~lK6h8IS*PtXh#kv2meo03F2tgB zWi3@HzmHm#8G$h89UDQvZ>~IpBg#XtQCv>G{5pC4#yE}5n|g#wg+lv8^<5V2((qr} z%Q2P2uKvJ>l~hFa1kV?<#GIpMbPjozH)u?Kv$14TmbUiGjL$T00?aM9R!TD?A|~6F zn7WxeA7jeVDW!?w$@bYxpVmbJU3+}`*$ERj_6?B`IQLNS>mY(IX3RF1_4Q~*pWWK9O)UE7YJAyHC=#1-6d1i?%xAcX*K@9EzNP_ADiR~n0ORR!) z_I#ZT(Z1B4)>6{oy|uGgU$ugzF==E7Lc*t2onl!!(FsS@c5f*4SA_R70!tQgwjG2J zXCUti*b%zau-mKtO=&<{LFw1Q!9i{DK}cWy$AC*skFe9VR0Wj_mbr}_(ek*)YC{G? zSwG<#Ip!0ej>&TTz=m(N7f0W1+g0VIUMp7)w-OYnH7nfu!C$M=xS-GLwd|Fj;ghpS z%%lGrzdv|%tBl9wZ0&7R_P2@4JTMFoLxpB}$AF^RPJ@KCc52NMSbH+LrX&y^xx|U&H+k@t^?z;Sw$Q5(co2r|>M{JG zH6GIUlb^l9-g(CTl@q!ft6=0>7QI}}Ke8S3J^2WG%9gPA=n465gEWuQ@fj^{aQu%! zHo=6ka4c-TD-X$jwX%8!oR>s-cmTWIjmpEvV=>;ZO0^NWW~>ImWDyyGsiuyGt=rYp z4fm5{t4cpO1Ae#ti06Os8OwaCgNl3secQv7NMR++aWi9?y|oAiR}IqTZtu#_wGMF8Waxy7ld}Q0;~VNK zgT_}W*=gLzE>r5avZS?ix;%s}Z~vvwTlb%SStetf+LLTiNs%w=OYJ8{9i4X;WFwT! z1}1d~<_|q9*>DGwoGE&U0n~q98KZ9Eo{ zd0I?c8kx8Q@7BF-8U>p*RBZe>1kZNvztU2!&-pe>RE%;wvF~CY>YZe{a30YPjhdLN z1x>HFXkp*l^JrP*hj9HZ>DamRQ?;!^YqsVv{3WMhgjgs=n#IWRY*!eaNk-*7?U^^VR7`yeHM4k zpRDXwFiOSeajiExgThYy*{_-=?!MKF3HcKAFj0YZ!|ir3?5;)Ub@CxcG371R%M71o zx(aYS)1#ltj`@c40oy0BA1{jbi;H#8xE6V*kAh?<^PqoPN9Mce(ai@@iK%CoHw z?ia4^`;SCG#TI~z5+y>=8Mf9WJ-g7=`iZe6Y>^~m0&;umd$%cKct^_h{P0>;{k3-g z<9V&DWzv-BXWMA5+3XcOi#<&jy8Mz zfO*Pf0s%Rn*)-Ms{z5Ggsb~l4x<^61jGr#w;cr^xWju;(`)hpS#%0*q?zofO4Azrh z5E^Wg^t7@}y^bsYX+MpR|M{EbLP1llmaQ^WIKGk0$lH#c{7+3hOP_8B^k(3dbK6{# zIvVt{y+ct*%e4wM++R7?p5E4eot)GEPqwm~{`15z!)!^KYjeaqr26}Lv*+!_r9T58 zlZx%L!h-T!qYv6RXi(c1?&l=IbOrbupe*DXsj z;KW3VUj9HcCS&dqNV9@f2e`F<{%1gZ67HBER|^y@0sJQ1L*d9n1BDUBBu+;ZuV&cH zf0_r5fj2*uHPiYgZRTftr}anCBsa+hCOV8LK!{YV@7RWasE>$ab%n zl^`?7m($n8uOInU+%EQY+D52sDFyu3_SiPPONOjcuc(uzM1FQ7-fi&y z4ns?V6rK<=p5;H{Sh>=k`+t~4eHP=xrWpEKNvf^&a=8KKg*HP=TXwF*I> zT(f7;oxNPE$UmT`%-A=3Ql-ho{vFPm?mi;?c_C}^qOJosp+KFXzCly0UfK5e<82z| z`2W}H4`Qqv?EDj(rw|VAb(z+fsOk&sm~9iy-wfVUw3~Bfc9`#X9%1kAzvD7y7iJ42 zG&K9D%xSK5IV7*8(_%SR5Nv%qZ%}^>#pmvE9|tfuJh(3Ptry*-ZUnFe4nI;FihfmI z+;5QZH(K?-SDY_yCBZrmXWC##HdPTk8a2F5;%kMzTe0$X;Yh6-Q@rP2UUZ9QnH#1( z9fq?=-Fq>+>kslfZCc)eo!PahXi!CSw*1{<>xO6!ZuRNHxKl<`wohEKLmqyxRck2B z4I^R`y%lx5(E;&8lF_T8coyPX^#KZe${;@!)^4trF~ya0tHgc+On?%fb%WU#lG*LzEE9i$4>rJkTn{*U}0o}@r1S9AJ^(cfn{#Xb>r29;D5x0*yMciwo@6x z`meQ2p=o53cVBjpWD`|n$5-vr_t6bU`z6mbvQD$VBm#A!` zc9hsCt@npx+B|%QDoHoIWa%q|UFI9+pR@hMMHR{s2=Ro_23j`2qD87eJU4q6EJcy` zsNpxzjg1GFFu5?C{`8rZ2(4Ks;iYMqWY#Xc6n&LUaO3UPQ>p9@wMM=l8(8K0fH@g` zW!Y}&ef;9CH+D8-%C_`$#?)4WoxnN)_I%A0Yr_P`S1NENqR?|D-mX*xpyEk1NX~T9 zD;vn1?mrfNeyO{(ONBfF!beOPu8gSC5}^XbXnH7EqJ#0PNgzE00N=xxMKa+O`>L#X z$fUQ!>^qpIRE!i&Ccd02Z&{o-ghS4!=+J1^PcRh$A6!f%XP~F|9fcR2@t^syI)z8* z4lQ2cU>roz0xviXL{^K?IXzXP9_~~417I0!XhtCgX$_z=142X>D*zllU-gdG{lD*| zLS|QTUKHGjUrRw3l?Z{-{cm4!p;JFE^XKg;aD;Vl&2N$}w;qCxEzBkgifWx2&AGj= zb@LuLUhFk5UknFoTw&_Wi&N|5+P^Mxrtj)pXp18iHQnXE4*$Y1#urp%D(~m}i=*h= zmtHxqee{1cGKij`hyMV-tnrZe5JGJ1KYPs!vQ<&%5HTVcv}5Gs^YNQ6`1+Y{B$RH&=2BIc?4`ybx5v*vkuv zM_pD;9q%r;8cPFW$e?pxy1kz!DrAJglW;Q+2ZHA+3=}BMG`KtK7OZTOOC#a=vL#>{ zQsjc*85Wq}wJ)k|>ZT$!aTK|eQz~0X^sa_V4 zr2~u?4}Bana214*!5?DW+W!wKlcBE=pL}J{I*y9|cHAg^lyv_-o$lk@*4kKz+^&0A5iWBOs}y~k(*8)r9qhGIXEoB8u`Tdr z{bQZA*p6xag>rj98qA@DRr=5mVEeR|P)*g|Sqo?z`dGGT;nsl5q+${oYegLhQ@xcd z*tw?WGj?GAlis3)tqFRP6Ua)K)zBa`Uf3B{6#0K5b=H(#hEN(wWZWo5!nyz1?P8Fo9liTm)CT;+BV4&0ZvN`eyoUNiIJ=BiLHg24R}{Q}kft7R z9InK@)Jrz6U93n^;uviu;_$pu`{Vf#iFxHJq$frCe3m*nB4U{(D+6TTAct0@D_k2n za3|cE{c?!+Gs}ExWf`Um$B7VT52gW21=8&z<5dLM$6BOgwIKhy2SX1xUN9g6j-0 zfT6!HwXlVs#U3qrQaiBtr96vxk*JQ4MLl}Y33P9o5 zgW-*u>uPefPV1!aywgImR6ZSDyuR1=p7{soTLanpJekQz00gM{+hf{1+`;I2hj*H~ z#Dg4Ff}>?w`Qyc*;K=3-9PR^Ytoz)SvdmszR0giAQyw}106?mXM<86Q&b2Jp>4 zU$^z~Ioof@_jlgf()SYdXPW*BjA9E^4r zW$G-XAZcd$RoeLIb-0ka@#l+~cPI@_IATol(?x~oowsF1W{>4-Tu}KFKlb(rRPa8_ zFZ%vQcpY_ev#J9G0N40QQ!SV!hqm8Ec|y*~dZ7DP*Po9d0@ocSa*Dnj!r5+XtzR53 z{CdDI|2Z5O{;nbjQ7G2KTP8Tz37(T*n=^V~z&+XahpX7X@AQja*I1Mg5zlh5x96*J zo@a29+V@nyUxs#L@Tioz`Dq?u=7BG|Rk8sv%{)2vcsKCBV1#fH%P*2W@Z2F%tkP_;n&>H?@E*jf z`7aw)`X<>%D6aYj7uE59)C%>Nwpsr4GvE%@<0D_--PW6j-0Mi!Cf(e`#68vI=GzN2 z@JQG;nF0y#28HtTkHbip$3a4Mo#RhsQ7|#Dw05TN8`Qrr97L3{*1*02TA>Wf#9T{ zyuds^==x|$1zEX_X}xArpnE%3v>5~QEUud;;L(Fj;1fi|k$5WWQRuuEQTHjDoL|}D ztd}%TGOsVwDy-dB?3nwb<2PHHgZZMU$BC{>;g_{emq(@>J{Zqf!Z9-f)EAm{`8vj_ zJmT+eN;s%LZnM>N=C4v#3{1gLhHlU9&l@OD>g}o%*Wp4*T)CC0OK05Um$*pUgQguN zOpwSFiMf9s61w@j8hVtzcMu((7gJjJ*+?WfIu7QNy6n58rpf^=A& zgPm%+^w6!n>FZ73Q6&ToVsdrnY89O49IE{XJ1THw23(gu$jk;RbuEVKzk8YTx#2clq+(yq6AY8#~wpA3K=ZB1uwuaS?U zB2l(v$>8%w{qSAUlp58;_Fx-tO8;iW!xNh6>ivHltUtmR&|7{ScANKnE&C|mkvc+7 zzbO0z<0h&XZk&?scJmAo?Kl__wY+Yy5K8TY7C7u!*&PQQOe~^2<1U1zKXzZwtLQ$` zS*1Q+BQTZ*zP+MjP9+O$SQO{e1;s-7oeGsJ^s00iXM^o^$a6B~6sIBFvR$YO^?y)* ze3ObOreAj*z;<-iOt7~S!vklrE0j>_=f5A}g?^Px2tXl>i3KhdW0TV$2E`5?`|qdd zo0W;|!tiQAqb8CFuTb_Vr2)AJEkZPoEK@fOwx5J};M z_7g;L)&yV9eipVcdrA;dK92Ivh!q@R!b|t$pE(eYuQY!)){Qv-kJ#{7ymuH1zJv>i zzdR7w^Xrm&QgGDHamyG!uy6mNqq@9B?{-E4j9MS4J`{eyXq`kEsyPi_%I05c#~~BmG3rOM2zM3=0S=@h?HbNe2aA zYA)AxGZ8DHgC=Rh;4RdEUkAc4O0MXb@g^bUYeLu|7~r$E{c@b}y)g@J=_{$yk35<_ zCfW&;Vpwh{f9d1I^6BdMUSaVn(BnUr#qtI`Y?dFm5AbGJmq*Nz7#n~!3$v~Gc!jOx zrA)TIbaZh@Gl0Yw# zZSQ+H;6|z7nbHP{OxC09mDC@(ufRITQkpPy#7L;+zux-14d9nK_1TZUwuuC|sU$rR)XDABvIQumf9 z2#CX2(HA}40Z--oSRc*?RE+n%6$kRKX2(K>W>xX_Km7wxfvnhV3x?}l;5SJ20@(fZDW0!hKUMJCRzTi~I`mcxD?}3-F126RUB z?J;&*1@i|9MDBf;WTu9&+5hs;ki1HYtw7di)wr9yJwyGhd>+|7yz_lH*h{Ho*>l>C z>{BD5G!EB$yO6#7aJbME^l=ZaIh^*YXA2q685vEVD~|%!96;#$y9~=vpj^fGa2z;b z#aDC=a?%@9cISDuD*!-fG^6z$*X274fKC!M?V>?c%iz<)M9=ArE(X8dT*1p-@KQLZ6iiFBK@T;fjX0bHwaA^0;P7+$H6ltLW z*%~iEL^BYyVEy7y*Sk-G`^aJ2u}nHPGox=*6iad-f`ND>-9q&;s)FbxYX|`bSK@Jf zKNC*k>X9`-kP*MerQUC@as6+s0^_c#7tp9GPLT$OXDg!D~Itf;(0Xf6&j=24gXPi}vp5WT8JG|sV`AuH;P_k0H0S`w?BpeUafgI&U z{!v7877O1Jws=HH^Y!~0)M7>epED8<;o2(Vt9K@2zgV??v|Xn*%s6U39^{^1zV$lL}-!tzo2Do(%UerkB^QAg=nR;xCmxaEB&Qx zlCykx410+1A+Crh=!eWk4U4(EhrR>W*X^h^5z|z#!vIRnPvC-24wfxD-t(;eBqXjC z4nnGEDQl1iKNoQ@a2TfaeG*IjgJNL+=Yjj)XPfAAawF6Hvm9DT0M7xEwCJHPI(;~| zVd8>{O70hKr-a*kBvwR-36dtMt35%bM863=#hq9}x1dInkX@0=+#`~nM@X8Mrvv8J4P6Ph z=eg&GGd{K%Y!?37<7)d- zChk=wyul!^`f!yW3YtisBy8I|V|2+yYuP0C?$v}zB$k<|~<5jLBNSuv8>OGYKA;qbiq)L8a-U=1A8 zGi%FS1h8^8cni5$bZpv;_W9bv23d*y{S3o^)}q0a%rJ(=d)FYFIBr!+WMovqST7DCP>!<3`6=+;b(65wRkVhTw)2B<H z+xB+hD;j5B3=ibs#Fr4G_tQdurtj|0QtvQ0HGd?;YV>jGZ2GUWXNS317=)`>4X7JL zpDXmKbQ#dNf9WB9w#A?VC_WNSJeU4iHV-siiZJFamZKe^Ux|B?D4W4_Xe3T)9^!@bvtq;3GIIjJWLXU{$5ZkAgZ(%g-9{mT?!Vq!=4KL9O) z%wQT$_WTD${(NV$$;PSwqP+g#Nzt_|oFe3jml*?S)^Yq}$KoTirB%ov(Ten#|77NX zhnw9p!0iqzvD(5^9yfK62ND|#{qkCzvD8*K!Xw_DA~}%}v(1lPN$-Ij)u2djnSg{2 zMV&QD`fEWLuaQ&diN;5QeA`%zqBZDIf6)MV9ppnZ2{UOL>0e^+csNVlS7W^_xZsA% zalXCZDI-}eqf_#2p%a`$V+gYn_;R%>U6Du6Lp$dTQSHjw)4{@*5rL=5oZdzah5wv* zr`2ZSghzm8H*P62a8AZbZ5acU&DACj%k~P&>>!%Mhh^h@TZxC}4YWc@`sAz%s%A$| zqQd}ZEl!w(7@^-h51o0@R8!$cy5~TNM!yN| zWmpeucEy$RHxsc-=0PzPJo)BZ{3&P_t^Olg1FkuHK*(iBz$|3D@x2}n!VET>GH@SH z&MZJ(_GMGw3Ir(w*}H>=(Zm|HS3|6wd3Ywre%0U>94_pELbAGcoUMArhm;vsr%gYE zVcw|@hrg=vX%4^3+2U{1GEMz@Lv9@nEGDJ5&-a&1sy;mW_w(Q>nglxp!YwbJ=fJZy zxLSo471Uht88W(l7n9g~n{Y2Y#a(T=W}jo*>1RuM0mp6(sLiECM9cUF0P=e%lBeOQ z?#^>VSW3l22yrFvvjj^1VSo5r!jD~ZcceTyF`=D704}CtTc7j!;QZsG>J4bMXRp_B#3BlF4u@6jG zYG*{!gW^N51PX8zRGQb?1;i(bg7uQ#lZg$-gV9Pt4KTW8gn>_m!`h7?3Wc13B^Xq71x8>s!1Gvi}0kk#!Ty$ z!OAzbAASoVbI}fitb`k~Jr>(ot7#kCK>6>wOtw8}ZZqv-h3SqcLp!TgL>^mGIu`>d$&uiEjq!I$X9!tM|*gW-OfF`_fizy{+ zpIdfhKkE7R9i!=H|I3dHuKgql%h*~u>r+q&`ex4`%=mNL5AZ$2C7~CgSVXk&xK}$q z%xR)I;s*B9jGJi;%!RnGm!W6^K6#Lf$igcF9tw)ptF`Y)`{7q|VJaK>| zeoT^-x;#MLc$@|%kf)NyujXrm&y5LAld+KPtd(!nXotI1W%ScLpPQ7ENi literal 0 HcmV?d00001 diff --git a/html/index.html b/html/index.html new file mode 100644 index 00000000..182d344a --- /dev/null +++ b/html/index.html @@ -0,0 +1,163 @@ + + + + + + + + + +
+ +
+
+
+
+
+
+ + + + + +
+
+
+ + +
+ +
+
If the submit button doesn't work, please ensure that you've entered the fields correctly.
+
+ + + + diff --git a/html/index_heightslider.html b/html/index_heightslider.html new file mode 100644 index 00000000..182d344a --- /dev/null +++ b/html/index_heightslider.html @@ -0,0 +1,163 @@ + + + + + + + + + +
+ +
+
+
+
+
+
+ + + + + +
+
+
+ + +
+ +
+
If the submit button doesn't work, please ensure that you've entered the fields correctly.
+
+ + + + diff --git a/html/index_heighttext.html b/html/index_heighttext.html new file mode 100644 index 00000000..13896e58 --- /dev/null +++ b/html/index_heighttext.html @@ -0,0 +1,150 @@ + + + + + + + + + +
+ +
+
+
+
+
+
+
+ + + + + +
+
+ +
+
If the submit button doesn't work, please ensure that you've entered the fields correctly.
+
+ + + + diff --git a/html/index_options/index_heightslider.html b/html/index_options/index_heightslider.html new file mode 100644 index 00000000..182d344a --- /dev/null +++ b/html/index_options/index_heightslider.html @@ -0,0 +1,163 @@ + + + + + + + + + +
+ +
+
+
+
+
+
+ + + + + +
+
+
+ + +
+ +
+
If the submit button doesn't work, please ensure that you've entered the fields correctly.
+
+ + + + diff --git a/html/index_options/index_heighttext.html b/html/index_options/index_heighttext.html new file mode 100644 index 00000000..13896e58 --- /dev/null +++ b/html/index_options/index_heighttext.html @@ -0,0 +1,150 @@ + + + + + + + + + +
+ +
+
+
+
+
+
+
+ + + + + +
+
+ +
+
If the submit button doesn't work, please ensure that you've entered the fields correctly.
+
+ + + + diff --git a/html/js/script.js b/html/js/script.js new file mode 100644 index 00000000..a6a5afce --- /dev/null +++ b/html/js/script.js @@ -0,0 +1,34 @@ +$(function() { + window.addEventListener('message', function(event) { + if (event.data.type == "enableui") { + document.body.style.display = event.data.enable ? "block" : "none"; + } + }); + + $("#register").submit(function(event) { + event.preventDefault(); // Prevent form from submitting + + // Verify date + var date = $("#dateofbirth").val(); + var dateCheck = new Date($("#dateofbirth").val()); + + if (dateCheck == "Invalid Date") { + date == "invalid"; + } + else { + const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(dateCheck) + const mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(dateCheck) + const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(dateCheck) + + var formattedDate = `${mo}/${da}/${ye}`; + + $.post('http://esx_identity/register', JSON.stringify({ + firstname: $("#firstname").val(), + lastname: $("#lastname").val(), + dateofbirth: formattedDate, + sex: $("input[type='radio'][name='sex']:checked").val(), + height: $("#height").val() + })); + } + }); +}); diff --git a/html/localization/cs_index(outofdate).html b/html/localization/cs_index(outofdate).html new file mode 100644 index 00000000..1dd357a9 --- /dev/null +++ b/html/localization/cs_index(outofdate).html @@ -0,0 +1,22 @@ + + + + + + + +
+
+

Register

+
+
+
+
+ Male + Female
+ +
+
+ + + diff --git a/html/localization/fi_index(outofdate).html b/html/localization/fi_index(outofdate).html new file mode 100644 index 00000000..87ca250a --- /dev/null +++ b/html/localization/fi_index(outofdate).html @@ -0,0 +1,22 @@ + + + + + + + +
+
+

Rekistöröinti

+
+
+
+
+ Mies + Nainen
+ +
+
+ + + diff --git a/html/localization/ko_index(outofdate).html b/html/localization/ko_index(outofdate).html new file mode 100644 index 00000000..c04fe9b7 --- /dev/null +++ b/html/localization/ko_index(outofdate).html @@ -0,0 +1,22 @@ + + + + + + + +
+
+

등록

+
+
+
+
+ 남자 + 여자
+ +
+
+ + + \ No newline at end of file diff --git a/html/localization/sv_index(outofdate).html b/html/localization/sv_index(outofdate).html new file mode 100644 index 00000000..7706c17b --- /dev/null +++ b/html/localization/sv_index(outofdate).html @@ -0,0 +1,22 @@ + + + + + + + +
+
+

Registrera

+
+
+
+
+ Man + Kvinna
+ +
+
+ + + diff --git a/locales/cs.lua b/locales/cs.lua index 98172461..80c6a267 100644 --- a/locales/cs.lua +++ b/locales/cs.lua @@ -1,6 +1,11 @@ Locales['cs'] = { - ['data_incorrect'] = 'data byla zadána nesprávně. Prosím zkuste to znovu.', - ['invalid_format'] = 'data byla nesprávně naformátována. Prosím zkuste to znovu.', - ['no_identifier'] = 'there was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.', - ['missing_identity'] = 'there was an error loading your character!\nError code: identity-missing\n\nIt seems like your identity is missing, try connecting again.', + ['show_registration'] = 'zobrazit registracni menu', + ['show_active_character'] = 'zobrazit aktivni postavy', + ['delete_character'] = 'smazat svou stavajici postavu a vytvorit novou', + ['deleted_character'] = 'vase postava byla smazana.', + ['not_registered'] = 'nemas zaregistrovanou postavu.', + ['active_character'] = '~b~aktivni postava:~s~ %s %s', + ['already_registered'] = 'jiz mas zaregistrovanou postavu.', + ['failed_identity'] = 'nastaveni vasi postavy selhalo, zkus to prosim znovu pozdeji nebo kontaktuj majitele serveru!', + ['create_a_character'] = 'aby jsi mohl/a hrat, tak se musis registrovat.' } diff --git a/locales/en.lua b/locales/en.lua index a8e381e4..165ee7ae 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,6 +1,33 @@ Locales['en'] = { - ['data_incorrect'] = 'data entered incorrectly. Please try again.', - ['invalid_format'] = 'data formatted incorrectly. Please try again.', - ['no_identifier'] = 'there was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.', - ['missing_identity'] = 'there was an error loading your character!\nError code: identity-missing\n\nIt seems like your identity is missing, try connecting again.', + ['show_active_character'] = 'Show Active Character', + ['active_character'] = 'Active Character: ~b~%s~s~', + ['error_active_character'] = "There was an error retrieving your name. Please contact an admin.", + ['delete_character'] = 'Delete Your Character And Create A New One', + ['deleted_character'] = 'Your character has been deleted.', + ['error_delete_character'] = "There was an error deleting your character. Please contact an admin.", + ['thank_you_for_registering'] = "Thank you for registering. Have fun.", + ['registration_error'] = "There was an error during registration. Please contact an admin.", + ['debug_xPlayer_get_first_name'] = "Return Your First Name", + ['debug_xPlayer_get_last_name'] = "Return Your Last Name", + ['debug_xPlayer_get_full_name'] = "Return Your Full Name", + ['debug_xPlayer_get_sex'] = "Return Your Sex", + ['debug_xPlayer_get_dob'] = "Return Your DOB", + ['debug_xPlayer_get_height'] = "Return Your Height", + ['error_debug_xPlayer_get_first_name'] = "There was an error retrieving your first name.", + ['error_debug_xPlayer_get_last_name'] = "There was an error retrieving your last name.", + ['error_debug_xPlayer_get_full_name'] = "There was an error retrieving your full name.", + ['error_debug_xPlayer_get_sex'] = "There was an error retrieving your sex.", + ['error_debug_xPlayer_get_dob'] = "There was an error retrieving your date of birth.", + ['error_debug_xPlayer_get_height'] = "There was an error retrieving your height.", + ['return_debug_xPlayer_get_first_name'] = "First Name: ~b~%s", + ['return_debug_xPlayer_get_last_name'] = "Last Name: ~b~%s", + ['return_debug_xPlayer_get_full_name'] = "Full Name: ~b~%s", + ['return_debug_xPlayer_get_sex'] = "Sex: ~b~%s", + ['return_debug_xPlayer_get_dob'] = "DOB: ~b~%s", + ['return_debug_xPlayer_get_height'] = "Height: ~b~%s Inches", + ['data_incorrect'] = 'Data entered incorrectly. Please try again.', + ['invalid_format'] = 'Data formatted incorrectly. Please try again.', + ['no_identifier'] = 'There was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.', + ['missing_identity'] = 'There was an error loading your character!\nError code: identity-missing\n\nIt seems like your identity is missing, try connecting again.', + ['deleted_identity'] = 'Your character has been deleted. Please login again in order to create a new character.' } diff --git a/server/main.lua b/server/main.lua index 3fbc4962..ede6b5bd 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,95 +1,455 @@ ESX = nil local playerIdentity = {} - +local alreadyRegistered = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) - deferrals.defer() - local playerId, identifier = source - Citizen.Wait(100) - - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, 'license:') then - identifier = string.sub(v, 9) - break +if Config.UseDeferrals then + AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) + deferrals.defer() + local playerId, identifier = source + Citizen.Wait(100) + + if Config.UseSteamID then + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + if string.match(v, 'steam:') then + identifier = v + break + end + end + else + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + if string.match(v, 'license:') then + identifier = string.sub(v, 9) + break + end + end end - end + + if identifier then + MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { + ['@identifier'] = identifier + }, function(result) + if result[1] then + if result[1].firstname then + playerIdentity[identifier] = { + firstName = result[1].firstname, + lastName = result[1].lastname, + dateOfBirth = result[1].dateofbirth, + sex = result[1].sex, + height = result[1].height + } + + deferrals.done() + else + deferrals.presentCard([==[{"type": "AdaptiveCard","body":[{"type":"Container","items":[{"type":"ColumnSet","columns":[{"type":"Column","items":[{"type":"Input.Text","placeholder":"First Name","id":"firstname","maxLength":15},{"type":"Input.Text","placeholder":"Date of Birth (MM/DD/YYYY)","id":"dateofbirth","maxLength":10}],"width":"stretch"},{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Last Name","id":"lastname","maxLength":15},{"type":"Input.Text","placeholder":"Height (48-96 inches)","id":"height","maxLength":2}]}]},{"type":"Input.ChoiceSet","placeholder":"Sex","choices":[{"title":"Male","value":"m"},{"title":"Female","value":"f"}],"style":"expanded","id":"sex"}]},{"type": "ActionSet","actions": [{"type":"Action.Submit","title":"Submit"}]}],"$schema": "http://adaptivecards.io/schemas/adaptive-card.json","version":"1.0"}]==], function(data, rawData) + if data.firstname == '' or data.lastname == '' or data.dateofbirth == '' or data.sex == '' or data.height == '' then + deferrals.done(_U('data_incorrect')) + else + if checkNameFormat(data.firstname) and checkNameFormat(data.lastname) and checkDOBFormat(data.dateofbirth) and checkSexFormat(data.sex) and checkHeightFormat(data.height) then + playerIdentity[identifier] = { + firstName = formatName(data.firstname), + lastName = formatName(data.lastname), + dateOfBirth = data.dateofbirth, + sex = data.sex, + height = tonumber(data.height), + saveToDatabase = true + } + + deferrals.done() + else + deferrals.done(_U('invalid_format')) + end + end + end) + end + else + deferrals.presentCard([==[{"type": "AdaptiveCard","body":[{"type":"Container","items":[{"type":"ColumnSet","columns":[{"type":"Column","items":[{"type":"Input.Text","placeholder":"First Name","id":"firstname","maxLength":15},{"type":"Input.Text","placeholder":"Date of Birth (MM/DD/YYYY)","id":"dateofbirth","maxLength":10}],"width":"stretch"},{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Last Name","id":"lastname","maxLength":15},{"type":"Input.Text","placeholder":"Height (48-96 inches)","id":"height","maxLength":2}]}]},{"type":"Input.ChoiceSet","placeholder":"Sex","choices":[{"title":"Male","value":"m"},{"title":"Female","value":"f"}],"style":"expanded","id":"sex"}]},{"type": "ActionSet","actions": [{"type":"Action.Submit","title":"Submit"}]}],"$schema": "http://adaptivecards.io/schemas/adaptive-card.json","version":"1.0"}]==], function(data, rawData) + if data.firstname == '' or data.lastname == '' or data.dateofbirth == '' or data.sex == '' or data.height == '' then + deferrals.done(_U('data_incorrect')) + else + if checkNameFormat(data.firstname) and checkNameFormat(data.lastname) and checkDOBFormat(data.dateofbirth) and checkSexFormat(data.sex) and checkHeightFormat(data.height) then + playerIdentity[identifier] = { + firstName = formatName(data.firstname), + lastName = formatName(data.lastname), + dateOfBirth = data.dateofbirth, + sex = data.sex, + height = tonumber(data.height), + saveToDatabase = true + } + + deferrals.done() + else + deferrals.done(_U('invalid_format')) + end + end + end) + end + end) + else + deferrals.done(_U('no_identifier')) + end + end) + + RegisterNetEvent('esx:playerLoaded') + AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) + if playerIdentity[xPlayer.identifier] then + local currentIdentity = playerIdentity[xPlayer.identifier] + + xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName)) + xPlayer.set('firstName', currentIdentity.firstName) + xPlayer.set('lastName', currentIdentity.lastName) + xPlayer.set('dateofbirth', currentIdentity.dateOfBirth) + xPlayer.set('sex', currentIdentity.sex) + xPlayer.set('height', currentIdentity.height) + + if currentIdentity.saveToDatabase then + saveIdentityToDatabase(xPlayer.identifier, currentIdentity) + end - if identifier then + Citizen.Wait(1000) + alreadyRegistered[xPlayer.identifier] = true + TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source) + + playerIdentity[xPlayer.identifier] = nil + else + xPlayer.kick(_('missing_identity')) + end + end) +elseif not Config.UseDeferrals then + AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) + deferrals.defer() + local playerId, identifier = source + Citizen.Wait(100) + + if Config.UseSteamID then + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + if string.match(v, 'steam:') then + identifier = v + break + end + end + else + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + if string.match(v, 'license:') then + identifier = string.sub(v, 9) + break + end + end + end + + if identifier then + MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { + ['@identifier'] = identifier + }, function(result) + if result[1] then + if result[1].firstname then + playerIdentity[identifier] = { + firstName = result[1].firstname, + lastName = result[1].lastname, + dateOfBirth = result[1].dateofbirth, + sex = result[1].sex, + height = result[1].height + } + + alreadyRegistered[identifier] = true + + deferrals.done() + else + playerIdentity[identifier] = nil + alreadyRegistered[identifier] = false + deferrals.done() + end + else + playerIdentity[identifier] = nil + alreadyRegistered[identifier] = false + deferrals.done() + end + end) + else + deferrals.done(_U('no_identifier')) + end + end) + + AddEventHandler('onResourceStart', function(resource) + if resource == GetCurrentResourceName() then + Citizen.Wait(1000) + + while not ESX do + Citizen.Wait(10) + end + + local xPlayers = ESX.GetPlayers() + + for i=1, #xPlayers, 1 do + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + + if xPlayer then + checkIdentity(xPlayer) + end + end + end + end) + + RegisterNetEvent('esx:playerLoaded') + AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) + if alreadyRegistered[xPlayer.identifier] == true then + local currentIdentity = playerIdentity[xPlayer.identifier] + + xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName)) + xPlayer.set('firstName', currentIdentity.firstName) + xPlayer.set('lastName', currentIdentity.lastName) + xPlayer.set('dateofbirth', currentIdentity.dateOfBirth) + xPlayer.set('sex', currentIdentity.sex) + xPlayer.set('height', currentIdentity.height) + + if currentIdentity.saveToDatabase then + saveIdentityToDatabase(xPlayer.identifier, currentIdentity) + end + + Citizen.Wait(1000) + TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source) + + playerIdentity[xPlayer.identifier] = nil + else + TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) + end + end) + + ESX.RegisterServerCallback('esx_identity:registerIdentity', function(source, cb, data) + local xPlayer = ESX.GetPlayerFromId(source) + + if xPlayer then + if not alreadyRegistered[xPlayer.identifier] then + if checkNameFormat(data.firstname) and checkNameFormat(data.lastname) and checkSexFormat(data.sex) and checkDOBFormat(data.dateofbirth) and checkHeightFormat(data.height) then + playerIdentity[xPlayer.identifier] = { + firstName = formatName(data.firstname), + lastName = formatName(data.lastname), + dateOfBirth = data.dateofbirth, + sex = data.sex, + height = data.height + } + + local currentIdentity = playerIdentity[xPlayer.identifier] + + xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName)) + xPlayer.set('firstName', currentIdentity.firstName) + xPlayer.set('lastName', currentIdentity.lastName) + xPlayer.set('dateofbirth', currentIdentity.dateOfBirth) + xPlayer.set('sex', currentIdentity.sex) + xPlayer.set('height', currentIdentity.height) + + saveIdentityToDatabase(xPlayer.identifier, currentIdentity) + alreadyRegistered[xPlayer.identifier] = true + + playerIdentity[xPlayer.identifier] = nil + cb(true) + else + cb(false) + end + else + cb(false) + end + end + end) + + function checkIdentity(xPlayer) MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { - ['@identifier'] = identifier + ['@identifier'] = xPlayer.identifier }, function(result) if result[1] then - playerIdentity[identifier] = { - firstName = result[1].firstname, - lastName = result[1].lastname, - dateOfBirth = result[1].dateofbirth, - sex = result[1].sex, - height = result[1].height - } + if result[1].firstname then + playerIdentity[xPlayer.identifier] = { + firstName = result[1].firstname, + lastName = result[1].lastname, + dateOfBirth = result[1].dateofbirth, + sex = result[1].sex, + height = result[1].height + } - deferrals.done() + alreadyRegistered[xPlayer.identifier] = true + + setIdentity(xPlayer) + else + playerIdentity[xPlayer.identifier] = nil + alreadyRegistered[xPlayer.identifier] = false + TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) + end else - deferrals.presentCard([==[{"type":"AdaptiveCard","body":[{"type":"Container","items":[{"type":"TextBlock","text":"Identity Registration","horizontalAlignment":"Center","size":"Large","weight":"Bolder"},{"type":"ColumnSet","columns":[{"type":"Column","items":[{"type":"Input.Text","placeholder":"First Name","id":"firstname","maxLength":15}],"width":"stretch"},{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Last Name","id":"lastname","maxLength":15}]}]},{"type":"ColumnSet","columns":[{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Date of Birth (YYYY-MM-DD)","id":"dateofbirth","maxLength":10}],"style":"default"},{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Height (24-96 inches)","id":"height","maxLength":2}]}]},{"type":"Input.ChoiceSet","placeholder":"Sex","choices":[{"title":"Male","value":"m"},{"title":"Female","value":"f"}],"style":"expanded","id":"sex"}],"style":"default","backgroundImage":"https://nischat.se/wp-content/uploads/Light-grey-background-1024x683.jpg"}],"actions":[{"type":"Action.Submit","title":"Submit"}],"$schema":"http://adaptivecards.io/schemas/adaptive-card.json","version":"1.0"}]==], function(data, rawData) - if - data.firstname == '' or - data.lastname == '' or - data.dateofbirth == '' or - data.sex == '' or - data.height == '' - then - deferrals.done(_U('data_incorrect')) - else - if - checkNameFormat(data.firstname) and - checkNameFormat(data.lastname) and - checkDOBFormat(data.dateofbirth) and - checkSexFormat(data.sex) and - checkHeightFormat(data.height) - then - playerIdentity[identifier] = { - firstName = formatName(data.firstname), - lastName = formatName(data.lastname), - dateOfBirth = data.dateofbirth, - sex = data.sex, - height = tonumber(data.height), - saveToDatabase = true - } - - deferrals.done() - else - deferrals.done(_U('invalid_format')) - end - end - end) + TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) end end) - else - deferrals.done(_U('no_identifier')) end -end) -RegisterNetEvent('esx:playerLoaded') -AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) - if playerIdentity[xPlayer.identifier] then - local currentIdentity = playerIdentity[xPlayer.identifier] + function setIdentity(xPlayer) + if alreadyRegistered[xPlayer.identifier] then + local currentIdentity = playerIdentity[xPlayer.identifier] - xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName)) - xPlayer.set('firstName', currentIdentity.firstName) - xPlayer.set('lastName', currentIdentity.lastName) - xPlayer.set('dateofbirth', currentIdentity.dateOfBirth) - xPlayer.set('sex', currentIdentity.sex) - xPlayer.set('height', currentIdentity.height) + xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName)) + xPlayer.set('firstName', currentIdentity.firstName) + xPlayer.set('lastName', currentIdentity.lastName) + xPlayer.set('dateofbirth', currentIdentity.dateOfBirth) + xPlayer.set('sex', currentIdentity.sex) + xPlayer.set('height', currentIdentity.height) - if currentIdentity.saveToDatabase then - SaveIdentityToDatabase(xPlayer.identifier, currentIdentity) + if currentIdentity.saveToDatabase then + saveIdentityToDatabase(xPlayer.identifier, currentIdentity) + end + + playerIdentity[xPlayer.identifier] = nil end - - playerIdentity[xPlayer.identifier] = nil - else - xPlayer.kick(_('missing_identity')) end -end) +end + +if Config.EnableCommands then + ESX.RegisterCommand('char', 'user', function(xPlayer, args, showError) + if xPlayer and xPlayer.getName() then + xPlayer.showNotification(_U('active_character', xPlayer.getName())) + else + xPlayer.showNotification(_U('error_active_character')) + end + end, false, {help = _U('show_active_character')}) + + ESX.RegisterCommand('chardel', 'user', function(xPlayer, args, showError) + if xPlayer and xPlayer.getName() then + if Config.UseDeferrals then + deleteIdentity(xPlayer) + xPlayer.showNotification(_U('deleted_character')) + playerIdentity[xPlayer.identifier] = nil + alreadyRegistered[xPlayer.identifier] = false + Citizen.Wait(2500) + xPlayer.kick(_('deleted_identity')) + else + deleteIdentity(xPlayer) + xPlayer.showNotification(_U('deleted_character')) + playerIdentity[xPlayer.identifier] = nil + alreadyRegistered[xPlayer.identifier] = false + TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) + end + else + xPlayer.showNotification(_U('error_delete_character')) + end + end, false, {help = _U('delete_character')}) +end + +if Config.EnableDebugging then + ESX.RegisterCommand('xPlayerGetFirstName', 'user', function(xPlayer, args, showError) + if xPlayer and xPlayer.get('firstName') then + xPlayer.showNotification(_U('return_debug_xPlayer_get_first_name', xPlayer.get('firstName'))) + else + xPlayer.showNotification(_U('error_debug_xPlayer_get_first_name')) + end + end, false, {help = _U('debug_xPlayer_get_first_name')}) + + ESX.RegisterCommand('xPlayerGetLastName', 'user', function(xPlayer, args, showError) + if xPlayer and xPlayer.get('lastName') then + xPlayer.showNotification(_U('return_debug_xPlayer_get_last_name', xPlayer.get('lastName'))) + else + xPlayer.showNotification(_U('error_debug_xPlayer_get_last_name')) + end + end, false, {help = _U('debug_xPlayer_get_last_name')}) + + ESX.RegisterCommand('xPlayerGetFullName', 'user', function(xPlayer, args, showError) + if xPlayer and xPlayer.getName() then + xPlayer.showNotification(_U('return_debug_xPlayer_get_full_name', xPlayer.getName())) + else + xPlayer.showNotification(_U('error_debug_xPlayer_get_full_name')) + end + end, false, {help = _U('debug_xPlayer_get_full_name')}) + + ESX.RegisterCommand('xPlayerGetSex', 'user', function(xPlayer, args, showError) + if xPlayer and xPlayer.get('sex') then + xPlayer.showNotification(_U('return_debug_xPlayer_get_sex', xPlayer.get('sex'))) + else + xPlayer.showNotification(_U('error_debug_xPlayer_get_sex')) + end + end, false, {help = _U('debug_xPlayer_get_sex')}) + + ESX.RegisterCommand('xPlayerGetDOB', 'user', function(xPlayer, args, showError) + if xPlayer and xPlayer.get('dateofbirth') then + xPlayer.showNotification(_U('return_debug_xPlayer_get_dob', xPlayer.get('dateofbirth'))) + else + xPlayer.showNotification(_U('error_debug_xPlayer_get_dob')) + end + end, false, {help = _U('debug_xPlayer_get_dob')}) + + ESX.RegisterCommand('xPlayerGetHeight', 'user', function(xPlayer, args, showError) + if xPlayer and xPlayer.get('height') then + xPlayer.showNotification(_U('return_debug_xPlayer_get_height', xPlayer.get('height'))) + else + xPlayer.showNotification(_U('error_debug_xPlayer_get_height')) + end + end, false, {help = _U('debug_xPlayer_get_height')}) +end + +function deleteIdentity(xPlayer) + if alreadyRegistered[xPlayer.identifier] then + xPlayer.setName(('%s %s'):format(nil, nil)) + xPlayer.set('firstName', nil) + xPlayer.set('lastName', nil) + xPlayer.set('dateofbirth', nil) + xPlayer.set('sex', nil) + xPlayer.set('height', nil) + + deleteIdentityFromDatabase(xPlayer) + end +end + +function saveIdentityToDatabase(identifier, identity) + MySQL.Sync.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', { + ['@identifier'] = identifier, + ['@firstname'] = identity.firstName, + ['@lastname'] = identity.lastName, + ['@dateofbirth'] = identity.dateOfBirth, + ['@sex'] = identity.sex, + ['@height'] = identity.height + }) +end + +function deleteIdentityFromDatabase(xPlayer) + MySQL.Sync.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height , skin = @skin WHERE identifier = @identifier', { + ['@identifier'] = xPlayer.identifier, + ['@firstname'] = NULL, + ['@lastname'] = NULL, + ['@dateofbirth'] = NULL, + ['@sex'] = NULL, + ['@height'] = NULL, + ['@skin'] = NULL + }) + + MySQL.Sync.execute('UPDATE addon_account_data SET money = 0 WHERE account_name = @account_name AND owner = @owner', { + ['@account_name'] = 'bank_savings', + ['@owner'] = xPlayer.identifier + }) + + MySQL.Sync.execute('UPDATE addon_account_data SET money = 0 WHERE account_name = @account_name AND owner = @owner', { + ['@account_name'] = 'caution', + ['@owner'] = xPlayer.identifier + }) + + MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { + ['@data'] = '\'{}\'', + ['@name'] = 'user_ears', + ['@owner'] = xPlayer.identifier + }) + + MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { + ['@data'] = '\'{}\'', + ['@name'] = 'user_glasses', + ['@owner'] = xPlayer.identifier + }) + + MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { + ['@data'] = '\'{}\'', + ['@name'] = 'user_helmet', + ['@owner'] = xPlayer.identifier + }) + + MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { + ['@data'] = '\'{}\'', + ['@name'] = 'user_mask', + ['@owner'] = xPlayer.identifier + }) +end function checkNameFormat(name) if not checkAlphanumeric(name) then @@ -157,11 +517,11 @@ function checkForNumbers(str) end function checkDate(str) - if string.match(str, '(%d%d%d%d)-(%d%d)-(%d%d)') ~= nil then - local y, m, d = string.match(str, '(%d+)-(%d+)-(%d+)') - y = tonumber(y) + if string.match(str, '(%d%d)/(%d%d)/(%d%d%d%d)') ~= nil then + local m, d, y = string.match(str, '(%d+)/(%d+)/(%d+)') m = tonumber(m) d = tonumber(d) + y = tonumber(y) if ((d <= 0) or (d > 31)) or ((m <= 0) or (m > 12)) or ((y <= Config.LowestYear) or (y > Config.HighestYear)) then return false elseif m == 4 or m == 6 or m == 9 or m == 11 then @@ -195,14 +555,3 @@ function checkDate(str) return false end end - -function SaveIdentityToDatabase(identifier, identity) - MySQL.Sync.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', { - ['@identifier'] = identifier, - ['@firstname'] = identity.firstName, - ['@lastname'] = identity.lastName, - ['@dateofbirth'] = identity.dateOfBirth, - ['@sex'] = identity.sex, - ['@height'] = identity.height - }) -end From eff4bc93844dbf31d3fee8017e2f1c80260f9f8b Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Sat, 16 May 2020 03:32:21 -0500 Subject: [PATCH 64/78] Fix delete character for deferral method --- server/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/main.lua b/server/main.lua index ede6b5bd..94385d09 100644 --- a/server/main.lua +++ b/server/main.lua @@ -312,12 +312,12 @@ if Config.EnableCommands then ESX.RegisterCommand('chardel', 'user', function(xPlayer, args, showError) if xPlayer and xPlayer.getName() then if Config.UseDeferrals then + xPlayer.kick(_('deleted_identity')) + Citizen.Wait(1500) deleteIdentity(xPlayer) xPlayer.showNotification(_U('deleted_character')) playerIdentity[xPlayer.identifier] = nil alreadyRegistered[xPlayer.identifier] = false - Citizen.Wait(2500) - xPlayer.kick(_('deleted_identity')) else deleteIdentity(xPlayer) xPlayer.showNotification(_U('deleted_character')) From 738c109c0d188d895856a96cf1d667ddc09c3698 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Sat, 16 May 2020 17:02:21 -0500 Subject: [PATCH 65/78] Update config.lua - Improve Config Documentation - Fix Config.UseDeferrals to default false --- config.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/config.lua b/config.lua index 3d37568a..3d9773dd 100644 --- a/config.lua +++ b/config.lua @@ -1,12 +1,30 @@ Config = {} Config.Locale = 'en' + +-- [Config.EnableCommands] +-- Enables Commands Such As /char and /chardel Config.EnableCommands = true -Config.UseSteamID = false -Config.UseDeferrals = true + +-- [Config.UseSteamID] +-- Changes the identifiers from Rockstar License To Steam. In order to use this, you will have to have +-- made edits to your ESX in order to use Steam identifiers all around, because new ESX uses Rockstar +-- license. I just made it easier for people that convert to steam identifiers. +Config.UseSteamID = false + +-- [Config.UseDeferrals] +-- EXPERIMENTAL Character Registration Method. This will allow players to create identities in deferrals +-- before they ever join the server. This still needs time of testing to see what issues that we have +-- in linux servers and windows servers, and which artifacts it will work on, and which artifacts it +-- will not work on. If you don't know a lot about this, I would suggest to set it false for now. +Config.UseDeferrals = false -- EXPERIMENTAL Character Registration Method. + + +-- These values are for the second input validation in server/main.lua Config.MaxNameLength = 16 Config.MinHeight = 48 Config.MaxHeight = 96 Config.LowestYear = 1900 Config.HighestYear = 2020 -Config.EnableDebugging = false \ No newline at end of file +-- You can leave this set to false, unless you are trying to solve an issue with your identity. +Config.EnableDebugging = false From 05d84b38673f86a3dc9d11ea04a5f62d30d20e09 Mon Sep 17 00:00:00 2001 From: shortybsd Date: Sat, 16 May 2020 22:57:28 -0500 Subject: [PATCH 66/78] Update esx_identity.sql INT - Integer display width is deprecated and will be removed in a future release. --- esx_identity.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esx_identity.sql b/esx_identity.sql index c9e411d5..ed5a3b06 100644 --- a/esx_identity.sql +++ b/esx_identity.sql @@ -5,5 +5,5 @@ ALTER TABLE `users` ADD COLUMN `lastname` VARCHAR(16) NULL DEFAULT NULL, ADD COLUMN `dateofbirth` VARCHAR(10) NULL DEFAULT NULL, ADD COLUMN `sex` VARCHAR(1) NULL DEFAULT NULL, - ADD COLUMN `height` INT(2) NULL DEFAULT NULL -; \ No newline at end of file + ADD COLUMN `height` INT NULL DEFAULT NULL +; From 201bca17962a465affac945b26d312a3108d6782 Mon Sep 17 00:00:00 2001 From: ArkSeyonet <31637812+ArkSeyonet@users.noreply.github.com> Date: Sun, 17 May 2020 04:24:44 -0500 Subject: [PATCH 67/78] Update esx_identity - Add config for full character wipe on character deletion --- config.lua | 2 +- server/main.lua | 58 +++++++++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/config.lua b/config.lua index 3d37568a..b4ac8516 100644 --- a/config.lua +++ b/config.lua @@ -8,5 +8,5 @@ Config.MinHeight = 48 Config.MaxHeight = 96 Config.LowestYear = 1900 Config.HighestYear = 2020 - +Config.FullCharDelete = false Config.EnableDebugging = false \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index ede6b5bd..eb9edfa3 100644 --- a/server/main.lua +++ b/server/main.lua @@ -416,39 +416,41 @@ function deleteIdentityFromDatabase(xPlayer) ['@skin'] = NULL }) - MySQL.Sync.execute('UPDATE addon_account_data SET money = 0 WHERE account_name = @account_name AND owner = @owner', { - ['@account_name'] = 'bank_savings', - ['@owner'] = xPlayer.identifier - }) + if Config.FullCharDelete then + MySQL.Sync.execute('UPDATE addon_account_data SET money = 0 WHERE account_name = @account_name AND owner = @owner', { + ['@account_name'] = 'bank_savings', + ['@owner'] = xPlayer.identifier + }) - MySQL.Sync.execute('UPDATE addon_account_data SET money = 0 WHERE account_name = @account_name AND owner = @owner', { - ['@account_name'] = 'caution', - ['@owner'] = xPlayer.identifier - }) + MySQL.Sync.execute('UPDATE addon_account_data SET money = 0 WHERE account_name = @account_name AND owner = @owner', { + ['@account_name'] = 'caution', + ['@owner'] = xPlayer.identifier + }) - MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { - ['@data'] = '\'{}\'', - ['@name'] = 'user_ears', - ['@owner'] = xPlayer.identifier - }) + MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { + ['@data'] = '\'{}\'', + ['@name'] = 'user_ears', + ['@owner'] = xPlayer.identifier + }) - MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { - ['@data'] = '\'{}\'', - ['@name'] = 'user_glasses', - ['@owner'] = xPlayer.identifier - }) + MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { + ['@data'] = '\'{}\'', + ['@name'] = 'user_glasses', + ['@owner'] = xPlayer.identifier + }) - MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { - ['@data'] = '\'{}\'', - ['@name'] = 'user_helmet', - ['@owner'] = xPlayer.identifier - }) + MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { + ['@data'] = '\'{}\'', + ['@name'] = 'user_helmet', + ['@owner'] = xPlayer.identifier + }) - MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { - ['@data'] = '\'{}\'', - ['@name'] = 'user_mask', - ['@owner'] = xPlayer.identifier - }) + MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', { + ['@data'] = '\'{}\'', + ['@name'] = 'user_mask', + ['@owner'] = xPlayer.identifier + }) + end end function checkNameFormat(name) From 84aa487dc3ce58ce55befb263fbe0766cea1639d Mon Sep 17 00:00:00 2001 From: RikoDEV <18230443+RikoDEV@users.noreply.github.com> Date: Sat, 25 Jul 2020 00:38:24 +0200 Subject: [PATCH 68/78] Adding Polish translation. (#105) * Create pl.lua * Update fxmanifest.lua --- fxmanifest.lua | 2 ++ locales/pl.lua | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 locales/pl.lua diff --git a/fxmanifest.lua b/fxmanifest.lua index 09853b6a..4c93baa3 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -11,6 +11,7 @@ server_scripts { '@mysql-async/lib/MySQL.lua', 'locales/en.lua', 'locales/cs.lua', + 'locales/pl.lua', 'config.lua', 'server/main.lua' } @@ -19,6 +20,7 @@ client_scripts { '@es_extended/locale.lua', 'locales/en.lua', 'locales/cs.lua', + 'locales/pl.lua', 'config.lua', 'client/main.lua' } diff --git a/locales/pl.lua b/locales/pl.lua new file mode 100644 index 00000000..72b2d38a --- /dev/null +++ b/locales/pl.lua @@ -0,0 +1,33 @@ +Locales['pl'] = { + ['show_active_character'] = 'Pokaż aktywną postać', + ['active_character'] = 'Aktywna postać: ~b~%s~s~', + ['error_active_character'] = "Podczas pobierania Twojego imienia wystąpił błąd. Proszę skontaktować się z administratorem.", + ['delete_character'] = 'Usuń swoją postać i stwórz nową', + ['deleted_character'] = 'Twoja postać została usunięta.', + ['error_delete_character'] = "Wystąpił błąd podczas usuwania twojej postaci. Proszę skontaktować się z administratorem.", + ['thank_you_for_registering'] = "Dziękujemy za rejestrację. Baw się dobrze.", + ['registration_error'] = "Wystąpił błąd podczas rejestracji. Proszę skontaktować się z administratorem.", + ['debug_xPlayer_get_first_name'] = "Podaj swoje imię", + ['debug_xPlayer_get_last_name'] = "Podaj swoje nazwisko", + ['debug_xPlayer_get_full_name'] = "Podaj swoją pełną nazwę", + ['debug_xPlayer_get_sex'] = "Podaj swoją płeć", + ['debug_xPlayer_get_dob'] = "Podaj swoją datę urodzenia", + ['debug_xPlayer_get_height'] = "Podaj swój wzrost", + ['error_debug_xPlayer_get_first_name'] = "Podczas pobierania twojego imienia wystąpił błąd.", + ['error_debug_xPlayer_get_last_name'] = "Podczas pobierania twojego nazwiska wystąpił błąd.", + ['error_debug_xPlayer_get_full_name'] = "Podczas pobierania twojego pełnego imienia wystąpił błąd.", + ['error_debug_xPlayer_get_sex'] = "Podczas pobierania twojej płci wystąpił błąd.", + ['error_debug_xPlayer_get_dob'] = "Podczas pobierania daty urodzenia wystąpił błąd.", + ['error_debug_xPlayer_get_height'] = "Podczas pobierania wzrostu wystąpił błąd.", + ['return_debug_xPlayer_get_first_name'] = "Imię: ~b~%s", + ['return_debug_xPlayer_get_last_name'] = "Nazwisko: ~b~%s", + ['return_debug_xPlayer_get_full_name'] = "Pełna nazwa: ~b~%s", + ['return_debug_xPlayer_get_sex'] = "Płeć: ~b~%s", + ['return_debug_xPlayer_get_dob'] = "Data urodzenia: ~b~%s", + ['return_debug_xPlayer_get_height'] = "Wzrost: ~b~%s centymetrów", + ['data_incorrect'] = 'Data została wprowadzona niepoprawnie. Proszę spróbuj ponownie.', + ['invalid_format'] = 'Data została wprowadzona niepoprawnie. Proszę spróbuj ponownie.', + ['no_identifier'] = 'Wystąpił błąd podczas ładowania twojej postaci!\nKod błędu: identifier-missing\n\nPrzyczyna tego błędu nie jest znana, nie można znaleźć Twojego identyfikatora. Wróć później lub zgłoś ten problem zespołowi administracyjnemu serwera.', + ['missing_identity'] = 'Wystąpił błąd podczas ładowania twojej postaci!\nKod błędu: identity-missing\n\nWygląda na to, że brakuje Twojej tożsamości, spróbuj połączyć się ponownie.', + ['deleted_identity'] = 'Twoja postać została usunięta. Dołącz ponownie, aby utworzyć nową postać.' +} From cade18e2de2f2084b2880031b3e8425d1433ad5f Mon Sep 17 00:00:00 2001 From: Jougito - Kheros Date: Mon, 27 Jul 2020 00:40:08 +0200 Subject: [PATCH 69/78] Spanish translation implemented (#119) --- fxmanifest.lua | 2 ++ locales/es.lua | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 locales/es.lua diff --git a/fxmanifest.lua b/fxmanifest.lua index 4c93baa3..55b90223 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -10,6 +10,7 @@ server_scripts { '@es_extended/locale.lua', '@mysql-async/lib/MySQL.lua', 'locales/en.lua', + 'locales/es.lua', 'locales/cs.lua', 'locales/pl.lua', 'config.lua', @@ -19,6 +20,7 @@ server_scripts { client_scripts { '@es_extended/locale.lua', 'locales/en.lua', + 'locales/es.lua', 'locales/cs.lua', 'locales/pl.lua', 'config.lua', diff --git a/locales/es.lua b/locales/es.lua new file mode 100644 index 00000000..2352d302 --- /dev/null +++ b/locales/es.lua @@ -0,0 +1,33 @@ +Locales['es'] = { + ['show_active_character'] = 'Mostrar personaje activo', + ['active_character'] = 'Personaje activo: ~b~%s~s~', + ['error_active_character'] = "Se produjo un error al recuperar tu nombre. Por favor contacta con un administrador", + ['delete_character'] = 'Elimina tu personaje y crea uno nuevo', + ['deleted_character'] = 'Tu personaje ha sido eliminado', + ['error_delete_character'] = "Se produjo un error al eliminar tu personaje. Por favor contacta con un administrador", + ['thank_you_for_registering'] = "Gracias por registrarte. Que te diviertas", + ['registration_error'] = "Se ha producido un error durante el registro. Por favor contacta con un administrador", + ['debug_xPlayer_get_first_name'] = "Devuelve tu nombre", + ['debug_xPlayer_get_last_name'] = "Devuelve tu apellido", + ['debug_xPlayer_get_full_name'] = "Devuelve tu nombre completo", + ['debug_xPlayer_get_sex'] = "Devuelve tu sexo", + ['debug_xPlayer_get_dob'] = "Devuelve tu fecha de nacimiento", + ['debug_xPlayer_get_height'] = "Devuelve tu altura", + ['error_debug_xPlayer_get_first_name'] = "Se produjo un error al recuperar tu nombre", + ['error_debug_xPlayer_get_last_name'] = "Se produjo un error al recuperar tu apellido", + ['error_debug_xPlayer_get_full_name'] = "Se produjo un error al recuperar tu nombre completo", + ['error_debug_xPlayer_get_sex'] = "Se produjo un error al recuperar tu sexo", + ['error_debug_xPlayer_get_dob'] = "Se produjo un error al recuperar tu fecha de nacimiento", + ['error_debug_xPlayer_get_height'] = "Se produjo un error al recuperar tu altura", + ['return_debug_xPlayer_get_first_name'] = "Nombre: ~b~%s", + ['return_debug_xPlayer_get_last_name'] = "Apellido: ~b~%s", + ['return_debug_xPlayer_get_full_name'] = "Nombre completo: ~b~%s", + ['return_debug_xPlayer_get_sex'] = "Sexo: ~b~%s", + ['return_debug_xPlayer_get_dob'] = "Fecha de nacimiento: ~b~%s", + ['return_debug_xPlayer_get_height'] = "Altura: ~b~%s centímetros", + ['data_incorrect'] = 'Datos introducidos de forma incorrecta. Inténtalo de nuevo', + ['invalid_format'] = 'Datos con formato incorrecto. Inténtalo de nuevo', + ['no_identifier'] = '¡Se ha producido un error al cargar tu personaje!\nCódigo de error: identifier-missing\n\nSe desconoce la causa de este error, no se pudo encontrar su identificador. Regrese más tarde o informe este problema al equipo de administración del servidor', + ['missing_identity'] = '¡Se ha producido un error al cargar tu personaje!\nCódigo de error: identity-missing\n\nParece que falta su identidad, intente conectarse nuevamente', + ['deleted_identity'] = 'Tu personaje ha sido borrado. Vuelva a iniciar sesión para crear un nuevo personaje' +} From 9691b2bade375ba55cc2a619b7197a11bb32dc9b Mon Sep 17 00:00:00 2001 From: protaknium <49377950+protaknium@users.noreply.github.com> Date: Thu, 30 Jul 2020 19:06:51 +0300 Subject: [PATCH 70/78] Added finnish locale --- locales/fi.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 locales/fi.lua diff --git a/locales/fi.lua b/locales/fi.lua new file mode 100644 index 00000000..a1720782 --- /dev/null +++ b/locales/fi.lua @@ -0,0 +1,33 @@ +Locales['fi'] = { + ['show_active_character'] = 'Näytä nykyinen hahmosi', + ['active_character'] = 'Nykyinen hahmosi: ~b~%s~s~', + ['error_active_character'] = "Hahmosi hakemisessa ilmeni ongelma. Ota yhteyttä ylläpitoon.", + ['delete_character'] = 'Poista hahmosi ja luo uusi.', + ['deleted_character'] = 'Hahmosi on poistetu.', + ['error_delete_character'] = "Hahmosi poistossa ilmeni ongelma. Ota yhteyttä ylläpitoon.", + ['thank_you_for_registering'] = "Kiitos registeröitymisestä. Pidä hauskaa!", + ['registration_error'] = "Registeröinnissä ilmeni ongelma. Ota yhteyttä ylläpitoon.", + ['debug_xPlayer_get_first_name'] = "Palauta etunimi", + ['debug_xPlayer_get_last_name'] = "Palauta sukunimi", + ['debug_xPlayer_get_full_name'] = "Palauta kokonimi", + ['debug_xPlayer_get_sex'] = "Palauta sukupuoli", + ['debug_xPlayer_get_dob'] = "Palauta syntymäpäivä", + ['debug_xPlayer_get_height'] = "Palauta pituus", + ['error_debug_xPlayer_get_first_name'] = "Hahmosi etunimen haussa ilmeni ongelma.", + ['error_debug_xPlayer_get_last_name'] = "Hahmosi sukunimen haussa ilmeni ongelma.", + ['error_debug_xPlayer_get_full_name'] = "Hahmosi kokonimen haussa ilmeni ongelma.", + ['error_debug_xPlayer_get_sex'] = "Hahmosi sukupuolen haussa ilmeni ongelma.", + ['error_debug_xPlayer_get_dob'] = "Hahmosi syntymäpäivän haussa ilmeni ongelma.", + ['error_debug_xPlayer_get_height'] = "Hahmosi pituuden haussa ilmeni ongelma.", + ['return_debug_xPlayer_get_first_name'] = "Etunimi: ~b~%s", + ['return_debug_xPlayer_get_last_name'] = "Sukunimi: ~b~%s", + ['return_debug_xPlayer_get_full_name'] = "Kokonimi: ~b~%s", + ['return_debug_xPlayer_get_sex'] = "Sukupuoli: ~b~%s", + ['return_debug_xPlayer_get_dob'] = "Syntymäpäivä: ~b~%s", + ['return_debug_xPlayer_get_height'] = "Pituus: ~b~%s CM", + ['data_incorrect'] = 'Data syötetty väärin. Yritä uudelleen.', + ['invalid_format'] = 'Data syötetty väärässä muodossa. Yritä uudelleen.', + ['no_identifier'] = 'Hahmosi lataamisessa ilmeni ongelma!\nVirhekoodi: identifier-missing\n\nVirhekoodin syytä ei tiedetä, joten ota yhteyttä ylläpitoon.', + ['missing_identity'] = 'Hahmosi lataamisessa ilmeni ongelma!\nError code: identity-missing\n\nNäyttää että hahmoasi ei ole olemassa. Kokeile yhdistää uudelleen tai ota yhteyttä ylläpitoon', + ['deleted_identity'] = 'Hahmosi on poistetu. Yhdistä uudestaan palvelimelle luodaksesi uuden hahmosi.' +} From 0ddd569fc1df7ddd80e2af01f8e4efc40b3c7553 Mon Sep 17 00:00:00 2001 From: protaknium <49377950+protaknium@users.noreply.github.com> Date: Thu, 30 Jul 2020 19:07:09 +0300 Subject: [PATCH 71/78] Added Finnish locale --- fi.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 fi.lua diff --git a/fi.lua b/fi.lua new file mode 100644 index 00000000..a1720782 --- /dev/null +++ b/fi.lua @@ -0,0 +1,33 @@ +Locales['fi'] = { + ['show_active_character'] = 'Näytä nykyinen hahmosi', + ['active_character'] = 'Nykyinen hahmosi: ~b~%s~s~', + ['error_active_character'] = "Hahmosi hakemisessa ilmeni ongelma. Ota yhteyttä ylläpitoon.", + ['delete_character'] = 'Poista hahmosi ja luo uusi.', + ['deleted_character'] = 'Hahmosi on poistetu.', + ['error_delete_character'] = "Hahmosi poistossa ilmeni ongelma. Ota yhteyttä ylläpitoon.", + ['thank_you_for_registering'] = "Kiitos registeröitymisestä. Pidä hauskaa!", + ['registration_error'] = "Registeröinnissä ilmeni ongelma. Ota yhteyttä ylläpitoon.", + ['debug_xPlayer_get_first_name'] = "Palauta etunimi", + ['debug_xPlayer_get_last_name'] = "Palauta sukunimi", + ['debug_xPlayer_get_full_name'] = "Palauta kokonimi", + ['debug_xPlayer_get_sex'] = "Palauta sukupuoli", + ['debug_xPlayer_get_dob'] = "Palauta syntymäpäivä", + ['debug_xPlayer_get_height'] = "Palauta pituus", + ['error_debug_xPlayer_get_first_name'] = "Hahmosi etunimen haussa ilmeni ongelma.", + ['error_debug_xPlayer_get_last_name'] = "Hahmosi sukunimen haussa ilmeni ongelma.", + ['error_debug_xPlayer_get_full_name'] = "Hahmosi kokonimen haussa ilmeni ongelma.", + ['error_debug_xPlayer_get_sex'] = "Hahmosi sukupuolen haussa ilmeni ongelma.", + ['error_debug_xPlayer_get_dob'] = "Hahmosi syntymäpäivän haussa ilmeni ongelma.", + ['error_debug_xPlayer_get_height'] = "Hahmosi pituuden haussa ilmeni ongelma.", + ['return_debug_xPlayer_get_first_name'] = "Etunimi: ~b~%s", + ['return_debug_xPlayer_get_last_name'] = "Sukunimi: ~b~%s", + ['return_debug_xPlayer_get_full_name'] = "Kokonimi: ~b~%s", + ['return_debug_xPlayer_get_sex'] = "Sukupuoli: ~b~%s", + ['return_debug_xPlayer_get_dob'] = "Syntymäpäivä: ~b~%s", + ['return_debug_xPlayer_get_height'] = "Pituus: ~b~%s CM", + ['data_incorrect'] = 'Data syötetty väärin. Yritä uudelleen.', + ['invalid_format'] = 'Data syötetty väärässä muodossa. Yritä uudelleen.', + ['no_identifier'] = 'Hahmosi lataamisessa ilmeni ongelma!\nVirhekoodi: identifier-missing\n\nVirhekoodin syytä ei tiedetä, joten ota yhteyttä ylläpitoon.', + ['missing_identity'] = 'Hahmosi lataamisessa ilmeni ongelma!\nError code: identity-missing\n\nNäyttää että hahmoasi ei ole olemassa. Kokeile yhdistää uudelleen tai ota yhteyttä ylläpitoon', + ['deleted_identity'] = 'Hahmosi on poistetu. Yhdistä uudestaan palvelimelle luodaksesi uuden hahmosi.' +} From 9ebf1eef21f97e69b6bfe3026ba750157af04448 Mon Sep 17 00:00:00 2001 From: protaknium <49377950+protaknium@users.noreply.github.com> Date: Thu, 30 Jul 2020 19:07:50 +0300 Subject: [PATCH 72/78] Edited fxmanifest to read and use finnish locales --- fxmanifest.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fxmanifest.lua b/fxmanifest.lua index 55b90223..72cf2823 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -13,6 +13,7 @@ server_scripts { 'locales/es.lua', 'locales/cs.lua', 'locales/pl.lua', + 'locales/fi.lua', 'config.lua', 'server/main.lua' } @@ -23,6 +24,7 @@ client_scripts { 'locales/es.lua', 'locales/cs.lua', 'locales/pl.lua', + 'locales/fi.lua', 'config.lua', 'client/main.lua' } From ff8f636d41678d273319e6ae476eae8d43ac0318 Mon Sep 17 00:00:00 2001 From: protaknium <49377950+protaknium@users.noreply.github.com> Date: Thu, 30 Jul 2020 19:08:13 +0300 Subject: [PATCH 73/78] Delete fi.lua --- fi.lua | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 fi.lua diff --git a/fi.lua b/fi.lua deleted file mode 100644 index a1720782..00000000 --- a/fi.lua +++ /dev/null @@ -1,33 +0,0 @@ -Locales['fi'] = { - ['show_active_character'] = 'Näytä nykyinen hahmosi', - ['active_character'] = 'Nykyinen hahmosi: ~b~%s~s~', - ['error_active_character'] = "Hahmosi hakemisessa ilmeni ongelma. Ota yhteyttä ylläpitoon.", - ['delete_character'] = 'Poista hahmosi ja luo uusi.', - ['deleted_character'] = 'Hahmosi on poistetu.', - ['error_delete_character'] = "Hahmosi poistossa ilmeni ongelma. Ota yhteyttä ylläpitoon.", - ['thank_you_for_registering'] = "Kiitos registeröitymisestä. Pidä hauskaa!", - ['registration_error'] = "Registeröinnissä ilmeni ongelma. Ota yhteyttä ylläpitoon.", - ['debug_xPlayer_get_first_name'] = "Palauta etunimi", - ['debug_xPlayer_get_last_name'] = "Palauta sukunimi", - ['debug_xPlayer_get_full_name'] = "Palauta kokonimi", - ['debug_xPlayer_get_sex'] = "Palauta sukupuoli", - ['debug_xPlayer_get_dob'] = "Palauta syntymäpäivä", - ['debug_xPlayer_get_height'] = "Palauta pituus", - ['error_debug_xPlayer_get_first_name'] = "Hahmosi etunimen haussa ilmeni ongelma.", - ['error_debug_xPlayer_get_last_name'] = "Hahmosi sukunimen haussa ilmeni ongelma.", - ['error_debug_xPlayer_get_full_name'] = "Hahmosi kokonimen haussa ilmeni ongelma.", - ['error_debug_xPlayer_get_sex'] = "Hahmosi sukupuolen haussa ilmeni ongelma.", - ['error_debug_xPlayer_get_dob'] = "Hahmosi syntymäpäivän haussa ilmeni ongelma.", - ['error_debug_xPlayer_get_height'] = "Hahmosi pituuden haussa ilmeni ongelma.", - ['return_debug_xPlayer_get_first_name'] = "Etunimi: ~b~%s", - ['return_debug_xPlayer_get_last_name'] = "Sukunimi: ~b~%s", - ['return_debug_xPlayer_get_full_name'] = "Kokonimi: ~b~%s", - ['return_debug_xPlayer_get_sex'] = "Sukupuoli: ~b~%s", - ['return_debug_xPlayer_get_dob'] = "Syntymäpäivä: ~b~%s", - ['return_debug_xPlayer_get_height'] = "Pituus: ~b~%s CM", - ['data_incorrect'] = 'Data syötetty väärin. Yritä uudelleen.', - ['invalid_format'] = 'Data syötetty väärässä muodossa. Yritä uudelleen.', - ['no_identifier'] = 'Hahmosi lataamisessa ilmeni ongelma!\nVirhekoodi: identifier-missing\n\nVirhekoodin syytä ei tiedetä, joten ota yhteyttä ylläpitoon.', - ['missing_identity'] = 'Hahmosi lataamisessa ilmeni ongelma!\nError code: identity-missing\n\nNäyttää että hahmoasi ei ole olemassa. Kokeile yhdistää uudelleen tai ota yhteyttä ylläpitoon', - ['deleted_identity'] = 'Hahmosi on poistetu. Yhdistä uudestaan palvelimelle luodaksesi uuden hahmosi.' -} From c48b75d928ae4cfc8f00e8e3274cc137b8fc45b5 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 5 Apr 2021 22:10:22 +0100 Subject: [PATCH 74/78] Fixes(maybe --- client/main.lua | 4 +--- config.lua | 6 +++--- server/main.lua | 27 ++++++--------------------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/client/main.lua b/client/main.lua index 238a485e..59de7400 100644 --- a/client/main.lua +++ b/client/main.lua @@ -65,7 +65,7 @@ if not Config.UseDeferrals then Citizen.CreateThread(function() while true do - Citizen.Wait(0) + Citizen.Wait(5) if guiEnabled then DisableControlAction(0, 1, true) -- LookLeftRight @@ -87,8 +87,6 @@ if not Config.UseDeferrals then DisableControlAction(0, 143, true) -- disable melee DisableControlAction(0, 75, true) -- disable exit vehicle DisableControlAction(27, 75, true) -- disable exit vehicle - else - Citizen.Wait(500) end end end) diff --git a/config.lua b/config.lua index 226744be..3bd35f42 100644 --- a/config.lua +++ b/config.lua @@ -20,11 +20,11 @@ Config.UseDeferrals = false -- EXPERIMENTAL Character Registration Method. -- These values are for the second input validation in server/main.lua -Config.MaxNameLength = 16 -Config.MinHeight = 48 +Config.MaxNameLength = 20 +Config.MinHeight = 45 Config.MaxHeight = 96 Config.LowestYear = 1900 -Config.HighestYear = 2020 +Config.HighestYear = 2021 Config.FullCharDelete = false Config.EnableDebugging = false diff --git a/server/main.lua b/server/main.lua index 0ee5810f..9e560d27 100644 --- a/server/main.lua +++ b/server/main.lua @@ -8,15 +8,7 @@ if Config.UseDeferrals then deferrals.defer() local playerId, identifier = source Citizen.Wait(100) - - if Config.UseSteamID then - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, 'steam:') then - identifier = v - break - end - end - else + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do if string.match(v, 'license:') then identifier = string.sub(v, 9) @@ -106,7 +98,7 @@ if Config.UseDeferrals then saveIdentityToDatabase(xPlayer.identifier, currentIdentity) end - Citizen.Wait(1000) + Citizen.Wait(5) alreadyRegistered[xPlayer.identifier] = true TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source) @@ -115,20 +107,13 @@ if Config.UseDeferrals then xPlayer.kick(_('missing_identity')) end end) + elseif not Config.UseDeferrals then AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) deferrals.defer() local playerId, identifier = source - Citizen.Wait(100) + Citizen.Wait(40) - if Config.UseSteamID then - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, 'steam:') then - identifier = v - break - end - end - else for k,v in ipairs(GetPlayerIdentifiers(playerId)) do if string.match(v, 'license:') then identifier = string.sub(v, 9) @@ -172,7 +157,7 @@ elseif not Config.UseDeferrals then AddEventHandler('onResourceStart', function(resource) if resource == GetCurrentResourceName() then - Citizen.Wait(1000) + Citizen.Wait(300) while not ESX do Citizen.Wait(10) @@ -206,7 +191,7 @@ elseif not Config.UseDeferrals then saveIdentityToDatabase(xPlayer.identifier, currentIdentity) end - Citizen.Wait(1000) + Citizen.Wait(10) TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source) playerIdentity[xPlayer.identifier] = nil From 1483f3363c3de17679d29b0f8eac33997563be1c Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 5 Apr 2021 22:26:15 +0100 Subject: [PATCH 75/78] Fixes for fixes --- config.lua | 1 - server/main.lua | 2 -- 2 files changed, 3 deletions(-) diff --git a/config.lua b/config.lua index 3bd35f42..2c21e317 100644 --- a/config.lua +++ b/config.lua @@ -9,7 +9,6 @@ Config.EnableCommands = true -- Changes the identifiers from Rockstar License To Steam. In order to use this, you will have to have -- made edits to your ESX in order to use Steam identifiers all around, because new ESX uses Rockstar -- license. I just made it easier for people that convert to steam identifiers. -Config.UseSteamID = false -- [Config.UseDeferrals] -- EXPERIMENTAL Character Registration Method. This will allow players to create identities in deferrals diff --git a/server/main.lua b/server/main.lua index 9e560d27..507b507d 100644 --- a/server/main.lua +++ b/server/main.lua @@ -15,7 +15,6 @@ if Config.UseDeferrals then break end end - end if identifier then MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { @@ -120,7 +119,6 @@ elseif not Config.UseDeferrals then break end end - end if identifier then MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { From c51122b19548a951ca287f2677ae93b760d2a890 Mon Sep 17 00:00:00 2001 From: Linden Date: Mon, 17 May 2021 21:15:15 +1000 Subject: [PATCH 76/78] fix(legacy/multichar): Add compatibility for esx_multicharacter Maintains compatibility with previous versions --- client/main.lua | 2 +- server/main.lua | 167 +++++++++++++++++++++++++----------------------- 2 files changed, 89 insertions(+), 80 deletions(-) diff --git a/client/main.lua b/client/main.lua index 59de7400..cf5359c1 100644 --- a/client/main.lua +++ b/client/main.lua @@ -56,7 +56,7 @@ if not Config.UseDeferrals then if callback then ESX.ShowNotification(_U('thank_you_for_registering')) EnableGui(false) - TriggerEvent('esx_skin:playerRegistered') + if not ESX.GetConfig().Multichar then TriggerEvent('esx_skin:playerRegistered') end else ESX.ShowNotification(_U('registration_error')) end diff --git a/server/main.lua b/server/main.lua index 507b507d..0d176191 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,20 +1,29 @@ ESX = nil +TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) local playerIdentity = {} local alreadyRegistered = {} -TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) +local multichar = ESX.GetConfig().Multichar or false + +function getIdentifier(playerId) + if multichar then + return ESX.GetIdentifier(playerId) + else + ESX.GetIdentifier = function(playerId) + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + if string.match(v, 'license') then + local identifier = string.gsub(v, 'license:', '') + return identifier + end + end + end + end +end if Config.UseDeferrals then AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) deferrals.defer() - local playerId, identifier = source + local playerId, identifier = source, getIdentifier(source) Citizen.Wait(100) - - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, 'license:') then - identifier = string.sub(v, 9) - break - end - end if identifier then MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { @@ -108,95 +117,90 @@ if Config.UseDeferrals then end) elseif not Config.UseDeferrals then - AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) - deferrals.defer() - local playerId, identifier = source - Citizen.Wait(40) + if not multichar then + AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) + deferrals.defer() + local playerId, identifier = source, getIdentifier(source) + Citizen.Wait(40) - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, 'license:') then - identifier = string.sub(v, 9) - break - end - end + if identifier then + MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { + ['@identifier'] = identifier + }, function(result) + if result[1] then + if result[1].firstname then + playerIdentity[identifier] = { + firstName = result[1].firstname, + lastName = result[1].lastname, + dateOfBirth = result[1].dateofbirth, + sex = result[1].sex, + height = result[1].height + } - if identifier then - MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', { - ['@identifier'] = identifier - }, function(result) - if result[1] then - if result[1].firstname then - playerIdentity[identifier] = { - firstName = result[1].firstname, - lastName = result[1].lastname, - dateOfBirth = result[1].dateofbirth, - sex = result[1].sex, - height = result[1].height - } + alreadyRegistered[identifier] = true - alreadyRegistered[identifier] = true - - deferrals.done() + deferrals.done() + else + playerIdentity[identifier] = nil + alreadyRegistered[identifier] = false + deferrals.done() + end else playerIdentity[identifier] = nil alreadyRegistered[identifier] = false deferrals.done() end - else - playerIdentity[identifier] = nil - alreadyRegistered[identifier] = false - deferrals.done() - end - end) - else - deferrals.done(_U('no_identifier')) - end - end) - - AddEventHandler('onResourceStart', function(resource) - if resource == GetCurrentResourceName() then - Citizen.Wait(300) - - while not ESX do - Citizen.Wait(10) + end) + else + deferrals.done(_U('no_identifier')) end + end) - local xPlayers = ESX.GetPlayers() + AddEventHandler('onResourceStart', function(resource) + if resource == GetCurrentResourceName() then + Citizen.Wait(300) - for i=1, #xPlayers, 1 do - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + while not ESX do + Citizen.Wait(10) + end - if xPlayer then - checkIdentity(xPlayer) + local xPlayers = ESX.GetPlayers() + + for i=1, #xPlayers, 1 do + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + + if xPlayer then + checkIdentity(xPlayer) + end end end - end - end) + end) - RegisterNetEvent('esx:playerLoaded') - AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) - if alreadyRegistered[xPlayer.identifier] == true then + RegisterNetEvent('esx:playerLoaded') + AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) local currentIdentity = playerIdentity[xPlayer.identifier] + if currentIdentity and alreadyRegistered[xPlayer.identifier] == true then - xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName)) - xPlayer.set('firstName', currentIdentity.firstName) - xPlayer.set('lastName', currentIdentity.lastName) - xPlayer.set('dateofbirth', currentIdentity.dateOfBirth) - xPlayer.set('sex', currentIdentity.sex) - xPlayer.set('height', currentIdentity.height) + xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName)) + xPlayer.set('firstName', currentIdentity.firstName) + xPlayer.set('lastName', currentIdentity.lastName) + xPlayer.set('dateofbirth', currentIdentity.dateOfBirth) + xPlayer.set('sex', currentIdentity.sex) + xPlayer.set('height', currentIdentity.height) - if currentIdentity.saveToDatabase then - saveIdentityToDatabase(xPlayer.identifier, currentIdentity) + if currentIdentity.saveToDatabase then + saveIdentityToDatabase(xPlayer.identifier, currentIdentity) + end + + Citizen.Wait(10) + TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source) + + playerIdentity[xPlayer.identifier] = nil + else + TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) end - - Citizen.Wait(10) - TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source) - - playerIdentity[xPlayer.identifier] = nil - else - TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source) - end - end) + end) + end ESX.RegisterServerCallback('esx_identity:registerIdentity', function(source, cb, data) local xPlayer = ESX.GetPlayerFromId(source) @@ -232,6 +236,11 @@ elseif not Config.UseDeferrals then else cb(false) end + else + if multichar and checkNameFormat(data.firstname) and checkNameFormat(data.lastname) and checkSexFormat(data.sex) and checkDOBFormat(data.dateofbirth) and checkHeightFormat(data.height) then + TriggerEvent('esx_identity:completedRegistration', source, data) + cb(true) + end end end) From 911d17e27ebb1d260ffd27b7d53d2a265d7f1ce1 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Wed, 19 May 2021 20:32:18 +1000 Subject: [PATCH 77/78] fix(legacy/multichar): Check if multichar is defined --- server/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/main.lua b/server/main.lua index 0d176191..cbfd78ff 100644 --- a/server/main.lua +++ b/server/main.lua @@ -2,10 +2,10 @@ ESX = nil TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) local playerIdentity = {} local alreadyRegistered = {} -local multichar = ESX.GetConfig().Multichar or false +local multichar = ESX.GetConfig().Multichar function getIdentifier(playerId) - if multichar then + if multichar ~= nil then return ESX.GetIdentifier(playerId) else ESX.GetIdentifier = function(playerId) From dfc0067f84274ca353326a2ebda3f445df103979 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Tue, 15 Jun 2021 01:05:33 +1000 Subject: [PATCH 78/78] fix(server/main): Fix identifier function for older versions of ESX --- server/main.lua | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/server/main.lua b/server/main.lua index cbfd78ff..ba3de70b 100644 --- a/server/main.lua +++ b/server/main.lua @@ -4,16 +4,12 @@ local playerIdentity = {} local alreadyRegistered = {} local multichar = ESX.GetConfig().Multichar -function getIdentifier(playerId) - if multichar ~= nil then - return ESX.GetIdentifier(playerId) - else - ESX.GetIdentifier = function(playerId) - for k,v in ipairs(GetPlayerIdentifiers(playerId)) do - if string.match(v, 'license') then - local identifier = string.gsub(v, 'license:', '') - return identifier - end +if multichar == nil then + ESX.GetIdentifier = function(playerId) + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + if string.match(v, 'license:') then + local identifier = string.gsub(v, 'license:', '') + return identifier end end end @@ -22,7 +18,7 @@ end if Config.UseDeferrals then AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) deferrals.defer() - local playerId, identifier = source, getIdentifier(source) + local playerId, identifier = source, ESX.GetIdentifier(source) Citizen.Wait(100) if identifier then @@ -120,7 +116,7 @@ elseif not Config.UseDeferrals then if not multichar then AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals) deferrals.defer() - local playerId, identifier = source, getIdentifier(source) + local playerId, identifier = source, ESX.GetIdentifier(source) Citizen.Wait(40) if identifier then