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 1/6] 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 2/6] 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 3/6] 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 4/6] 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 @@