From cb68068cb713ea856ae8d39dde9a93cf9246e14c Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 15 Apr 2018 12:23:40 +0200 Subject: [PATCH] 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, " "))