Change Default Number

This step varies depending on your framework, be careful and read this completely so as not to break any internal files, since esx and qbcore are completely opposite.

We can change the default phone number, whether its prefix or number of numbers. But we only recommend changing the prefix and not the number of numbers because it could cause problems if you use a very small number of numbers or a very long one.


Change the default phone number

For this method, qbcore and esx are very opposite, display the option that suits your server and edit accordingly.

Change default phone number in esx

In esx the step is extremely simple, we will go to qs-base and in config.lua we will have a configuration to change the prefix and the number of numbers that will be given to the player.

Config.NumberPrefix = '553' -- Prefix of the number
Config.NumberDigits = 6 -- Amount of digits after the prefix
Change default phone number in qbcore

The step to change the number or prefix in qbcore is somewhat more advanced, we must access qb-core/server/player.lua and look for the CreatePhoneNumber() function.

function QBCore.Functions.CreatePhoneNumber()
    local UniqueFound = false
    local PhoneNumber = nil
    while not UniqueFound do
        PhoneNumber = 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
            UniqueFound = true
        end
    end
    return PhoneNumber
end

In this we can change the telephone prefix in the first math.random giving it a fixed value or a dynamic one using math.random, the second value is the number of digits. We can make a custom number using this as an example.

PhoneNumber = '376' .. math.random(100000, 999999)

With this example, we have created a number with a prefix 376 + 6 random digits.

Last updated