diff --git a/[esx]/esx_identity/.editorconfig b/[esx]/esx_identity/.editorconfig
deleted file mode 100644
index 9b425256..00000000
--- a/[esx]/esx_identity/.editorconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-root = true
-
-[*]
-indent_size = 4
-indent_style = tab
-end_of_line = crlf
-charset = utf-8
-trim_trailing_whitespace = true
-insert_final_newline = true
\ No newline at end of file
diff --git a/[esx]/esx_identity/README.md b/[esx]/esx_identity/README.md
index a310d94b..bda34d05 100644
--- a/[esx]/esx_identity/README.md
+++ b/[esx]/esx_identity/README.md
@@ -1,48 +1,25 @@
-# esx_identity
+
[ESX] Identity Discord - Website - Documentation
+
+A Core Resource that Allows the player to Pick their characters, Name, Gender, Hight and Date-of-birth.
+
+
+
+# Infomation
## Requirements
-* Dependencies For Full Functionality
- * [esx_skin](https://github.com/ESX-Org/esx_skin)
- * [esx_policejob](https://github.com/ESX-Org/esx_policejob)
- * [esx_society](https://github.com/ESX-Org/esx_society)
-## Download & Installation
+ [esx_skin](./../esx_skin/README.md)
-### Using [fvm](https://github.com/qlaffont/fvm-installer)
-```
-fvm install --save --folder=esx esx-org/esx_identity
-```
+## Commands
-### Using Git
-```
-cd resources
-git clone https://github.com/ESX-Org/esx_identity [esx]/esx_identity
-```
-
-### Manually
-- Download https://github.com/ESX-Org/esx_identity/archive/master.zip
-- Put it in the `[esx]` directory
-
-## Installation
-- Import `esx_identity.sql` in your database
-- Add this to your `server.cfg`:
-
-```
-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
+## Legal
+
+esx_identity - Make your Character a Person!
Copyright (C) 2015-2022 Jérémie N'gadi
@@ -50,4 +27,4 @@ This program Is free software: you can redistribute it And/Or modify it under th
This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.
-You should have received a copy Of the GNU General Public License along with this program. If Not, see http://www.gnu.org/licenses/.
+You should have received a copy Of the GNU General Public License along with this program. If Not, see .
diff --git a/[esx]/esx_identity/client/main.lua b/[esx]/esx_identity/client/main.lua
index ddc9af4b..7920fc75 100644
--- a/[esx]/esx_identity/client/main.lua
+++ b/[esx]/esx_identity/client/main.lua
@@ -3,89 +3,92 @@ local ready = false
RegisterNetEvent('esx_identity:alreadyRegistered')
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)
AddEventHandler('esx:loadingScreenOff', function()
- loadingScreenFinished = true
+ loadingScreenFinished = true
end)
RegisterNUICallback('ready', function(data, cb)
- ready = true
- cb(1)
+ ready = true
+ cb(1)
end)
if not Config.UseDeferrals then
- local guiEnabled = false
+ local guiEnabled = false
- function EnableGui(state)
- SetNuiFocus(state, state)
- guiEnabled = state
- while not ready do
- Wait(500)
- end
- SendNUIMessage({
- type = "enableui",
- enable = state
- })
- if state == false then ClearTimecycleModifier() end
- end
+ function EnableGui(state)
+ SetNuiFocus(state, state)
+ guiEnabled = state
+ while not ready do
+ Wait(500)
+ end
+ if state then
+ SetTimecycleModifier("hud_def_blur")
+ else
+ ClearTimecycleModifier()
+ end
+ SendNUIMessage({
+ type = "enableui",
+ enable = state
+ })
+ end
- RegisterNetEvent('esx_identity:showRegisterIdentity')
- AddEventHandler('esx_identity:showRegisterIdentity', function()
- TriggerEvent('esx_skin:resetFirstSpawn')
+ RegisterNetEvent('esx_identity:showRegisterIdentity')
+ AddEventHandler('esx_identity:showRegisterIdentity', function()
+ TriggerEvent('esx_skin:resetFirstSpawn')
- if not ESX.PlayerData.dead then
- EnableGui(true)
- SetTimecycleModifier("hud_def_blur")
- SetTimecycleModifierStrength(1)
- end
- end)
+ if not ESX.PlayerData.dead 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)
+ if not ESX.GetConfig().Multichar then
+ TriggerEvent('esx_skin:playerRegistered')
+ end
+ else
+ ESX.ShowNotification(_U('registration_error'), "error", 5000)
+ end
+ end, data)
+ 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)
- if not ESX.GetConfig().Multichar then TriggerEvent('esx_skin:playerRegistered') end
- else
- ESX.ShowNotification(_U('registration_error'), "error",5000)
- end
- end, data)
- end)
+ CreateThread(function()
+ while true do
+ local sleep = 1500
- CreateThread(function()
- while true do
- local sleep = 1500
-
- if guiEnabled then
- sleep = 0
- 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
- end
- Wait(sleep)
- end
- end)
+ if guiEnabled then
+ sleep = 0
+ 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
+ end
+ Wait(sleep)
+ end
+ end)
end
diff --git a/[esx]/esx_identity/config.lua b/[esx]/esx_identity/config.lua
index a46575be..01d1e4c4 100644
--- a/[esx]/esx_identity/config.lua
+++ b/[esx]/esx_identity/config.lua
@@ -9,11 +9,11 @@ Config.UseDeferrals = false -- EXPERIMENTAL Character Registration Method.
-- These values are for the second input validation in server/main.lua
-Config.MaxNameLength = 20
-Config.MinHeight = 120
-Config.MaxHeight = 220
-Config.LowestYear = 1900
-Config.HighestYear = 2021
+Config.MaxNameLength = 20 -- Max Name Length.
+Config.MinHeight = 120 -- 120 cm lowest height
+Config.MaxHeight = 220 -- 220 cm max height.
+Config.LowestYear = 1900 -- 112 years old is the oldest you can be.
+Config.HighestYear = 2003 -- 18 years old is the youngest you can be.
-Config.FullCharDelete = false
-Config.EnableDebugging = false
+Config.FullCharDelete = true -- Delete all reference to character.
+Config.EnableDebugging = false -- prints for debugging :)
diff --git a/[esx]/esx_identity/html/index_heightslider.html b/[esx]/esx_identity/html/index_heightslider.html
deleted file mode 100644
index 65aac7f3..00000000
--- a/[esx]/esx_identity/html/index_heightslider.html
+++ /dev/null
@@ -1,163 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
If the submit button doesn't work, please ensure that you've entered the fields correctly.
-
-
-
-
-
diff --git a/[esx]/esx_identity/html/index_heighttext.html b/[esx]/esx_identity/html/index_heighttext.html
deleted file mode 100644
index 13896e58..00000000
--- a/[esx]/esx_identity/html/index_heighttext.html
+++ /dev/null
@@ -1,150 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
If the submit button doesn't work, please ensure that you've entered the fields correctly.
-
-
-
-
-
diff --git a/[esx]/esx_identity/html/index_options/index_heightslider.html b/[esx]/esx_identity/html/index_options/index_heightslider.html
deleted file mode 100644
index 182d344a..00000000
--- a/[esx]/esx_identity/html/index_options/index_heightslider.html
+++ /dev/null
@@ -1,163 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
If the submit button doesn't work, please ensure that you've entered the fields correctly.
-
-
-
-
-
diff --git a/[esx]/esx_identity/html/index_options/index_heighttext.html b/[esx]/esx_identity/html/index_options/index_heighttext.html
deleted file mode 100644
index 13896e58..00000000
--- a/[esx]/esx_identity/html/index_options/index_heighttext.html
+++ /dev/null
@@ -1,150 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
If the submit button doesn't work, please ensure that you've entered the fields correctly.
-
-
-
-
-
diff --git a/[esx]/esx_identity/html/localization/cs_index(outofdate).html b/[esx]/esx_identity/html/localization/cs_index(outofdate).html
deleted file mode 100644
index 1dd357a9..00000000
--- a/[esx]/esx_identity/html/localization/cs_index(outofdate).html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/[esx]/esx_identity/html/localization/fi_index(outofdate).html b/[esx]/esx_identity/html/localization/fi_index(outofdate).html
deleted file mode 100644
index 87ca250a..00000000
--- a/[esx]/esx_identity/html/localization/fi_index(outofdate).html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/[esx]/esx_identity/html/localization/ko_index(outofdate).html b/[esx]/esx_identity/html/localization/ko_index(outofdate).html
deleted file mode 100644
index c04fe9b7..00000000
--- a/[esx]/esx_identity/html/localization/ko_index(outofdate).html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/[esx]/esx_identity/html/localization/sv_index(outofdate).html b/[esx]/esx_identity/html/localization/sv_index(outofdate).html
deleted file mode 100644
index 7706c17b..00000000
--- a/[esx]/esx_identity/html/localization/sv_index(outofdate).html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/[esx]/esx_identity/server/main.lua b/[esx]/esx_identity/server/main.lua
index 4f28d808..af984dd8 100644
--- a/[esx]/esx_identity/server/main.lua
+++ b/[esx]/esx_identity/server/main.lua
@@ -3,481 +3,515 @@ local alreadyRegistered = {}
local multichar = ESX.GetConfig().Multichar
if Config.UseDeferrals then
- AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
- deferrals.defer()
- local playerId, identifier = source, ESX.GetIdentifier(source)
- Wait(100)
-
- if identifier then
- MySQL.single('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = ?', {identifier},
- function(result)
- if result then
- if result.firstname then
- playerIdentity[identifier] = {
- firstName = result.firstname,
- lastName = result.lastname,
- dateOfBirth = result.dateofbirth,
- sex = result.sex,
- height = result.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
+ AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
+ deferrals.defer()
+ local playerId, identifier = source, ESX.GetIdentifier(source)
+ Wait(100)
- Wait(0)
- alreadyRegistered[xPlayer.identifier] = true
- TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source)
-
- playerIdentity[xPlayer.identifier] = nil
- else
- xPlayer.kick(_('missing_identity'))
- end
- end)
+ if identifier then
+ MySQL.single('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = ?',
+ {identifier}, function(result)
+ if result then
+ if result.firstname then
+ playerIdentity[identifier] = {
+ firstName = result.firstname,
+ lastName = result.lastname,
+ dateOfBirth = result.dateofbirth,
+ sex = result.sex,
+ height = result.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
+
+ Wait(0)
+ 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
- if not multichar then
- AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
- deferrals.defer()
- local playerId, identifier = source, ESX.GetIdentifier(source)
- Wait(40)
+ if not multichar then
+ AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
+ deferrals.defer()
+ local playerId, identifier = source, ESX.GetIdentifier(source)
+ Wait(40)
- if identifier then
- MySQL.single('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = ?', {identifier},
- function(result)
- if result then
- if result.firstname then
- playerIdentity[identifier] = {
- firstName = result.firstname,
- lastName = result.lastname,
- dateOfBirth = result.dateofbirth,
- sex = result.sex,
- height = result.height
- }
+ if identifier then
+ MySQL.single('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = ?',
+ {identifier}, function(result)
+ if result then
+ if result.firstname then
+ playerIdentity[identifier] = {
+ firstName = result.firstname,
+ lastName = result.lastname,
+ dateOfBirth = result.dateofbirth,
+ sex = result.sex,
+ height = result.height
+ }
- alreadyRegistered[identifier] = true
+ 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)
+ 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
- Wait(300)
+ AddEventHandler('onResourceStart', function(resource)
+ if resource == GetCurrentResourceName() then
+ Wait(300)
- while not ESX do
- Wait(0)
- end
+ while not ESX do
+ Wait(0)
+ end
- local xPlayers = ESX.GetExtendedPlayers()
- for _, xPlayer in pairs(xPlayers) do
- if xPlayer then
- checkIdentity(xPlayer)
- end
- end
- end
- end)
+ local xPlayers = ESX.GetExtendedPlayers()
+ for _, xPlayer in pairs(xPlayers) do
+ if xPlayer then
+ checkIdentity(xPlayer)
+ end
+ end
+ end
+ end)
- RegisterNetEvent('esx:playerLoaded')
- AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
- local currentIdentity = playerIdentity[xPlayer.identifier]
- if currentIdentity and alreadyRegistered[xPlayer.identifier] == true then
+ RegisterNetEvent('esx:playerLoaded')
+ AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
+ local currentIdentity = playerIdentity[xPlayer.identifier]
+ if currentIdentity and alreadyRegistered[xPlayer.identifier] == true then
- 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)
- end
+ if currentIdentity.saveToDatabase then
+ saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
+ end
- Wait(0)
- TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source)
+ Wait(0)
+ TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source)
- playerIdentity[xPlayer.identifier] = nil
- else
- TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source)
- end
- end)
- end
+ playerIdentity[xPlayer.identifier] = nil
+ else
+ TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source)
+ end
+ 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
- }
+ ESX.RegisterServerCallback('esx_identity:registerIdentity', function(source, cb, data)
+ local xPlayer = ESX.GetPlayerFromId(source)
- local currentIdentity = playerIdentity[xPlayer.identifier]
+ 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
+ }
- 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)
+ local currentIdentity = playerIdentity[xPlayer.identifier]
- saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
- alreadyRegistered[xPlayer.identifier] = true
-
- playerIdentity[xPlayer.identifier] = nil
- cb(true)
- else
- cb(false)
- end
- else
- cb(false)
- end
- else
- if multichar and checkNameFormat(data.firstname) and checkNameFormat(data.lastname) and checkSexFormat(data.sex) and checkDOBFormat(data.dateofbirth) and checkHeightFormat(data.height) then
- TriggerEvent('esx_identity:completedRegistration', source, data)
- cb(true)
- end
- end
- end)
+ 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)
- function checkIdentity(xPlayer)
- MySQL.single('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = ?', { xPlayer.identifier },
- function(result)
- if result then
- if result.firstname then
- playerIdentity[xPlayer.identifier] = {
- firstName = result.firstname,
- lastName = result.lastname,
- dateOfBirth = result.dateofbirth,
- sex = result.sex,
- height = result.height
- }
+ saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
+ alreadyRegistered[xPlayer.identifier] = true
- alreadyRegistered[xPlayer.identifier] = true
+ playerIdentity[xPlayer.identifier] = nil
+ cb(true)
+ else
+ cb(false)
+ end
+ else
+ cb(false)
+ end
+ else
+ if multichar and checkNameFormat(data.firstname) and checkNameFormat(data.lastname) and
+ checkSexFormat(data.sex) and checkDOBFormat(data.dateofbirth) and checkHeightFormat(data.height) then
+ TriggerEvent('esx_identity:completedRegistration', source, data)
+ cb(true)
+ end
+ end
+ end)
- setIdentity(xPlayer)
- else
- playerIdentity[xPlayer.identifier] = nil
- alreadyRegistered[xPlayer.identifier] = false
- TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source)
- end
- else
- TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source)
- end
- end)
- end
+ function checkIdentity(xPlayer)
+ MySQL.single('SELECT firstname, lastname, dateofbirth, sex, height FROM users WHERE identifier = ?',
+ {xPlayer.identifier}, function(result)
+ if result then
+ if result.firstname then
+ playerIdentity[xPlayer.identifier] = {
+ firstName = result.firstname,
+ lastName = result.lastname,
+ dateOfBirth = result.dateofbirth,
+ sex = result.sex,
+ height = result.height
+ }
- function setIdentity(xPlayer)
- if alreadyRegistered[xPlayer.identifier] then
- local currentIdentity = playerIdentity[xPlayer.identifier]
+ alreadyRegistered[xPlayer.identifier] = true
- 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)
+ setIdentity(xPlayer)
+ else
+ playerIdentity[xPlayer.identifier] = nil
+ alreadyRegistered[xPlayer.identifier] = false
+ TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source)
+ end
+ else
+ TriggerClientEvent('esx_identity:showRegisterIdentity', xPlayer.source)
+ end
+ end)
+ end
- if currentIdentity.saveToDatabase then
- saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
- end
+ function setIdentity(xPlayer)
+ if alreadyRegistered[xPlayer.identifier] then
+ local currentIdentity = playerIdentity[xPlayer.identifier]
- playerIdentity[xPlayer.identifier] = nil
- end
- end
+ 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
+
+ playerIdentity[xPlayer.identifier] = nil
+ 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('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
- xPlayer.kick(_U('deleted_identity'))
- Wait(1500)
- deleteIdentity(xPlayer)
- xPlayer.showNotification(_U('deleted_character'))
- playerIdentity[xPlayer.identifier] = nil
- alreadyRegistered[xPlayer.identifier] = false
- 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')})
+ ESX.RegisterCommand('chardel', 'user', function(xPlayer, args, showError)
+ if xPlayer and xPlayer.getName() then
+ if Config.UseDeferrals then
+ xPlayer.kick(_U('deleted_identity'))
+ Wait(1500)
+ deleteIdentity(xPlayer)
+ xPlayer.showNotification(_U('deleted_character'))
+ playerIdentity[xPlayer.identifier] = nil
+ alreadyRegistered[xPlayer.identifier] = false
+ 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('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('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('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('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('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')})
+ 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)
+ 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
+ deleteIdentityFromDatabase(xPlayer)
+ end
end
function saveIdentityToDatabase(identifier, identity)
- MySQL.update.await('UPDATE users SET firstname = ?, lastname = ?, dateofbirth = ?, sex = ?, height = ? WHERE identifier = ?', {identity.firstName, identity.lastName, identity.dateOfBirth, identity.sex, identity.height, identifier})
+ MySQL.update.await(
+ 'UPDATE users SET firstname = ?, lastname = ?, dateofbirth = ?, sex = ?, height = ? WHERE identifier = ?',
+ {identity.firstName, identity.lastName, identity.dateOfBirth, identity.sex, identity.height, identifier})
end
function deleteIdentityFromDatabase(xPlayer)
- MySQL.query.await('UPDATE users SET firstname = ?, lastname = ?, dateofbirth = ?, sex = ?, height = ?, skin = ? WHERE identifier = ?', {nil, nil, nil, nil, nil, nil, xPlayer.identifier})
+ MySQL.query.await(
+ 'UPDATE users SET firstname = ?, lastname = ?, dateofbirth = ?, sex = ?, height = ?, skin = ? WHERE identifier = ?',
+ {nil, nil, nil, nil, nil, nil, xPlayer.identifier})
- if Config.FullCharDelete then
- MySQL.update.await('UPDATE addon_account_data SET money = 0 WHERE account_name IN (?) AND owner = ?', {{'bank_savings', 'caution'}, xPlayer.identifier})
+ if Config.FullCharDelete then
+ MySQL.update.await('UPDATE addon_account_data SET money = 0 WHERE account_name IN (?) AND owner = ?',
+ {{'bank_savings', 'caution'}, xPlayer.identifier})
- MySQL.prepare.await('UPDATE datastore_data SET data = ? WHERE name IN (?) AND owner = ?', {'\'{}\'', {'user_ears', 'user_glasses', 'user_helmet', 'user_mask'}, xPlayer.identifier})
- end
+ MySQL.prepare.await('UPDATE datastore_data SET data = ? WHERE name IN (?) AND owner = ?',
+ {'\'{}\'', {'user_ears', 'user_glasses', 'user_helmet', 'user_mask'}, xPlayer.identifier})
+ end
end
function checkNameFormat(name)
- if not checkAlphanumeric(name) then
- if not checkForNumbers(name) then
- local stringLength = string.len(name)
- if stringLength > 0 and stringLength < Config.MaxNameLength then
- return true
- else
- return false
- end
- else
- return false
- end
- else
- return false
- end
+ if not checkAlphanumeric(name) then
+ if not checkForNumbers(name) then
+ local stringLength = string.len(name)
+ if stringLength > 0 and stringLength < Config.MaxNameLength then
+ return true
+ else
+ return false
+ end
+ else
+ return false
+ end
+ else
+ return false
+ end
end
function checkDOBFormat(dob)
- local date = tostring(dob)
- if checkDate(date) then
- return true
- else
- return false
- end
+ local date = tostring(dob)
+ if checkDate(date) then
+ return true
+ else
+ return false
+ end
end
function checkSexFormat(sex)
- if sex == "m" or sex == "M" or sex == "f" or sex == "F" then
- return true
- else
- return false
- end
+ if sex == "m" or sex == "M" or sex == "f" or sex == "F" then
+ return true
+ else
+ return false
+ end
end
function checkHeightFormat(height)
- local numHeight = tonumber(height)
- if numHeight < Config.MinHeight and numHeight > Config.MaxHeight then
- return false
- else
- return true
- end
+ local numHeight = tonumber(height)
+ if numHeight < Config.MinHeight and numHeight > Config.MaxHeight then
+ return false
+ else
+ return true
+ end
end
function formatName(name)
- local loweredName = convertToLowerCase(name)
- local formattedName = convertFirstLetterToUpper(loweredName)
- return formattedName
+ local loweredName = convertToLowerCase(name)
+ local formattedName = convertFirstLetterToUpper(loweredName)
+ return formattedName
end
function convertToLowerCase(str)
- return string.lower(str)
+ return string.lower(str)
end
function convertFirstLetterToUpper(str)
- return str:gsub("^%l", string.upper)
+ return str:gsub("^%l", string.upper)
end
function checkAlphanumeric(str)
- return (string.match(str, "%W"))
+ return (string.match(str, "%W"))
end
function checkForNumbers(str)
- return (string.match(str,"%d"))
+ return (string.match(str, "%d"))
end
function checkDate(str)
- if string.match(str, '(%d%d)/(%d%d)/(%d%d%d%d)') ~= nil then
- local d, m, 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
- if d > 30 then
- return false
- else
- return true
- end
- elseif m == 2 then
- if y%400 == 0 or (y%100 ~= 0 and y%4 == 0) then
- if d > 29 then
- return false
- else
- return true
- end
- else
- if d > 28 then
- return false
- else
- return true
- end
- end
- else
- if d > 31 then
- return false
- else
- return true
- end
- end
- else
- return false
- end
+ if string.match(str, '(%d%d)/(%d%d)/(%d%d%d%d)') ~= nil then
+ local d, m, 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
+ if d > 30 then
+ return false
+ else
+ return true
+ end
+ elseif m == 2 then
+ if y % 400 == 0 or (y % 100 ~= 0 and y % 4 == 0) then
+ if d > 29 then
+ return false
+ else
+ return true
+ end
+ else
+ if d > 28 then
+ return false
+ else
+ return true
+ end
+ end
+ else
+ if d > 31 then
+ return false
+ else
+ return true
+ end
+ end
+ else
+ return false
+ end
end