#Cid change to numbers
1 messages · Page 1 of 1 (latest)
I don't think this does what you think it's doing
This should in theory work, but you literally already have an id in the players table, that auto increments, that you could use. It does the same thing, without having to do it manually
Which you could set the default value of to 1001, if you really want that
And replace the citizenid with entirely, if you want to
It is a string for a reason using integers as IDs in this way is not recommended, if you have a very large playerbase you could run into issues if this is a signed integer (It would take a LOT of players but still a concern to be mindful of)
Also when displaying a citizen ID in NUI you could run into issues as people are expecting that data type to be a string "CV56CV" in the database
To be fair though, the integer limit is probably not to worry about. FiveM servers typically dont have more than a couple thousands of characters, nevertheless millions... billions
I'd imagine strings/default citizenid's are nicer to type out though, as you come to a point where the number is just too long
Yeah you're right there just thought i'd mention
The main issue would be with NUI if someone uses a string method on the citizen id as that's what they expect it to be but you are passing an integer then it would break whatever script is doing that
function QBCore.Player.CreateCitizenId()
local CitizenId = tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomInt(2))
local result = MySQL.prepare.await('SELECT EXISTS(SELECT 1 FROM players WHERE citizenid = ?) AS uniqueCheck', { CitizenId })
if result == 0 then return CitizenId end
return QBCore.Player.CreateCitizenId()
end
try this if u want 4 numbers