mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 17:58:54 +00:00
Update ESX Identity
- Finalized Update For ESX Identity That Gives Access To The Deferrals Update + The two optional UI based updates.
This commit is contained in:
@@ -34,6 +34,12 @@ start esx_identity
|
||||
- If you are using esx_policejob or esx_society, you need to enable the following in the scripts' `config.lua`:
|
||||
```Config.EnableESXIdentity = true```
|
||||
|
||||
### Commands
|
||||
```
|
||||
/char
|
||||
/chardel
|
||||
```
|
||||
|
||||
# Legal
|
||||
### License
|
||||
esx_identity - rp characters
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
ESX = nil
|
||||
local loadingScreenFinished = false
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while ESX == nil do
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_identity:alreadyRegistered')
|
||||
AddEventHandler('esx_identity:alreadyRegistered', function()
|
||||
while not loadingScreenFinished do
|
||||
Citizen.Wait(100)
|
||||
end
|
||||
|
||||
TriggerEvent('esx_skin:playerRegistered')
|
||||
end)
|
||||
|
||||
AddEventHandler('esx:loadingScreenOff', function()
|
||||
loadingScreenFinished = true
|
||||
end)
|
||||
|
||||
if not Config.UseDeferrals then
|
||||
local guiEnabled, isDead = false, false
|
||||
|
||||
AddEventHandler('esx:onPlayerDeath', function(data)
|
||||
isDead = true
|
||||
end)
|
||||
|
||||
AddEventHandler('esx:onPlayerSpawn', function(spawn)
|
||||
isDead = false
|
||||
end)
|
||||
|
||||
function EnableGui(state)
|
||||
SetNuiFocus(state, state)
|
||||
guiEnabled = state
|
||||
|
||||
SendNUIMessage({
|
||||
type = "enableui",
|
||||
enable = state
|
||||
})
|
||||
end
|
||||
|
||||
RegisterNetEvent('esx_identity:showRegisterIdentity')
|
||||
AddEventHandler('esx_identity:showRegisterIdentity', function()
|
||||
TriggerEvent('esx_skin:resetFirstSpawn')
|
||||
|
||||
if not isDead then
|
||||
EnableGui(true)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNUICallback('register', function(data, cb)
|
||||
ESX.TriggerServerCallback('esx_identity:registerIdentity', function(callback)
|
||||
if callback then
|
||||
ESX.ShowNotification(_U('thank_you_for_registering'))
|
||||
EnableGui(false)
|
||||
TriggerEvent('esx_skin:playerRegistered')
|
||||
else
|
||||
ESX.ShowNotification(_U('registration_error'))
|
||||
end
|
||||
end, data)
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
|
||||
if guiEnabled then
|
||||
DisableControlAction(0, 1, true) -- LookLeftRight
|
||||
DisableControlAction(0, 2, true) -- LookUpDown
|
||||
DisableControlAction(0, 106, true) -- VehicleMouseControlOverride
|
||||
DisableControlAction(0, 142, true) -- MeleeAttackAlternate
|
||||
DisableControlAction(0, 30, true) -- MoveLeftRight
|
||||
DisableControlAction(0, 31, true) -- MoveUpDown
|
||||
DisableControlAction(0, 21, true) -- disable sprint
|
||||
DisableControlAction(0, 24, true) -- disable attack
|
||||
DisableControlAction(0, 25, true) -- disable aim
|
||||
DisableControlAction(0, 47, true) -- disable weapon
|
||||
DisableControlAction(0, 58, true) -- disable weapon
|
||||
DisableControlAction(0, 263, true) -- disable melee
|
||||
DisableControlAction(0, 264, true) -- disable melee
|
||||
DisableControlAction(0, 257, true) -- disable melee
|
||||
DisableControlAction(0, 140, true) -- disable melee
|
||||
DisableControlAction(0, 141, true) -- disable melee
|
||||
DisableControlAction(0, 143, true) -- disable melee
|
||||
DisableControlAction(0, 75, true) -- disable exit vehicle
|
||||
DisableControlAction(27, 75, true) -- disable exit vehicle
|
||||
else
|
||||
Citizen.Wait(500)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
+10
-5
@@ -1,7 +1,12 @@
|
||||
Config = {}
|
||||
Config.Locale = 'en'
|
||||
Config.MinHeight = 24 -- Minimum Height
|
||||
Config.MaxHeight = 96 -- Maximum Height
|
||||
Config.HighestYear = 2020 -- The highest year that can be used in date of birth
|
||||
Config.LowestYear = 1900 -- The lowest year that can be used in date of birth
|
||||
Config.MaxNameLength = 15 -- You must also change the SQL structure for 'firstname' and 'lastname' in the `users` table
|
||||
Config.EnableCommands = true
|
||||
Config.UseSteamID = false
|
||||
Config.UseDeferrals = true
|
||||
Config.MaxNameLength = 16
|
||||
Config.MinHeight = 48
|
||||
Config.MaxHeight = 96
|
||||
Config.LowestYear = 1900
|
||||
Config.HighestYear = 2020
|
||||
|
||||
Config.EnableDebugging = false
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
USE `es_extended`;
|
||||
|
||||
ALTER TABLE `users`
|
||||
ADD COLUMN `firstname` VARCHAR(15) NULL DEFAULT NULL,
|
||||
ADD COLUMN `lastname` VARCHAR(15) NULL DEFAULT NULL,
|
||||
ADD COLUMN `firstname` VARCHAR(16) NULL DEFAULT NULL,
|
||||
ADD COLUMN `lastname` VARCHAR(16) NULL DEFAULT NULL,
|
||||
ADD COLUMN `dateofbirth` VARCHAR(10) NULL DEFAULT NULL,
|
||||
ADD COLUMN `sex` VARCHAR(1) NULL DEFAULT NULL,
|
||||
ADD COLUMN `height` VARCHAR(3) NULL DEFAULT NULL
|
||||
ADD COLUMN `height` INT(2) NULL DEFAULT NULL
|
||||
;
|
||||
+18
-1
@@ -4,7 +4,7 @@ game 'gta5'
|
||||
|
||||
description 'ESX Identity'
|
||||
|
||||
version '1.3.0'
|
||||
version '1.4.0'
|
||||
|
||||
server_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
@@ -15,4 +15,21 @@ server_scripts {
|
||||
'server/main.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
'locales/en.lua',
|
||||
'locales/cs.lua',
|
||||
'config.lua',
|
||||
'client/main.lua'
|
||||
}
|
||||
|
||||
ui_page 'html/index.html'
|
||||
|
||||
files {
|
||||
'html/index.html',
|
||||
'html/js/script.js',
|
||||
'html/css/style.css',
|
||||
'html/img/esx_identity.png'
|
||||
}
|
||||
|
||||
dependency 'es_extended'
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.dialog {
|
||||
width: 332px;
|
||||
opacity : 0.95;
|
||||
position : absolute;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
top : 30.0%;
|
||||
padding: 10px;
|
||||
left : 50%; /* à 50%/50% du parent référent */
|
||||
transform : translate(-50%); /* décalage de 50% de sa propre taille */
|
||||
background-color: #B7B7B7;
|
||||
border-radius : 4px;
|
||||
box-shadow: 0px 0px 50px 0px #000;
|
||||
border-left:5px solid #000;
|
||||
border:1px inset;
|
||||
margin:5px;
|
||||
margin-bottom:20px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
text-align:left;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
|
||||
color: black;
|
||||
opacity: 1; /* Firefox */
|
||||
}
|
||||
|
||||
.radio-toolbar input[type="radio"] {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
width: 36%;
|
||||
}
|
||||
|
||||
.radio-toolbar label {
|
||||
display: inline-block;
|
||||
margin-top: 5px;
|
||||
background-color: #ddd;
|
||||
padding: 10px 20px;
|
||||
font-family: sans-serif, Arial;
|
||||
font-size: 16px;
|
||||
color: #000000;
|
||||
border: 2px solid #444;
|
||||
border-radius: 4px;
|
||||
width: 36%;
|
||||
}
|
||||
|
||||
.radio-toolbar input[type="radio"]:checked + label {
|
||||
width: 36%;
|
||||
background-color:#3399FF;
|
||||
border-color: #0033FF;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.radio-toolbar input[type="radio"]:focus + label {
|
||||
border: 2px solid #444;
|
||||
width: 36%;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.radio-toolbar label:hover {
|
||||
background-color: #dfd;
|
||||
width: 36%;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
button {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
padding: 10px;
|
||||
background-color: #373737;
|
||||
border: 2px solid #444;
|
||||
color: #FFFFFF;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
margin-right: 5px;
|
||||
padding: 10px;
|
||||
background-color: #506be6;
|
||||
color: #000000;
|
||||
width: 93%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.range-wrap {
|
||||
position: relative;
|
||||
margin: 0 auto 3rem;
|
||||
}
|
||||
|
||||
.range {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.bubble {
|
||||
background: #3399FF;
|
||||
color: black;
|
||||
padding: 4px 12px;
|
||||
position: absolute;
|
||||
border-radius: 4px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.bubble::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 2px;
|
||||
height: 2px;
|
||||
background: #3399FF;
|
||||
color: black;
|
||||
top: -1px;
|
||||
left: 50%;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
+163
@@ -0,0 +1,163 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
||||
<link href="css/style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body onkeydown="TriggeredKey(this)">
|
||||
<div class="dialog">
|
||||
<img id="logo" src="img/esx_identity.png" height="110px" width="332px">
|
||||
<form id="register" name="register" action="#">
|
||||
<input id="firstname" type="text" class="" name="firstname" placeholder="First Name (Max 16 Characters)" onKeyDown="if(this.value.length==16 && event.keyCode!=8) return false;" onkeypress="if (isNumber(event) == true) return false;" onKeyUp="checkFirstName()" onmouseup="checkFirstName()"><br>
|
||||
<input id="lastname" type="text" class="" name="lastname" placeholder="Last Name (Max 16 Characters)" onKeyDown="if(this.value.length==16 && event.keyCode!=8) return false;" onkeypress="if (isNumber(event) == true) return false;" onKeyUp="checkLastName()" onmouseup="checkLastName()"><br>
|
||||
<input id="dateofbirth" type="text" name="dateofbirth" class="" placeholder="Date of Birth (MM/DD/YYYY)" dateformat="M d y" min="01/01/1900" max="12/31/2020" onfocus="(this.type='date')" onkeypress="if ( isNaN(String.fromCharCode(event.keyCode) )) return false;" onchange="checkDOB()" onKeyUp="checkDOB()" onmouseup="checkDOB()"><br>
|
||||
<center>
|
||||
<div class="radio-toolbar">
|
||||
<input type="radio" id="radiom" name="sex" value="m" checked>
|
||||
<label for="radiom">Male</label>
|
||||
|
||||
<input type="radio" id="radiof" name="sex" value="f">
|
||||
<label for="radiof">Female</label>
|
||||
</div>
|
||||
</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="5px">Submit</font></button>
|
||||
</form>
|
||||
<center><font size="1px" color="red">If the submit button doesn't work, please ensure that you've entered the fields correctly.</font></center>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
const allRanges = document.querySelectorAll(".range-wrap");
|
||||
allRanges.forEach(wrap => {
|
||||
const range = wrap.querySelector(".range");
|
||||
const bubble = wrap.querySelector(".bubble");
|
||||
|
||||
range.addEventListener("input", () => {
|
||||
setBubble(range, bubble);
|
||||
});
|
||||
setBubble(range, bubble);
|
||||
});
|
||||
|
||||
function setBubble(range, bubble) {
|
||||
const val = range.value;
|
||||
const min = range.min ? range.min : 0;
|
||||
const max = range.max ? range.max : 100;
|
||||
const newVal = Number(((val - min) * 100) / (max - min));
|
||||
bubble.innerHTML = 'Height: ' + val;
|
||||
bubble.style.left = `calc(${newVal}% + (${8 - newVal * 0.15}px))`;
|
||||
}
|
||||
|
||||
var myFirstName = document.getElementById('firstname');
|
||||
var myLastName = document.getElementById('lastname');
|
||||
var myDOB = document.getElementById('dateofbirth');
|
||||
var myHeight = document.getElementById('height');
|
||||
|
||||
function isNumber(e) {
|
||||
var key=e.which || e.KeyCode;
|
||||
if ( key >=48 && key <= 57) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkFirstName() {
|
||||
var value = myFirstName.value;
|
||||
if(value.trim().match(/^[a-zA-Z][0-9a-zA-Z .,'-]*$/) == null) {
|
||||
myFirstName.style.backgroundColor = '#E06666';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
if(value.length > 0 && value.length < 17) {
|
||||
myFirstName.style.backgroundColor = '#B6D7A8';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
myFirstName.style.backgroundColor = '#E06666';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkLastName() {
|
||||
var value = myLastName.value;
|
||||
if(value.trim().match(/^[a-zA-Z][0-9a-zA-Z .,'-]*$/) == null) {
|
||||
myLastName.style.backgroundColor = '#E06666';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
if(value.length > 0 && value.length < 17) {
|
||||
myLastName.style.backgroundColor = '#B6D7A8';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
myLastName.style.backgroundColor = '#E06666';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkDOB() {
|
||||
var date = new Date($('#dateofbirth').val());
|
||||
day = date.getDate();
|
||||
month = date.getMonth() + 1;
|
||||
year = date.getFullYear();
|
||||
if (isNaN(month) || isNaN(day) || isNaN(year)) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
var dateInput = [month, day, year].join('/');
|
||||
|
||||
var regExp = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
|
||||
var dateArray = dateInput.match(regExp);
|
||||
|
||||
if (dateArray == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
month = dateArray[1];
|
||||
day= dateArray[3];
|
||||
year = dateArray[5];
|
||||
|
||||
if (month < 1 || month > 12){
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if (day < 1 || day> 31) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if ((month==4 || month==6 || month==9 || month==11) && day ==31) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if (month == 2) {
|
||||
var isLeapYear = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
|
||||
if (day> 29 || (day ==29 && !isLeapYear)){
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
}
|
||||
else {
|
||||
myDOB.style.backgroundColor = '#B6D7A8';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function TriggeredKey(e) {
|
||||
var keycode;
|
||||
if (window.event) keycode = window.event.keyCode;
|
||||
if (window.event.keyCode == 13 || window.event.keyCode == 27) return false;
|
||||
}
|
||||
</script>
|
||||
<script src="js/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,163 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
||||
<link href="css/style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body onkeydown="TriggeredKey(this)">
|
||||
<div class="dialog">
|
||||
<img id="logo" src="img/esx_identity.png" height="110px" width="332px">
|
||||
<form id="register" name="register" action="#">
|
||||
<input id="firstname" type="text" class="" name="firstname" placeholder="First Name (Max 16 Characters)" onKeyDown="if(this.value.length==16 && event.keyCode!=8) return false;" onkeypress="if (isNumber(event) == true) return false;" onKeyUp="checkFirstName()" onmouseup="checkFirstName()"><br>
|
||||
<input id="lastname" type="text" class="" name="lastname" placeholder="Last Name (Max 16 Characters)" onKeyDown="if(this.value.length==16 && event.keyCode!=8) return false;" onkeypress="if (isNumber(event) == true) return false;" onKeyUp="checkLastName()" onmouseup="checkLastName()"><br>
|
||||
<input id="dateofbirth" type="text" name="dateofbirth" class="" placeholder="Date of Birth (MM/DD/YYYY)" dateformat="M d y" min="01/01/1900" max="12/31/2020" onfocus="(this.type='date')" onkeypress="if ( isNaN(String.fromCharCode(event.keyCode) )) return false;" onchange="checkDOB()" onKeyUp="checkDOB()" onmouseup="checkDOB()"><br>
|
||||
<center>
|
||||
<div class="radio-toolbar">
|
||||
<input type="radio" id="radiom" name="sex" value="m" checked>
|
||||
<label for="radiom">Male</label>
|
||||
|
||||
<input type="radio" id="radiof" name="sex" value="f">
|
||||
<label for="radiof">Female</label>
|
||||
</div>
|
||||
</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="5px">Submit</font></button>
|
||||
</form>
|
||||
<center><font size="1px" color="red">If the submit button doesn't work, please ensure that you've entered the fields correctly.</font></center>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
const allRanges = document.querySelectorAll(".range-wrap");
|
||||
allRanges.forEach(wrap => {
|
||||
const range = wrap.querySelector(".range");
|
||||
const bubble = wrap.querySelector(".bubble");
|
||||
|
||||
range.addEventListener("input", () => {
|
||||
setBubble(range, bubble);
|
||||
});
|
||||
setBubble(range, bubble);
|
||||
});
|
||||
|
||||
function setBubble(range, bubble) {
|
||||
const val = range.value;
|
||||
const min = range.min ? range.min : 0;
|
||||
const max = range.max ? range.max : 100;
|
||||
const newVal = Number(((val - min) * 100) / (max - min));
|
||||
bubble.innerHTML = 'Height: ' + val;
|
||||
bubble.style.left = `calc(${newVal}% + (${8 - newVal * 0.15}px))`;
|
||||
}
|
||||
|
||||
var myFirstName = document.getElementById('firstname');
|
||||
var myLastName = document.getElementById('lastname');
|
||||
var myDOB = document.getElementById('dateofbirth');
|
||||
var myHeight = document.getElementById('height');
|
||||
|
||||
function isNumber(e) {
|
||||
var key=e.which || e.KeyCode;
|
||||
if ( key >=48 && key <= 57) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkFirstName() {
|
||||
var value = myFirstName.value;
|
||||
if(value.trim().match(/^[a-zA-Z][0-9a-zA-Z .,'-]*$/) == null) {
|
||||
myFirstName.style.backgroundColor = '#E06666';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
if(value.length > 0 && value.length < 17) {
|
||||
myFirstName.style.backgroundColor = '#B6D7A8';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
myFirstName.style.backgroundColor = '#E06666';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkLastName() {
|
||||
var value = myLastName.value;
|
||||
if(value.trim().match(/^[a-zA-Z][0-9a-zA-Z .,'-]*$/) == null) {
|
||||
myLastName.style.backgroundColor = '#E06666';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
if(value.length > 0 && value.length < 17) {
|
||||
myLastName.style.backgroundColor = '#B6D7A8';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
myLastName.style.backgroundColor = '#E06666';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkDOB() {
|
||||
var date = new Date($('#dateofbirth').val());
|
||||
day = date.getDate();
|
||||
month = date.getMonth() + 1;
|
||||
year = date.getFullYear();
|
||||
if (isNaN(month) || isNaN(day) || isNaN(year)) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
var dateInput = [month, day, year].join('/');
|
||||
|
||||
var regExp = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
|
||||
var dateArray = dateInput.match(regExp);
|
||||
|
||||
if (dateArray == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
month = dateArray[1];
|
||||
day= dateArray[3];
|
||||
year = dateArray[5];
|
||||
|
||||
if (month < 1 || month > 12){
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if (day < 1 || day> 31) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if ((month==4 || month==6 || month==9 || month==11) && day ==31) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if (month == 2) {
|
||||
var isLeapYear = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
|
||||
if (day> 29 || (day ==29 && !isLeapYear)){
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
}
|
||||
else {
|
||||
myDOB.style.backgroundColor = '#B6D7A8';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function TriggeredKey(e) {
|
||||
var keycode;
|
||||
if (window.event) keycode = window.event.keyCode;
|
||||
if (window.event.keyCode == 13 || window.event.keyCode == 27) return false;
|
||||
}
|
||||
</script>
|
||||
<script src="js/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,150 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
||||
<link href="css/style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body onkeydown="TriggeredKey(this)">
|
||||
<div class="dialog">
|
||||
<img id="logo" src="img/esx_identity.png" height="110px" width="332px">
|
||||
<form id="register" name="register" action="#">
|
||||
<input id="firstname" type="text" class="" name="firstname" placeholder="First Name (Max 16 Characters)" onKeyDown="if(this.value.length==16 && event.keyCode!=8) return false;" onkeypress="if (isNumber(event) == true) return false;" onKeyUp="checkFirstName()" onmouseup="checkFirstName()"><br>
|
||||
<input id="lastname" type="text" class="" name="lastname" placeholder="Last Name (Max 16 Characters)" onKeyDown="if(this.value.length==16 && event.keyCode!=8) return false;" onkeypress="if (isNumber(event) == true) return false;" onKeyUp="checkLastName()" onmouseup="checkLastName()"><br>
|
||||
<input id="dateofbirth" type="text" name="dateofbirth" class="" placeholder="Date of Birth (MM/DD/YYYY)" dateformat="M d y" min="01/01/1900" max="12/31/2020" onfocus="(this.type='date')" onkeypress="if ( isNaN(String.fromCharCode(event.keyCode) )) return false;" onchange="checkDOB()" onKeyUp="checkDOB()" onmouseup="checkDOB()"><br>
|
||||
<input id="height" type="number" class="" name="height" min="48" max="96" placeholder="Height In Inches (48-96)" onKeyDown="if(this.value.length==2 && event.keyCode!=8) return false;" onkeypress="if ( isNaN(String.fromCharCode(event.keyCode) )) return false;" onKeyUp="checkHeight()" onmouseup="checkHeight()"><br>
|
||||
<center>
|
||||
<div class="radio-toolbar">
|
||||
<input type="radio" id="radiom" name="sex" value="m" checked>
|
||||
<label for="radiom">Male</label>
|
||||
|
||||
<input type="radio" id="radiof" name="sex" value="f">
|
||||
<label for="radiof">Female</label>
|
||||
</div>
|
||||
</center>
|
||||
<button id="submit" type="submit"><font size="5px">Submit</font></button>
|
||||
</form>
|
||||
<center><font size="1px" color="red">If the submit button doesn't work, please ensure that you've entered the fields correctly.</font></center>
|
||||
</div>
|
||||
<script>
|
||||
var myFirstName = document.getElementById('firstname');
|
||||
var myLastName = document.getElementById('lastname');
|
||||
var myDOB = document.getElementById('dateofbirth');
|
||||
var myHeight = document.getElementById('height');
|
||||
|
||||
function isNumber(e) {
|
||||
var key=e.which || e.KeyCode;
|
||||
if ( key >=48 && key <= 57) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkFirstName() {
|
||||
var value = myFirstName.value;
|
||||
if(value.trim().match(/^[a-zA-Z][0-9a-zA-Z .,'-]*$/) == null) {
|
||||
myFirstName.style.backgroundColor = '#E06666';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
if(value.length > 0 && value.length < 17) {
|
||||
myFirstName.style.backgroundColor = '#B6D7A8';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
myFirstName.style.backgroundColor = '#E06666';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkLastName() {
|
||||
var value = myLastName.value;
|
||||
if(value.trim().match(/^[a-zA-Z][0-9a-zA-Z .,'-]*$/) == null) {
|
||||
myLastName.style.backgroundColor = '#E06666';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
if(value.length > 0 && value.length < 17) {
|
||||
myLastName.style.backgroundColor = '#B6D7A8';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
myLastName.style.backgroundColor = '#E06666';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkDOB() {
|
||||
var date = new Date($('#dateofbirth').val());
|
||||
day = date.getDate();
|
||||
month = date.getMonth() + 1;
|
||||
year = date.getFullYear();
|
||||
if (isNaN(month) || isNaN(day) || isNaN(year)) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
var dateInput = [month, day, year].join('/');
|
||||
|
||||
var regExp = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
|
||||
var dateArray = dateInput.match(regExp);
|
||||
|
||||
if (dateArray == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
month = dateArray[1];
|
||||
day= dateArray[3];
|
||||
year = dateArray[5];
|
||||
|
||||
if (month < 1 || month > 12){
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if (day < 1 || day> 31) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if ((month==4 || month==6 || month==9 || month==11) && day ==31) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if (month == 2) {
|
||||
var isLeapYear = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
|
||||
if (day> 29 || (day ==29 && !isLeapYear)){
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
}
|
||||
else {
|
||||
myDOB.style.backgroundColor = '#B6D7A8';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkHeight() {
|
||||
var value = myHeight.value;
|
||||
if (!value || isNaN(value) || parseInt(value, 10) < 48 || parseInt(value, 10) > 96) {
|
||||
myHeight.style.backgroundColor = '#E06666';
|
||||
myHeight.style.color = 'black';
|
||||
} else {
|
||||
myHeight.style.backgroundColor = '#B6D7A8';
|
||||
myHeight.style.color = 'black';
|
||||
}
|
||||
}
|
||||
|
||||
function TriggeredKey(e) {
|
||||
var keycode;
|
||||
if (window.event) keycode = window.event.keyCode;
|
||||
if (window.event.keyCode == 13 || window.event.keyCode == 27) return false;
|
||||
}
|
||||
</script>
|
||||
<script src="js/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,163 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
||||
<link href="css/style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body onkeydown="TriggeredKey(this)">
|
||||
<div class="dialog">
|
||||
<img id="logo" src="img/esx_identity.png" height="110px" width="332px">
|
||||
<form id="register" name="register" action="#">
|
||||
<input id="firstname" type="text" class="" name="firstname" placeholder="First Name (Max 16 Characters)" onKeyDown="if(this.value.length==16 && event.keyCode!=8) return false;" onkeypress="if (isNumber(event) == true) return false;" onKeyUp="checkFirstName()" onmouseup="checkFirstName()"><br>
|
||||
<input id="lastname" type="text" class="" name="lastname" placeholder="Last Name (Max 16 Characters)" onKeyDown="if(this.value.length==16 && event.keyCode!=8) return false;" onkeypress="if (isNumber(event) == true) return false;" onKeyUp="checkLastName()" onmouseup="checkLastName()"><br>
|
||||
<input id="dateofbirth" type="text" name="dateofbirth" class="" placeholder="Date of Birth (MM/DD/YYYY)" dateformat="M d y" min="01/01/1900" max="12/31/2020" onfocus="(this.type='date')" onkeypress="if ( isNaN(String.fromCharCode(event.keyCode) )) return false;" onchange="checkDOB()" onKeyUp="checkDOB()" onmouseup="checkDOB()"><br>
|
||||
<center>
|
||||
<div class="radio-toolbar">
|
||||
<input type="radio" id="radiom" name="sex" value="m" checked>
|
||||
<label for="radiom">Male</label>
|
||||
|
||||
<input type="radio" id="radiof" name="sex" value="f">
|
||||
<label for="radiof">Female</label>
|
||||
</div>
|
||||
</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="5px">Submit</font></button>
|
||||
</form>
|
||||
<center><font size="1px" color="red">If the submit button doesn't work, please ensure that you've entered the fields correctly.</font></center>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
const allRanges = document.querySelectorAll(".range-wrap");
|
||||
allRanges.forEach(wrap => {
|
||||
const range = wrap.querySelector(".range");
|
||||
const bubble = wrap.querySelector(".bubble");
|
||||
|
||||
range.addEventListener("input", () => {
|
||||
setBubble(range, bubble);
|
||||
});
|
||||
setBubble(range, bubble);
|
||||
});
|
||||
|
||||
function setBubble(range, bubble) {
|
||||
const val = range.value;
|
||||
const min = range.min ? range.min : 0;
|
||||
const max = range.max ? range.max : 100;
|
||||
const newVal = Number(((val - min) * 100) / (max - min));
|
||||
bubble.innerHTML = 'Height: ' + val;
|
||||
bubble.style.left = `calc(${newVal}% + (${8 - newVal * 0.15}px))`;
|
||||
}
|
||||
|
||||
var myFirstName = document.getElementById('firstname');
|
||||
var myLastName = document.getElementById('lastname');
|
||||
var myDOB = document.getElementById('dateofbirth');
|
||||
var myHeight = document.getElementById('height');
|
||||
|
||||
function isNumber(e) {
|
||||
var key=e.which || e.KeyCode;
|
||||
if ( key >=48 && key <= 57) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkFirstName() {
|
||||
var value = myFirstName.value;
|
||||
if(value.trim().match(/^[a-zA-Z][0-9a-zA-Z .,'-]*$/) == null) {
|
||||
myFirstName.style.backgroundColor = '#E06666';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
if(value.length > 0 && value.length < 17) {
|
||||
myFirstName.style.backgroundColor = '#B6D7A8';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
myFirstName.style.backgroundColor = '#E06666';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkLastName() {
|
||||
var value = myLastName.value;
|
||||
if(value.trim().match(/^[a-zA-Z][0-9a-zA-Z .,'-]*$/) == null) {
|
||||
myLastName.style.backgroundColor = '#E06666';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
if(value.length > 0 && value.length < 17) {
|
||||
myLastName.style.backgroundColor = '#B6D7A8';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
myLastName.style.backgroundColor = '#E06666';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkDOB() {
|
||||
var date = new Date($('#dateofbirth').val());
|
||||
day = date.getDate();
|
||||
month = date.getMonth() + 1;
|
||||
year = date.getFullYear();
|
||||
if (isNaN(month) || isNaN(day) || isNaN(year)) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
var dateInput = [month, day, year].join('/');
|
||||
|
||||
var regExp = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
|
||||
var dateArray = dateInput.match(regExp);
|
||||
|
||||
if (dateArray == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
month = dateArray[1];
|
||||
day= dateArray[3];
|
||||
year = dateArray[5];
|
||||
|
||||
if (month < 1 || month > 12){
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if (day < 1 || day> 31) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if ((month==4 || month==6 || month==9 || month==11) && day ==31) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if (month == 2) {
|
||||
var isLeapYear = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
|
||||
if (day> 29 || (day ==29 && !isLeapYear)){
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
}
|
||||
else {
|
||||
myDOB.style.backgroundColor = '#B6D7A8';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function TriggeredKey(e) {
|
||||
var keycode;
|
||||
if (window.event) keycode = window.event.keyCode;
|
||||
if (window.event.keyCode == 13 || window.event.keyCode == 27) return false;
|
||||
}
|
||||
</script>
|
||||
<script src="js/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,150 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
||||
<link href="css/style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body onkeydown="TriggeredKey(this)">
|
||||
<div class="dialog">
|
||||
<img id="logo" src="img/esx_identity.png" height="110px" width="332px">
|
||||
<form id="register" name="register" action="#">
|
||||
<input id="firstname" type="text" class="" name="firstname" placeholder="First Name (Max 16 Characters)" onKeyDown="if(this.value.length==16 && event.keyCode!=8) return false;" onkeypress="if (isNumber(event) == true) return false;" onKeyUp="checkFirstName()" onmouseup="checkFirstName()"><br>
|
||||
<input id="lastname" type="text" class="" name="lastname" placeholder="Last Name (Max 16 Characters)" onKeyDown="if(this.value.length==16 && event.keyCode!=8) return false;" onkeypress="if (isNumber(event) == true) return false;" onKeyUp="checkLastName()" onmouseup="checkLastName()"><br>
|
||||
<input id="dateofbirth" type="text" name="dateofbirth" class="" placeholder="Date of Birth (MM/DD/YYYY)" dateformat="M d y" min="01/01/1900" max="12/31/2020" onfocus="(this.type='date')" onkeypress="if ( isNaN(String.fromCharCode(event.keyCode) )) return false;" onchange="checkDOB()" onKeyUp="checkDOB()" onmouseup="checkDOB()"><br>
|
||||
<input id="height" type="number" class="" name="height" min="48" max="96" placeholder="Height In Inches (48-96)" onKeyDown="if(this.value.length==2 && event.keyCode!=8) return false;" onkeypress="if ( isNaN(String.fromCharCode(event.keyCode) )) return false;" onKeyUp="checkHeight()" onmouseup="checkHeight()"><br>
|
||||
<center>
|
||||
<div class="radio-toolbar">
|
||||
<input type="radio" id="radiom" name="sex" value="m" checked>
|
||||
<label for="radiom">Male</label>
|
||||
|
||||
<input type="radio" id="radiof" name="sex" value="f">
|
||||
<label for="radiof">Female</label>
|
||||
</div>
|
||||
</center>
|
||||
<button id="submit" type="submit"><font size="5px">Submit</font></button>
|
||||
</form>
|
||||
<center><font size="1px" color="red">If the submit button doesn't work, please ensure that you've entered the fields correctly.</font></center>
|
||||
</div>
|
||||
<script>
|
||||
var myFirstName = document.getElementById('firstname');
|
||||
var myLastName = document.getElementById('lastname');
|
||||
var myDOB = document.getElementById('dateofbirth');
|
||||
var myHeight = document.getElementById('height');
|
||||
|
||||
function isNumber(e) {
|
||||
var key=e.which || e.KeyCode;
|
||||
if ( key >=48 && key <= 57) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkFirstName() {
|
||||
var value = myFirstName.value;
|
||||
if(value.trim().match(/^[a-zA-Z][0-9a-zA-Z .,'-]*$/) == null) {
|
||||
myFirstName.style.backgroundColor = '#E06666';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
if(value.length > 0 && value.length < 17) {
|
||||
myFirstName.style.backgroundColor = '#B6D7A8';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
myFirstName.style.backgroundColor = '#E06666';
|
||||
myFirstName.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkLastName() {
|
||||
var value = myLastName.value;
|
||||
if(value.trim().match(/^[a-zA-Z][0-9a-zA-Z .,'-]*$/) == null) {
|
||||
myLastName.style.backgroundColor = '#E06666';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
if(value.length > 0 && value.length < 17) {
|
||||
myLastName.style.backgroundColor = '#B6D7A8';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
myLastName.style.backgroundColor = '#E06666';
|
||||
myLastName.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkDOB() {
|
||||
var date = new Date($('#dateofbirth').val());
|
||||
day = date.getDate();
|
||||
month = date.getMonth() + 1;
|
||||
year = date.getFullYear();
|
||||
if (isNaN(month) || isNaN(day) || isNaN(year)) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else {
|
||||
var dateInput = [month, day, year].join('/');
|
||||
|
||||
var regExp = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
|
||||
var dateArray = dateInput.match(regExp);
|
||||
|
||||
if (dateArray == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
month = dateArray[1];
|
||||
day= dateArray[3];
|
||||
year = dateArray[5];
|
||||
|
||||
if (month < 1 || month > 12){
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if (day < 1 || day> 31) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if ((month==4 || month==6 || month==9 || month==11) && day ==31) {
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
else if (month == 2) {
|
||||
var isLeapYear = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
|
||||
if (day> 29 || (day ==29 && !isLeapYear)){
|
||||
myDOB.style.backgroundColor = '#E06666';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
}
|
||||
else {
|
||||
myDOB.style.backgroundColor = '#B6D7A8';
|
||||
myDOB.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkHeight() {
|
||||
var value = myHeight.value;
|
||||
if (!value || isNaN(value) || parseInt(value, 10) < 48 || parseInt(value, 10) > 96) {
|
||||
myHeight.style.backgroundColor = '#E06666';
|
||||
myHeight.style.color = 'black';
|
||||
} else {
|
||||
myHeight.style.backgroundColor = '#B6D7A8';
|
||||
myHeight.style.color = 'black';
|
||||
}
|
||||
}
|
||||
|
||||
function TriggeredKey(e) {
|
||||
var keycode;
|
||||
if (window.event) keycode = window.event.keyCode;
|
||||
if (window.event.keyCode == 13 || window.event.keyCode == 27) return false;
|
||||
}
|
||||
</script>
|
||||
<script src="js/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,34 @@
|
||||
$(function() {
|
||||
window.addEventListener('message', function(event) {
|
||||
if (event.data.type == "enableui") {
|
||||
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());
|
||||
|
||||
if (dateCheck == "Invalid Date") {
|
||||
date == "invalid";
|
||||
}
|
||||
else {
|
||||
const ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(dateCheck)
|
||||
const mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(dateCheck)
|
||||
const da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(dateCheck)
|
||||
|
||||
var formattedDate = `${mo}/${da}/${ye}`;
|
||||
|
||||
$.post('http://esx_identity/register', JSON.stringify({
|
||||
firstname: $("#firstname").val(),
|
||||
lastname: $("#lastname").val(),
|
||||
dateofbirth: formattedDate,
|
||||
sex: $("input[type='radio'][name='sex']:checked").val(),
|
||||
height: $("#height").val()
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<link href="style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="dialog">
|
||||
<form id="register">
|
||||
<h1>Register</h1>
|
||||
<input id="firstname" type="text" placeholder="Křestní jméno"><br>
|
||||
<input id="lastname" type="text" placeholder="Příjmení"><br>
|
||||
<input id="dateofbirth" type="text" placeholder="Datum narození (YYYY-MM-DD)"><br>
|
||||
<input id="height" type="text" placeholder="Výška (140-200 cm)"><br><center>
|
||||
<input type="radio" name="sex" value="m" checked>Male
|
||||
<input type="radio" name="sex" value="ž">Female<br></center>
|
||||
<button id="submit" type="submit">Vytvořit</button>
|
||||
</form>
|
||||
</div>
|
||||
<script src="script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<link href="style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="dialog">
|
||||
<form id="register">
|
||||
<h1>Rekistöröinti</h1>
|
||||
<input id="firstname" type="text" placeholder="Etunimi"><br>
|
||||
<input id="lastname" type="text" placeholder="Sukunimi"><br>
|
||||
<input id="dateofbirth" type="text" placeholder="Syntymäaika (PP.KK.VVVV)"><br>
|
||||
<input id="height" type="text" placeholder="Pituus (140-200 cm)"><br><center>
|
||||
<input type="radio" name="sex" value="m" checked>Mies
|
||||
<input type="radio" name="sex" value="f">Nainen<br></center>
|
||||
<button id="submit" type="submit">Luo</button>
|
||||
</form>
|
||||
</div>
|
||||
<script src="script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<link href="style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="dialog">
|
||||
<form id="register">
|
||||
<h1>등록</h1>
|
||||
<input id="firstname" type="text" placeholder="이름"><br>
|
||||
<input id="lastname" type="text" placeholder="성"><br>
|
||||
<input id="dateofbirth" type="text" placeholder="생일 (YYYY-MM-DD)"><br>
|
||||
<input id="height" type="text" placeholder="키 (140-200 cm)"><br><center>
|
||||
<input type="radio" name="sex" value="m" checked>남자
|
||||
<input type="radio" name="sex" value="f">여자<br></center>
|
||||
<button id="submit" type="submit">생성</button>
|
||||
</form>
|
||||
</div>
|
||||
<script src="script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<link href="style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="dialog">
|
||||
<form id="register">
|
||||
<h1>Registrera</h1>
|
||||
<input id="firstname" type="text" placeholder="Förnamn"><br>
|
||||
<input id="lastname" type="text" placeholder="Efternamn"><br>
|
||||
<input id="dateofbirth" type="text" placeholder="Födelsedatum (YYYY-MM-DD)"><br>
|
||||
<input id="height" type="text" placeholder="Längd (140-200 cm)"><br><center>
|
||||
<input type="radio" name="sex" value="m" checked>Man
|
||||
<input type="radio" name="sex" value="f">Kvinna<br></center>
|
||||
<button id="submit" type="submit">Skapa</button>
|
||||
</form>
|
||||
</div>
|
||||
<script src="script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
+9
-4
@@ -1,6 +1,11 @@
|
||||
Locales['cs'] = {
|
||||
['data_incorrect'] = 'data byla zadána nesprávně. Prosím zkuste to znovu.',
|
||||
['invalid_format'] = 'data byla nesprávně naformátována. Prosím zkuste to znovu.',
|
||||
['no_identifier'] = 'there was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.',
|
||||
['missing_identity'] = 'there was an error loading your character!\nError code: identity-missing\n\nIt seems like your identity is missing, try connecting again.',
|
||||
['show_registration'] = 'zobrazit registracni menu',
|
||||
['show_active_character'] = 'zobrazit aktivni postavy',
|
||||
['delete_character'] = 'smazat svou stavajici postavu a vytvorit novou',
|
||||
['deleted_character'] = 'vase postava byla smazana.',
|
||||
['not_registered'] = 'nemas zaregistrovanou postavu.',
|
||||
['active_character'] = '~b~aktivni postava:~s~ %s %s',
|
||||
['already_registered'] = 'jiz mas zaregistrovanou postavu.',
|
||||
['failed_identity'] = 'nastaveni vasi postavy selhalo, zkus to prosim znovu pozdeji nebo kontaktuj majitele serveru!',
|
||||
['create_a_character'] = 'aby jsi mohl/a hrat, tak se musis registrovat.'
|
||||
}
|
||||
|
||||
+31
-4
@@ -1,6 +1,33 @@
|
||||
Locales['en'] = {
|
||||
['data_incorrect'] = 'data entered incorrectly. Please try again.',
|
||||
['invalid_format'] = 'data formatted incorrectly. Please try again.',
|
||||
['no_identifier'] = 'there was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.',
|
||||
['missing_identity'] = 'there was an error loading your character!\nError code: identity-missing\n\nIt seems like your identity is missing, try connecting again.',
|
||||
['show_active_character'] = 'Show Active Character',
|
||||
['active_character'] = 'Active Character: ~b~%s~s~',
|
||||
['error_active_character'] = "There was an error retrieving your name. Please contact an admin.",
|
||||
['delete_character'] = 'Delete Your Character And Create A New One',
|
||||
['deleted_character'] = 'Your character has been deleted.',
|
||||
['error_delete_character'] = "There was an error deleting your character. Please contact an admin.",
|
||||
['thank_you_for_registering'] = "Thank you for registering. Have fun.",
|
||||
['registration_error'] = "There was an error during registration. Please contact an admin.",
|
||||
['debug_xPlayer_get_first_name'] = "Return Your First Name",
|
||||
['debug_xPlayer_get_last_name'] = "Return Your Last Name",
|
||||
['debug_xPlayer_get_full_name'] = "Return Your Full Name",
|
||||
['debug_xPlayer_get_sex'] = "Return Your Sex",
|
||||
['debug_xPlayer_get_dob'] = "Return Your DOB",
|
||||
['debug_xPlayer_get_height'] = "Return Your Height",
|
||||
['error_debug_xPlayer_get_first_name'] = "There was an error retrieving your first name.",
|
||||
['error_debug_xPlayer_get_last_name'] = "There was an error retrieving your last name.",
|
||||
['error_debug_xPlayer_get_full_name'] = "There was an error retrieving your full name.",
|
||||
['error_debug_xPlayer_get_sex'] = "There was an error retrieving your sex.",
|
||||
['error_debug_xPlayer_get_dob'] = "There was an error retrieving your date of birth.",
|
||||
['error_debug_xPlayer_get_height'] = "There was an error retrieving your height.",
|
||||
['return_debug_xPlayer_get_first_name'] = "First Name: ~b~%s",
|
||||
['return_debug_xPlayer_get_last_name'] = "Last Name: ~b~%s",
|
||||
['return_debug_xPlayer_get_full_name'] = "Full Name: ~b~%s",
|
||||
['return_debug_xPlayer_get_sex'] = "Sex: ~b~%s",
|
||||
['return_debug_xPlayer_get_dob'] = "DOB: ~b~%s",
|
||||
['return_debug_xPlayer_get_height'] = "Height: ~b~%s Inches",
|
||||
['data_incorrect'] = 'Data entered incorrectly. Please try again.',
|
||||
['invalid_format'] = 'Data formatted incorrectly. Please try again.',
|
||||
['no_identifier'] = 'There was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.',
|
||||
['missing_identity'] = 'There was an error loading your character!\nError code: identity-missing\n\nIt seems like your identity is missing, try connecting again.',
|
||||
['deleted_identity'] = 'Your character has been deleted. Please login again in order to create a new character.'
|
||||
}
|
||||
|
||||
+436
-87
@@ -1,95 +1,455 @@
|
||||
ESX = nil
|
||||
local playerIdentity = {}
|
||||
|
||||
local alreadyRegistered = {}
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
|
||||
deferrals.defer()
|
||||
local playerId, identifier = source
|
||||
Citizen.Wait(100)
|
||||
|
||||
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
|
||||
if string.match(v, 'license:') then
|
||||
identifier = string.sub(v, 9)
|
||||
break
|
||||
if Config.UseDeferrals then
|
||||
AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
|
||||
deferrals.defer()
|
||||
local playerId, identifier = source
|
||||
Citizen.Wait(100)
|
||||
|
||||
if Config.UseSteamID then
|
||||
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
|
||||
if string.match(v, 'steam:') then
|
||||
identifier = v
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
|
||||
if string.match(v, 'license:') then
|
||||
identifier = string.sub(v, 9)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if identifier then
|
||||
MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', {
|
||||
['@identifier'] = identifier
|
||||
}, function(result)
|
||||
if result[1] then
|
||||
if result[1].firstname then
|
||||
playerIdentity[identifier] = {
|
||||
firstName = result[1].firstname,
|
||||
lastName = result[1].lastname,
|
||||
dateOfBirth = result[1].dateofbirth,
|
||||
sex = result[1].sex,
|
||||
height = result[1].height
|
||||
}
|
||||
|
||||
deferrals.done()
|
||||
else
|
||||
deferrals.presentCard([==[{"type": "AdaptiveCard","body":[{"type":"Container","items":[{"type":"ColumnSet","columns":[{"type":"Column","items":[{"type":"Input.Text","placeholder":"First Name","id":"firstname","maxLength":15},{"type":"Input.Text","placeholder":"Date of Birth (MM/DD/YYYY)","id":"dateofbirth","maxLength":10}],"width":"stretch"},{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Last Name","id":"lastname","maxLength":15},{"type":"Input.Text","placeholder":"Height (48-96 inches)","id":"height","maxLength":2}]}]},{"type":"Input.ChoiceSet","placeholder":"Sex","choices":[{"title":"Male","value":"m"},{"title":"Female","value":"f"}],"style":"expanded","id":"sex"}]},{"type": "ActionSet","actions": [{"type":"Action.Submit","title":"Submit"}]}],"$schema": "http://adaptivecards.io/schemas/adaptive-card.json","version":"1.0"}]==], function(data, rawData)
|
||||
if data.firstname == '' or data.lastname == '' or data.dateofbirth == '' or data.sex == '' or data.height == '' then
|
||||
deferrals.done(_U('data_incorrect'))
|
||||
else
|
||||
if checkNameFormat(data.firstname) and checkNameFormat(data.lastname) and checkDOBFormat(data.dateofbirth) and checkSexFormat(data.sex) and checkHeightFormat(data.height) then
|
||||
playerIdentity[identifier] = {
|
||||
firstName = formatName(data.firstname),
|
||||
lastName = formatName(data.lastname),
|
||||
dateOfBirth = data.dateofbirth,
|
||||
sex = data.sex,
|
||||
height = tonumber(data.height),
|
||||
saveToDatabase = true
|
||||
}
|
||||
|
||||
deferrals.done()
|
||||
else
|
||||
deferrals.done(_U('invalid_format'))
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
else
|
||||
deferrals.presentCard([==[{"type": "AdaptiveCard","body":[{"type":"Container","items":[{"type":"ColumnSet","columns":[{"type":"Column","items":[{"type":"Input.Text","placeholder":"First Name","id":"firstname","maxLength":15},{"type":"Input.Text","placeholder":"Date of Birth (MM/DD/YYYY)","id":"dateofbirth","maxLength":10}],"width":"stretch"},{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Last Name","id":"lastname","maxLength":15},{"type":"Input.Text","placeholder":"Height (48-96 inches)","id":"height","maxLength":2}]}]},{"type":"Input.ChoiceSet","placeholder":"Sex","choices":[{"title":"Male","value":"m"},{"title":"Female","value":"f"}],"style":"expanded","id":"sex"}]},{"type": "ActionSet","actions": [{"type":"Action.Submit","title":"Submit"}]}],"$schema": "http://adaptivecards.io/schemas/adaptive-card.json","version":"1.0"}]==], function(data, rawData)
|
||||
if data.firstname == '' or data.lastname == '' or data.dateofbirth == '' or data.sex == '' or data.height == '' then
|
||||
deferrals.done(_U('data_incorrect'))
|
||||
else
|
||||
if checkNameFormat(data.firstname) and checkNameFormat(data.lastname) and checkDOBFormat(data.dateofbirth) and checkSexFormat(data.sex) and checkHeightFormat(data.height) then
|
||||
playerIdentity[identifier] = {
|
||||
firstName = formatName(data.firstname),
|
||||
lastName = formatName(data.lastname),
|
||||
dateOfBirth = data.dateofbirth,
|
||||
sex = data.sex,
|
||||
height = tonumber(data.height),
|
||||
saveToDatabase = true
|
||||
}
|
||||
|
||||
deferrals.done()
|
||||
else
|
||||
deferrals.done(_U('invalid_format'))
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
else
|
||||
deferrals.done(_U('no_identifier'))
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
|
||||
if playerIdentity[xPlayer.identifier] then
|
||||
local currentIdentity = playerIdentity[xPlayer.identifier]
|
||||
|
||||
xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName))
|
||||
xPlayer.set('firstName', currentIdentity.firstName)
|
||||
xPlayer.set('lastName', currentIdentity.lastName)
|
||||
xPlayer.set('dateofbirth', currentIdentity.dateOfBirth)
|
||||
xPlayer.set('sex', currentIdentity.sex)
|
||||
xPlayer.set('height', currentIdentity.height)
|
||||
|
||||
if currentIdentity.saveToDatabase then
|
||||
saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
|
||||
end
|
||||
|
||||
if identifier then
|
||||
Citizen.Wait(1000)
|
||||
alreadyRegistered[xPlayer.identifier] = true
|
||||
TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source)
|
||||
|
||||
playerIdentity[xPlayer.identifier] = nil
|
||||
else
|
||||
xPlayer.kick(_('missing_identity'))
|
||||
end
|
||||
end)
|
||||
elseif not Config.UseDeferrals then
|
||||
AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
|
||||
deferrals.defer()
|
||||
local playerId, identifier = source
|
||||
Citizen.Wait(100)
|
||||
|
||||
if Config.UseSteamID then
|
||||
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
|
||||
if string.match(v, 'steam:') then
|
||||
identifier = v
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
|
||||
if string.match(v, 'license:') then
|
||||
identifier = string.sub(v, 9)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if identifier then
|
||||
MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', {
|
||||
['@identifier'] = identifier
|
||||
}, function(result)
|
||||
if result[1] then
|
||||
if result[1].firstname then
|
||||
playerIdentity[identifier] = {
|
||||
firstName = result[1].firstname,
|
||||
lastName = result[1].lastname,
|
||||
dateOfBirth = result[1].dateofbirth,
|
||||
sex = result[1].sex,
|
||||
height = result[1].height
|
||||
}
|
||||
|
||||
alreadyRegistered[identifier] = true
|
||||
|
||||
deferrals.done()
|
||||
else
|
||||
playerIdentity[identifier] = nil
|
||||
alreadyRegistered[identifier] = false
|
||||
deferrals.done()
|
||||
end
|
||||
else
|
||||
playerIdentity[identifier] = nil
|
||||
alreadyRegistered[identifier] = false
|
||||
deferrals.done()
|
||||
end
|
||||
end)
|
||||
else
|
||||
deferrals.done(_U('no_identifier'))
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStart', function(resource)
|
||||
if resource == GetCurrentResourceName() then
|
||||
Citizen.Wait(1000)
|
||||
|
||||
while not ESX do
|
||||
Citizen.Wait(10)
|
||||
end
|
||||
|
||||
local xPlayers = ESX.GetPlayers()
|
||||
|
||||
for i=1, #xPlayers, 1 do
|
||||
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
|
||||
|
||||
if xPlayer then
|
||||
checkIdentity(xPlayer)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
|
||||
if alreadyRegistered[xPlayer.identifier] == true then
|
||||
local currentIdentity = playerIdentity[xPlayer.identifier]
|
||||
|
||||
xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName))
|
||||
xPlayer.set('firstName', currentIdentity.firstName)
|
||||
xPlayer.set('lastName', currentIdentity.lastName)
|
||||
xPlayer.set('dateofbirth', currentIdentity.dateOfBirth)
|
||||
xPlayer.set('sex', currentIdentity.sex)
|
||||
xPlayer.set('height', currentIdentity.height)
|
||||
|
||||
if currentIdentity.saveToDatabase then
|
||||
saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
|
||||
end
|
||||
|
||||
Citizen.Wait(1000)
|
||||
TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source)
|
||||
|
||||
playerIdentity[xPlayer.identifier] = nil
|
||||
else
|
||||
TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source)
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_identity:registerIdentity', function(source, cb, data)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
if xPlayer then
|
||||
if not alreadyRegistered[xPlayer.identifier] then
|
||||
if checkNameFormat(data.firstname) and checkNameFormat(data.lastname) and checkSexFormat(data.sex) and checkDOBFormat(data.dateofbirth) and checkHeightFormat(data.height) then
|
||||
playerIdentity[xPlayer.identifier] = {
|
||||
firstName = formatName(data.firstname),
|
||||
lastName = formatName(data.lastname),
|
||||
dateOfBirth = data.dateofbirth,
|
||||
sex = data.sex,
|
||||
height = data.height
|
||||
}
|
||||
|
||||
local currentIdentity = playerIdentity[xPlayer.identifier]
|
||||
|
||||
xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName))
|
||||
xPlayer.set('firstName', currentIdentity.firstName)
|
||||
xPlayer.set('lastName', currentIdentity.lastName)
|
||||
xPlayer.set('dateofbirth', currentIdentity.dateOfBirth)
|
||||
xPlayer.set('sex', currentIdentity.sex)
|
||||
xPlayer.set('height', currentIdentity.height)
|
||||
|
||||
saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
|
||||
alreadyRegistered[xPlayer.identifier] = true
|
||||
|
||||
playerIdentity[xPlayer.identifier] = nil
|
||||
cb(true)
|
||||
else
|
||||
cb(false)
|
||||
end
|
||||
else
|
||||
cb(false)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function checkIdentity(xPlayer)
|
||||
MySQL.Async.fetchAll('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = @identifier', {
|
||||
['@identifier'] = identifier
|
||||
['@identifier'] = xPlayer.identifier
|
||||
}, function(result)
|
||||
if result[1] then
|
||||
playerIdentity[identifier] = {
|
||||
firstName = result[1].firstname,
|
||||
lastName = result[1].lastname,
|
||||
dateOfBirth = result[1].dateofbirth,
|
||||
sex = result[1].sex,
|
||||
height = result[1].height
|
||||
}
|
||||
if result[1].firstname then
|
||||
playerIdentity[xPlayer.identifier] = {
|
||||
firstName = result[1].firstname,
|
||||
lastName = result[1].lastname,
|
||||
dateOfBirth = result[1].dateofbirth,
|
||||
sex = result[1].sex,
|
||||
height = result[1].height
|
||||
}
|
||||
|
||||
deferrals.done()
|
||||
alreadyRegistered[xPlayer.identifier] = true
|
||||
|
||||
setIdentity(xPlayer)
|
||||
else
|
||||
playerIdentity[xPlayer.identifier] = nil
|
||||
alreadyRegistered[xPlayer.identifier] = false
|
||||
TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source)
|
||||
end
|
||||
else
|
||||
deferrals.presentCard([==[{"type":"AdaptiveCard","body":[{"type":"Container","items":[{"type":"TextBlock","text":"Identity Registration","horizontalAlignment":"Center","size":"Large","weight":"Bolder"},{"type":"ColumnSet","columns":[{"type":"Column","items":[{"type":"Input.Text","placeholder":"First Name","id":"firstname","maxLength":15}],"width":"stretch"},{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Last Name","id":"lastname","maxLength":15}]}]},{"type":"ColumnSet","columns":[{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Date of Birth (YYYY-MM-DD)","id":"dateofbirth","maxLength":10}],"style":"default"},{"type":"Column","width":"stretch","items":[{"type":"Input.Text","placeholder":"Height (24-96 inches)","id":"height","maxLength":2}]}]},{"type":"Input.ChoiceSet","placeholder":"Sex","choices":[{"title":"Male","value":"m"},{"title":"Female","value":"f"}],"style":"expanded","id":"sex"}],"style":"default","backgroundImage":"https://nischat.se/wp-content/uploads/Light-grey-background-1024x683.jpg"}],"actions":[{"type":"Action.Submit","title":"Submit"}],"$schema":"http://adaptivecards.io/schemas/adaptive-card.json","version":"1.0"}]==], function(data, rawData)
|
||||
if
|
||||
data.firstname == '' or
|
||||
data.lastname == '' or
|
||||
data.dateofbirth == '' or
|
||||
data.sex == '' or
|
||||
data.height == ''
|
||||
then
|
||||
deferrals.done(_U('data_incorrect'))
|
||||
else
|
||||
if
|
||||
checkNameFormat(data.firstname) and
|
||||
checkNameFormat(data.lastname) and
|
||||
checkDOBFormat(data.dateofbirth) and
|
||||
checkSexFormat(data.sex) and
|
||||
checkHeightFormat(data.height)
|
||||
then
|
||||
playerIdentity[identifier] = {
|
||||
firstName = formatName(data.firstname),
|
||||
lastName = formatName(data.lastname),
|
||||
dateOfBirth = data.dateofbirth,
|
||||
sex = data.sex,
|
||||
height = tonumber(data.height),
|
||||
saveToDatabase = true
|
||||
}
|
||||
|
||||
deferrals.done()
|
||||
else
|
||||
deferrals.done(_U('invalid_format'))
|
||||
end
|
||||
end
|
||||
end)
|
||||
TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source)
|
||||
end
|
||||
end)
|
||||
else
|
||||
deferrals.done(_U('no_identifier'))
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
|
||||
if playerIdentity[xPlayer.identifier] then
|
||||
local currentIdentity = playerIdentity[xPlayer.identifier]
|
||||
function setIdentity(xPlayer)
|
||||
if alreadyRegistered[xPlayer.identifier] then
|
||||
local currentIdentity = playerIdentity[xPlayer.identifier]
|
||||
|
||||
xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName))
|
||||
xPlayer.set('firstName', currentIdentity.firstName)
|
||||
xPlayer.set('lastName', currentIdentity.lastName)
|
||||
xPlayer.set('dateofbirth', currentIdentity.dateOfBirth)
|
||||
xPlayer.set('sex', currentIdentity.sex)
|
||||
xPlayer.set('height', currentIdentity.height)
|
||||
xPlayer.setName(('%s %s'):format(currentIdentity.firstName, currentIdentity.lastName))
|
||||
xPlayer.set('firstName', currentIdentity.firstName)
|
||||
xPlayer.set('lastName', currentIdentity.lastName)
|
||||
xPlayer.set('dateofbirth', currentIdentity.dateOfBirth)
|
||||
xPlayer.set('sex', currentIdentity.sex)
|
||||
xPlayer.set('height', currentIdentity.height)
|
||||
|
||||
if currentIdentity.saveToDatabase then
|
||||
SaveIdentityToDatabase(xPlayer.identifier, currentIdentity)
|
||||
if currentIdentity.saveToDatabase then
|
||||
saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
|
||||
end
|
||||
|
||||
playerIdentity[xPlayer.identifier] = nil
|
||||
end
|
||||
|
||||
playerIdentity[xPlayer.identifier] = nil
|
||||
else
|
||||
xPlayer.kick(_('missing_identity'))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if Config.EnableCommands then
|
||||
ESX.RegisterCommand('char', 'user', function(xPlayer, args, showError)
|
||||
if xPlayer and xPlayer.getName() then
|
||||
xPlayer.showNotification(_U('active_character', xPlayer.getName()))
|
||||
else
|
||||
xPlayer.showNotification(_U('error_active_character'))
|
||||
end
|
||||
end, false, {help = _U('show_active_character')})
|
||||
|
||||
ESX.RegisterCommand('chardel', 'user', function(xPlayer, args, showError)
|
||||
if xPlayer and xPlayer.getName() then
|
||||
if Config.UseDeferrals then
|
||||
deleteIdentity(xPlayer)
|
||||
xPlayer.showNotification(_U('deleted_character'))
|
||||
playerIdentity[xPlayer.identifier] = nil
|
||||
alreadyRegistered[xPlayer.identifier] = false
|
||||
Citizen.Wait(2500)
|
||||
xPlayer.kick(_('deleted_identity'))
|
||||
else
|
||||
deleteIdentity(xPlayer)
|
||||
xPlayer.showNotification(_U('deleted_character'))
|
||||
playerIdentity[xPlayer.identifier] = nil
|
||||
alreadyRegistered[xPlayer.identifier] = false
|
||||
TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source)
|
||||
end
|
||||
else
|
||||
xPlayer.showNotification(_U('error_delete_character'))
|
||||
end
|
||||
end, false, {help = _U('delete_character')})
|
||||
end
|
||||
|
||||
if Config.EnableDebugging then
|
||||
ESX.RegisterCommand('xPlayerGetFirstName', 'user', function(xPlayer, args, showError)
|
||||
if xPlayer and xPlayer.get('firstName') then
|
||||
xPlayer.showNotification(_U('return_debug_xPlayer_get_first_name', xPlayer.get('firstName')))
|
||||
else
|
||||
xPlayer.showNotification(_U('error_debug_xPlayer_get_first_name'))
|
||||
end
|
||||
end, false, {help = _U('debug_xPlayer_get_first_name')})
|
||||
|
||||
ESX.RegisterCommand('xPlayerGetLastName', 'user', function(xPlayer, args, showError)
|
||||
if xPlayer and xPlayer.get('lastName') then
|
||||
xPlayer.showNotification(_U('return_debug_xPlayer_get_last_name', xPlayer.get('lastName')))
|
||||
else
|
||||
xPlayer.showNotification(_U('error_debug_xPlayer_get_last_name'))
|
||||
end
|
||||
end, false, {help = _U('debug_xPlayer_get_last_name')})
|
||||
|
||||
ESX.RegisterCommand('xPlayerGetFullName', 'user', function(xPlayer, args, showError)
|
||||
if xPlayer and xPlayer.getName() then
|
||||
xPlayer.showNotification(_U('return_debug_xPlayer_get_full_name', xPlayer.getName()))
|
||||
else
|
||||
xPlayer.showNotification(_U('error_debug_xPlayer_get_full_name'))
|
||||
end
|
||||
end, false, {help = _U('debug_xPlayer_get_full_name')})
|
||||
|
||||
ESX.RegisterCommand('xPlayerGetSex', 'user', function(xPlayer, args, showError)
|
||||
if xPlayer and xPlayer.get('sex') then
|
||||
xPlayer.showNotification(_U('return_debug_xPlayer_get_sex', xPlayer.get('sex')))
|
||||
else
|
||||
xPlayer.showNotification(_U('error_debug_xPlayer_get_sex'))
|
||||
end
|
||||
end, false, {help = _U('debug_xPlayer_get_sex')})
|
||||
|
||||
ESX.RegisterCommand('xPlayerGetDOB', 'user', function(xPlayer, args, showError)
|
||||
if xPlayer and xPlayer.get('dateofbirth') then
|
||||
xPlayer.showNotification(_U('return_debug_xPlayer_get_dob', xPlayer.get('dateofbirth')))
|
||||
else
|
||||
xPlayer.showNotification(_U('error_debug_xPlayer_get_dob'))
|
||||
end
|
||||
end, false, {help = _U('debug_xPlayer_get_dob')})
|
||||
|
||||
ESX.RegisterCommand('xPlayerGetHeight', 'user', function(xPlayer, args, showError)
|
||||
if xPlayer and xPlayer.get('height') then
|
||||
xPlayer.showNotification(_U('return_debug_xPlayer_get_height', xPlayer.get('height')))
|
||||
else
|
||||
xPlayer.showNotification(_U('error_debug_xPlayer_get_height'))
|
||||
end
|
||||
end, false, {help = _U('debug_xPlayer_get_height')})
|
||||
end
|
||||
|
||||
function deleteIdentity(xPlayer)
|
||||
if alreadyRegistered[xPlayer.identifier] then
|
||||
xPlayer.setName(('%s %s'):format(nil, nil))
|
||||
xPlayer.set('firstName', nil)
|
||||
xPlayer.set('lastName', nil)
|
||||
xPlayer.set('dateofbirth', nil)
|
||||
xPlayer.set('sex', nil)
|
||||
xPlayer.set('height', nil)
|
||||
|
||||
deleteIdentityFromDatabase(xPlayer)
|
||||
end
|
||||
end
|
||||
|
||||
function saveIdentityToDatabase(identifier, identity)
|
||||
MySQL.Sync.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', {
|
||||
['@identifier'] = identifier,
|
||||
['@firstname'] = identity.firstName,
|
||||
['@lastname'] = identity.lastName,
|
||||
['@dateofbirth'] = identity.dateOfBirth,
|
||||
['@sex'] = identity.sex,
|
||||
['@height'] = identity.height
|
||||
})
|
||||
end
|
||||
|
||||
function deleteIdentityFromDatabase(xPlayer)
|
||||
MySQL.Sync.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height , skin = @skin WHERE identifier = @identifier', {
|
||||
['@identifier'] = xPlayer.identifier,
|
||||
['@firstname'] = NULL,
|
||||
['@lastname'] = NULL,
|
||||
['@dateofbirth'] = NULL,
|
||||
['@sex'] = NULL,
|
||||
['@height'] = NULL,
|
||||
['@skin'] = NULL
|
||||
})
|
||||
|
||||
MySQL.Sync.execute('UPDATE addon_account_data SET money = 0 WHERE account_name = @account_name AND owner = @owner', {
|
||||
['@account_name'] = 'bank_savings',
|
||||
['@owner'] = xPlayer.identifier
|
||||
})
|
||||
|
||||
MySQL.Sync.execute('UPDATE addon_account_data SET money = 0 WHERE account_name = @account_name AND owner = @owner', {
|
||||
['@account_name'] = 'caution',
|
||||
['@owner'] = xPlayer.identifier
|
||||
})
|
||||
|
||||
MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', {
|
||||
['@data'] = '\'{}\'',
|
||||
['@name'] = 'user_ears',
|
||||
['@owner'] = xPlayer.identifier
|
||||
})
|
||||
|
||||
MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', {
|
||||
['@data'] = '\'{}\'',
|
||||
['@name'] = 'user_glasses',
|
||||
['@owner'] = xPlayer.identifier
|
||||
})
|
||||
|
||||
MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', {
|
||||
['@data'] = '\'{}\'',
|
||||
['@name'] = 'user_helmet',
|
||||
['@owner'] = xPlayer.identifier
|
||||
})
|
||||
|
||||
MySQL.Sync.execute('UPDATE datastore_data SET data = @data WHERE name = @name AND owner = @owner', {
|
||||
['@data'] = '\'{}\'',
|
||||
['@name'] = 'user_mask',
|
||||
['@owner'] = xPlayer.identifier
|
||||
})
|
||||
end
|
||||
|
||||
function checkNameFormat(name)
|
||||
if not checkAlphanumeric(name) then
|
||||
@@ -157,11 +517,11 @@ function checkForNumbers(str)
|
||||
end
|
||||
|
||||
function checkDate(str)
|
||||
if string.match(str, '(%d%d%d%d)-(%d%d)-(%d%d)') ~= nil then
|
||||
local y, m, d = string.match(str, '(%d+)-(%d+)-(%d+)')
|
||||
y = tonumber(y)
|
||||
if string.match(str, '(%d%d)/(%d%d)/(%d%d%d%d)') ~= nil then
|
||||
local m, d, y = string.match(str, '(%d+)/(%d+)/(%d+)')
|
||||
m = tonumber(m)
|
||||
d = tonumber(d)
|
||||
y = tonumber(y)
|
||||
if ((d <= 0) or (d > 31)) or ((m <= 0) or (m > 12)) or ((y <= Config.LowestYear) or (y > Config.HighestYear)) then
|
||||
return false
|
||||
elseif m == 4 or m == 6 or m == 9 or m == 11 then
|
||||
@@ -195,14 +555,3 @@ function checkDate(str)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function SaveIdentityToDatabase(identifier, identity)
|
||||
MySQL.Sync.execute('UPDATE users SET firstname = @firstname, lastname = @lastname, dateofbirth = @dateofbirth, sex = @sex, height = @height WHERE identifier = @identifier', {
|
||||
['@identifier'] = identifier,
|
||||
['@firstname'] = identity.firstName,
|
||||
['@lastname'] = identity.lastName,
|
||||
['@dateofbirth'] = identity.dateOfBirth,
|
||||
['@sex'] = identity.sex,
|
||||
['@height'] = identity.height
|
||||
})
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user