Add SSN Generation

Last updated
Go to vms_documentsv2/server/modules/ssn.lua and in the first line you have to customize your birth date format stored on your server.
By default, the date of birth in ESX is stored in the column dateofbirth.

If you are NOT using any multicharacter system, skip this step, go to identity.
Go to your es_extended/server/main.lua and replace the highlighted code in the createESXPlayer function.
Find the loadESXPlayer function and only the highlighted code
Part of the code from the loadESXPlayer function has been removed to focus on the required changes.
You need to enter only xPlayer.set("ssn", result.ssn) in the highlighted area.
The line: xPlayer.set("ssn", result.ssn)
MUST be placed:
inside loadESXPlayer()
after the Identity block
before TriggerEvent("esx:playerLoaded")
Go to your es_extended/server/functions.lua and replace the entire Core.generateSSN function.
If you are using any multicharacter go back to point two.
If you don't want to use the whole esx_identity, read carefully the README.md from the above github, there you will find exactly marked changes.
Last updated
local function createESXPlayer(identifier, playerId, data)
local accounts = {}
for account, money in pairs(Config.StartingAccountMoney) do
accounts[account] = money
end
local defaultGroup = "user"
if Core.IsPlayerAdmin(playerId) then
print(("[^2INFO^0] Player ^5%s^0 Has been granted admin permissions via ^5Ace Perms^7."):format(playerId))
defaultGroup = "admin"
end
local parameters = Config.Multichar and
{ json.encode(accounts), identifier, Core.generateSSN(data.dateofbirth, data.sex), defaultGroup, data.firstname, data.lastname, data.dateofbirth, data.sex, data.height }
or { json.encode(accounts), identifier, Core.generateSSN(), defaultGroup }
if Config.StartingInventoryItems then
table.insert(parameters, json.encode(Config.StartingInventoryItems))
end
MySQL.prepare(newPlayer, parameters, function()
loadESXPlayer(identifier, playerId, true)
end)
endfunction loadESXPlayer(identifier, playerId, isNew)
...
-- Identity
if result.firstname and result.firstname ~= "" then
...
end
xPlayer.set("ssn", result.ssn)
TriggerEvent("esx:playerLoaded", playerId, xPlayer, isNew)
....
end---@param dob string?
---@param sex number?
---@return number
function Core.generateSSN(dob, sex)
if dob == nil or sex == nil then
return nil
end
if GetResourceState('vms_cityhall') == 'started' then
return exports['vms_cityhall']:GenerateSSN(dob, sex)
elseif GetResourceState('vms_documentsv2') == 'started' then
return exports['vms_documentsv2']:GenerateSSN(dob, sex)
end
end