mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:08:57 +00:00
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:
+2
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user