mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
refactor(esx_identity): Refactor for better error handling and cleanup.
- Refactored the if validation statements to display better error notifications - Added config for different DOB Formats - Bumped version
This commit is contained in:
@@ -1,12 +1,10 @@
|
|||||||
local loadingScreenFinished = false
|
local loadingScreenFinished = false
|
||||||
local ready = false
|
local ready = false
|
||||||
|
local guiEnabled = false
|
||||||
|
local timecycleModifier = "hud_def_blur"
|
||||||
|
|
||||||
RegisterNetEvent('esx_identity:alreadyRegistered')
|
RegisterNetEvent('esx_identity:alreadyRegistered', function()
|
||||||
AddEventHandler('esx_identity:alreadyRegistered', function()
|
while not loadingScreenFinished do Wait(100) end
|
||||||
while not loadingScreenFinished do
|
|
||||||
Wait(100)
|
|
||||||
end
|
|
||||||
|
|
||||||
TriggerEvent('esx_skin:playerRegistered')
|
TriggerEvent('esx_skin:playerRegistered')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -20,32 +18,23 @@ RegisterNUICallback('ready', function(data, cb)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
if not Config.UseDeferrals then
|
if not Config.UseDeferrals then
|
||||||
local guiEnabled = false
|
|
||||||
|
|
||||||
function EnableGui(state)
|
function EnableGui(state)
|
||||||
SetNuiFocus(state, state)
|
SetNuiFocus(state, state)
|
||||||
guiEnabled = state
|
guiEnabled = state
|
||||||
while not ready do
|
|
||||||
Wait(500)
|
|
||||||
end
|
|
||||||
if state then
|
if state then
|
||||||
SetTimecycleModifier("hud_def_blur")
|
SetTimecycleModifier(timecycleModifier)
|
||||||
else
|
else
|
||||||
ClearTimecycleModifier()
|
ClearTimecycleModifier()
|
||||||
end
|
end
|
||||||
SendNUIMessage({
|
|
||||||
type = "enableui",
|
SendNUIMessage({type = "enableui",enable = state})
|
||||||
enable = state
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNetEvent('esx_identity:showRegisterIdentity')
|
RegisterNetEvent('esx_identity:showRegisterIdentity', function()
|
||||||
AddEventHandler('esx_identity:showRegisterIdentity', function()
|
|
||||||
TriggerEvent('esx_skin:resetFirstSpawn')
|
TriggerEvent('esx_skin:resetFirstSpawn')
|
||||||
|
|
||||||
if not ESX.PlayerData.dead then
|
if not ESX.PlayerData.dead then EnableGui(true) end
|
||||||
EnableGui(true)
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNUICallback('register', function(data, cb)
|
RegisterNUICallback('register', function(data, cb)
|
||||||
@@ -53,11 +42,10 @@ if not Config.UseDeferrals then
|
|||||||
if callback then
|
if callback then
|
||||||
ESX.ShowNotification(_U('thank_you_for_registering'))
|
ESX.ShowNotification(_U('thank_you_for_registering'))
|
||||||
EnableGui(false)
|
EnableGui(false)
|
||||||
|
|
||||||
if not ESX.GetConfig().Multichar then
|
if not ESX.GetConfig().Multichar then
|
||||||
TriggerEvent('esx_skin:playerRegistered')
|
TriggerEvent('esx_skin:playerRegistered')
|
||||||
end
|
end
|
||||||
else
|
|
||||||
ESX.ShowNotification(_U('registration_error'), "error", 5000)
|
|
||||||
end
|
end
|
||||||
end, data)
|
end, data)
|
||||||
end)
|
end)
|
||||||
@@ -87,7 +75,10 @@ if not Config.UseDeferrals then
|
|||||||
DisableControlAction(0, 143, true) -- disable melee
|
DisableControlAction(0, 143, true) -- disable melee
|
||||||
DisableControlAction(0, 75, true) -- disable exit vehicle
|
DisableControlAction(0, 75, true) -- disable exit vehicle
|
||||||
DisableControlAction(27, 75, true) -- disable exit vehicle
|
DisableControlAction(27, 75, true) -- disable exit vehicle
|
||||||
|
else
|
||||||
|
sleep = 1500
|
||||||
end
|
end
|
||||||
|
|
||||||
Wait(sleep)
|
Wait(sleep)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ Config.Locale = 'en'
|
|||||||
-- Enables Commands Such As /char and /chardel
|
-- Enables Commands Such As /char and /chardel
|
||||||
Config.EnableCommands = ESX.GetConfig().EnableDebug
|
Config.EnableCommands = ESX.GetConfig().EnableDebug
|
||||||
|
|
||||||
Config.UseDeferrals = false -- EXPERIMENTAL Character Registration Method.
|
-- EXPERIMENTAL Character Registration Method
|
||||||
|
Config.UseDeferrals = false
|
||||||
|
|
||||||
|
-- These values are for the date format in the registration menu
|
||||||
|
-- Choices: DD/MM/YYYY | MM/DD/YYYY | YYYY/MM/DD
|
||||||
|
Config.DateFormat = 'DD/MM/YYYY'
|
||||||
|
|
||||||
-- These values are for the second input validation in server/main.lua
|
-- These values are for the second input validation in server/main.lua
|
||||||
Config.MaxNameLength = 20 -- Max Name Length.
|
Config.MaxNameLength = 20 -- Max Name Length.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ game 'gta5'
|
|||||||
|
|
||||||
description 'ESX Identity'
|
description 'ESX Identity'
|
||||||
|
|
||||||
version '1.7.5'
|
version '1.7.6'
|
||||||
|
|
||||||
shared_script '@es_extended/imports.lua'
|
shared_script '@es_extended/imports.lua'
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ body {
|
|||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aa {
|
.title {
|
||||||
font-family: 'Oswald', sans-serif;
|
font-family: 'Oswald', sans-serif;
|
||||||
font-size: 22px;
|
font-size: 22px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -8,15 +8,15 @@
|
|||||||
|
|
||||||
<body onkeydown="TriggeredKey(this)">
|
<body onkeydown="TriggeredKey(this)">
|
||||||
<div class="dialog">
|
<div class="dialog">
|
||||||
<div class="aa"><b>IDENTITY</b></div>
|
<div class="title"><b>IDENTITY</b></div>
|
||||||
<!-- <img id="logo" height="110px" width="332px"> > -->
|
<!-- <img id="logo" height="110px" width="332px"> > -->
|
||||||
<form id="register" name="register" action="#">
|
<form id="register" name="register" action="#">
|
||||||
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif";>First Name</div>
|
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif";>First Name</div>
|
||||||
<input id="firstname" type="text" class="" name="firstname" placeholder="First Name" onKeyDown="if(this.value.length==16 && event.keyCode!=8)"><br>
|
<input id="firstname" type="text" class="" name="firstname" placeholder="First Name" onKeyDown="if(this.value.length==16 && event.keyCode!=8)"><br>
|
||||||
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif";>Last Name</div>
|
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif";>Last Name</div>
|
||||||
<input id="lastname" type="text" class="" name="lastname" placeholder="Last Name" onKeyDown="if(this.value.length==16 && event.keyCode!=8)"><br>
|
<input id="lastname" type="text" class="" name="lastname" placeholder="Last Name" onKeyDown="if(this.value.length==16 && event.keyCode!=8)"><br>
|
||||||
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif", sans-serif;>Date of Birth (MM/DD/YYYY)</div>
|
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif", sans-serif;>Date of Birth (MM/DD/YYYY)</div>
|
||||||
<input id="dateofbirth" type="date" name="dateofbirth" class="" placeholder="Date of Birth (dd/mm/yyy)" min="01/01/1900" max="01/01/2010" onfocus="(this.type='date')"><br>
|
<input id="dateofbirth" type="date" name="dateofbirth" class="" placeholder="Date of Birth (dd/mm/yyyy)" min="01/01/1900" max="01/01/2010" onfocus="(this.type='date')"><br>
|
||||||
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif", sans-serif;>Height</div>
|
<div style="color: rgb(46, 187, 205);font-size: 12px; font-family: 'Gill Sans', sans-serif", sans-serif;>Height</div>
|
||||||
<input id="height" type="number" class="" name="height" min="120" max="220" placeholder="Height (cm)" onKeyDown="if(this.value.length==3 && event.keyCode!=8)"><br>
|
<input id="height" type="number" class="" name="height" min="120" max="220" placeholder="Height (cm)" onKeyDown="if(this.value.length==3 && event.keyCode!=8)"><br>
|
||||||
<center>
|
<center>
|
||||||
@@ -28,16 +28,11 @@
|
|||||||
<label for="radiof">Female</label>
|
<label for="radiof">Female</label>
|
||||||
</div>
|
</div>
|
||||||
</center>
|
</center>
|
||||||
<!-- <div class="range-wrap" style="width: 80%;">
|
|
||||||
<input type="range" id="height" class="range" min="48" max="96" value="48">
|
|
||||||
<output class="bubble"></output>
|
|
||||||
</div> -->
|
|
||||||
<button id="submit" type="submit"><font size="4px">CREATE</font></button>
|
<button id="submit" type="submit"><font size="4px">CREATE</font></button>
|
||||||
</form>
|
</form>
|
||||||
<center><font size="1px" color="green">If the submit button doesn't work, please ensure that you've entered the fields correctly.</font></center>
|
<center><font size="1px" color="green">If the submit button doesn't work, please ensure that you've entered the fields correctly.</font></center>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
const allRanges = document.querySelectorAll(".range-wrap");
|
const allRanges = document.querySelectorAll(".range-wrap");
|
||||||
allRanges.forEach(wrap => {
|
allRanges.forEach(wrap => {
|
||||||
const range = wrap.querySelector(".range");
|
const range = wrap.querySelector(".range");
|
||||||
|
|||||||
@@ -1,36 +1,35 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
$.post('http://esx_identity/ready', JSON.stringify({}));
|
$.post('http://esx_identity/ready', JSON.stringify({}))
|
||||||
|
|
||||||
window.addEventListener('message', function(event) {
|
window.addEventListener('message', function(event) {
|
||||||
if (event.data.type == "enableui") {
|
if (event.data.type === "enableui") {
|
||||||
document.body.style.display = event.data.enable ? "block" : "none";
|
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());
|
|
||||||
|
|
||||||
|
$("#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") {
|
if (dateCheck == "Invalid Date") {
|
||||||
date == "invalid";
|
date == "invalid"
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(dateCheck)
|
const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(dateCheck)
|
||||||
const mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(dateCheck)
|
const mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(dateCheck)
|
||||||
const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(dateCheck)
|
const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(dateCheck)
|
||||||
|
|
||||||
var formattedDate = `${da}/${mo}/${ye}`;
|
var formattedDate = `${da}/${mo}/${ye}`
|
||||||
|
|
||||||
$.post('http://esx_identity/register', JSON.stringify({
|
$.post('http://esx_identity/register', JSON.stringify({
|
||||||
firstname: $("#firstname").val(),
|
firstname: $("#firstname").val(),
|
||||||
lastname: $("#lastname").val(),
|
lastname: $("#lastname").val(),
|
||||||
dateofbirth: formattedDate,
|
dateofbirth: formattedDate,
|
||||||
sex: $("input[type='radio'][name='sex']:checked").val(),
|
sex: $("input[type='radio'][name='sex']:checked").val(),
|
||||||
height: $("#height").val()
|
height: $("#height").val()
|
||||||
}));
|
}))
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|||||||
@@ -1,33 +1,38 @@
|
|||||||
Locales['en'] = {
|
Locales['en'] = {
|
||||||
['show_active_character'] = 'Show Active Character',
|
['show_active_character'] = 'Show Active Character',
|
||||||
['active_character'] = 'Active Character: %s',
|
['active_character'] = 'Active Character: %s',
|
||||||
['error_active_character'] = "There was an error obtaining your data.",
|
['error_active_character'] = 'There was an error obtaining your data.',
|
||||||
['delete_character'] = 'Delete Current Character And Create a new one.',
|
['delete_character'] = 'Delete Your Current Character.',
|
||||||
['deleted_character'] = 'Character Deleted.',
|
['deleted_character'] = 'Character Deleted',
|
||||||
['error_delete_character'] = "There was a problem deleting your character.",
|
['error_delete_character'] = 'There was a problem deleting your character.',
|
||||||
['thank_you_for_registering'] = "Successfully Registered, Enjoy!",
|
['thank_you_for_registering'] = 'Registration Successful. Enjoy!',
|
||||||
['registration_error'] = "Your Data is incorrect.",
|
['debug_xPlayer_get_first_name'] = 'Returns Your First Name',
|
||||||
['debug_xPlayer_get_first_name'] = "Returns Your forename",
|
['debug_xPlayer_get_last_name'] = 'Returns Your Last Name',
|
||||||
['debug_xPlayer_get_last_name'] = "Returns Your surname",
|
['debug_xPlayer_get_full_name'] = 'Returns Your Full Name',
|
||||||
['debug_xPlayer_get_full_name'] = "Return Your Name",
|
['debug_xPlayer_get_sex'] = 'Returns Your Sex',
|
||||||
['debug_xPlayer_get_sex'] = "Returns Your Sex",
|
['debug_xPlayer_get_dob'] = 'Returns Your DOB',
|
||||||
['debug_xPlayer_get_dob'] = "Returns Your DOB",
|
['debug_xPlayer_get_height'] = 'Returns Your Height',
|
||||||
['debug_xPlayer_get_height'] = "Returns Your Height",
|
['error_debug_xPlayer_get_first_name'] = 'There was an issue while obtaining your first name.',
|
||||||
['error_debug_xPlayer_get_first_name'] = "There was an issue while obtaining your forename.",
|
['error_debug_xPlayer_get_last_name'] = 'There was an issue while obtaining your last name.',
|
||||||
['error_debug_xPlayer_get_last_name'] = "There was an issue while obtaining your surname.",
|
['error_debug_xPlayer_get_full_name'] = 'There was an issue while obtaining your full name.',
|
||||||
['error_debug_xPlayer_get_full_name'] = "There was an issue while obtaining your name.",
|
['error_debug_xPlayer_get_sex'] = 'There was an issue while obtaining your sex.',
|
||||||
['error_debug_xPlayer_get_sex'] = "There was an issue while obtaining your sex.",
|
['error_debug_xPlayer_get_dob'] = 'There was an issue while obtaining your date of birth.',
|
||||||
['error_debug_xPlayer_get_dob'] = "There was an issue while obtaining your date of birth.",
|
['error_debug_xPlayer_get_height'] = 'There was an issue while obtaining your height.',
|
||||||
['error_debug_xPlayer_get_height'] = "There was an issue while obtaining your height.",
|
['return_debug_xPlayer_get_first_name'] = 'First Name: %s',
|
||||||
['return_debug_xPlayer_get_first_name'] = "First Name: %s",
|
['return_debug_xPlayer_get_last_name'] = 'Last Name: %s',
|
||||||
['return_debug_xPlayer_get_last_name'] = "Last Name: %s",
|
['return_debug_xPlayer_get_full_name'] = 'Name: %s',
|
||||||
['return_debug_xPlayer_get_full_name'] = "Name: %s",
|
['return_debug_xPlayer_get_sex'] = 'Sex: %s',
|
||||||
['return_debug_xPlayer_get_sex'] = "Sex: %s",
|
['return_debug_xPlayer_get_dob'] = 'DOB: %s',
|
||||||
['return_debug_xPlayer_get_dob'] = "DOB: %s",
|
['return_debug_xPlayer_get_height'] = 'Height: %s Inches',
|
||||||
['return_debug_xPlayer_get_height'] = "Height: %s Inches",
|
|
||||||
['data_incorrect'] = 'Invalid Data, Please try again.',
|
['data_incorrect'] = 'Invalid Data, Please try again.',
|
||||||
['invalid_format'] = 'Invalid Data Format, Please try again.',
|
['invalid_format'] = 'Invalid Data Format, Please try again.',
|
||||||
['no_identifier'] = '[ESX Identity]\nThere was an issue while loading your character!\nError code: identifier-missing\n\nThis is caused by your identifier being missing. Please come back later or report this problem to the Server Owner.',
|
['no_identifier'] = '[ESX Identity]\nThere was an issue while loading your character!\nError Code: identifier-missing\n\nThis is caused by your identifier being missing. Please come back later or report this problem to the Server Owner.',
|
||||||
['missing_identity'] = '[ESX Identity]\nThere was an issue loading your character!\nError code: identity-missing\n\nIt seems like your identity is missing, try connecting again.',
|
['missing_identity'] = '[ESX Identity]\nThere was an issue loading your character!\nError Code: identity-missing\n\nIt seems like your identity is missing, try connecting again.',
|
||||||
['deleted_identity'] = 'Character deleted, Please rejoin to create a new character.'
|
['deleted_identity'] = 'Character deleted. Please rejoin to create a new character.',
|
||||||
|
['already_registered'] = 'You have already registered.',
|
||||||
|
['invalid_firstname_format'] = 'Invalid Format (First Name): Please try again.',
|
||||||
|
['invalid_lastname_format'] = 'Invalid Format (Last Name): Please try again.',
|
||||||
|
['invalid_dob_format'] = 'Invalid Format (DOB): Please try again.',
|
||||||
|
['invalid_sex_format'] = 'Invalid Format (Sex): Please try again.',
|
||||||
|
['invalid_height_format'] = 'Invalid Format (Height): Please try again.'
|
||||||
}
|
}
|
||||||
|
|||||||
+536
-449
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user