mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 13:01:31 +00:00
67 lines
2.5 KiB
Lua
67 lines
2.5 KiB
Lua
--==================================================================================
|
|
--====== 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 firstname, lastname FROM characters WHERE identifier = @identifier", {
|
|
['@identifier'] = identifier
|
|
})
|
|
if result[1] ~= nil then
|
|
local identity = result[1]
|
|
|
|
return {
|
|
firstname = identity['firstname']
|
|
}
|
|
else
|
|
return {
|
|
firstname = ''
|
|
}
|
|
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.firstname == '' then
|
|
print('Player Does Not Have An Identity')
|
|
Wait(2000)
|
|
TriggerClientEvent('esx_identity:showRegisterIdentity', source)
|
|
else
|
|
print('Player Has An Identity')
|
|
end
|
|
end)
|