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` 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') 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 '' +; 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 + 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; +} 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)