fix: Phone number generation

Due to merging the 2 sets of random generated numbers it makes the variable PhoneNumber a string when it should be a number value. I noticed this bug when the framework function QBCore.Functions.GetPlayerByPhone was not working as intended.
This commit is contained in:
uShifty
2022-06-06 20:05:24 -07:00
committed by GitHub
parent c1bc866c45
commit 88d31270bf
+2 -2
View File
@@ -56,7 +56,7 @@ function QBCore.Player.CheckPlayerData(source, PlayerData)
PlayerData.charinfo.gender = PlayerData.charinfo.gender or 0
PlayerData.charinfo.backstory = PlayerData.charinfo.backstory or 'placeholder backstory'
PlayerData.charinfo.nationality = PlayerData.charinfo.nationality or 'USA'
PlayerData.charinfo.phone = PlayerData.charinfo.phone or QBCore.Functions.CreatePhoneNumber()
PlayerData.charinfo.phone = tonumber(PlayerData.charinfo.phone) or QBCore.Functions.CreatePhoneNumber()
PlayerData.charinfo.account = PlayerData.charinfo.account or QBCore.Functions.CreateAccountNumber()
-- Metadata
PlayerData.metadata = PlayerData.metadata or {}
@@ -634,7 +634,7 @@ function QBCore.Functions.CreatePhoneNumber()
local UniqueFound = false
local PhoneNumber = nil
while not UniqueFound do
PhoneNumber = math.random(100,999) .. math.random(1000000,9999999)
PhoneNumber = tonumber(math.random(100,999) .. math.random(1000000,9999999))
local query = '%' .. PhoneNumber .. '%'
local result = MySQL.prepare.await('SELECT COUNT(*) as count FROM players WHERE charinfo LIKE ?', { query })
if result == 0 then