#Cid change to numbers

1 messages · Page 1 of 1 (latest)

stark temple
#
function QBCore.Player.CreateCitizenId()
    local result = MySQL.query.await("SELECT citizenid FROM players ORDER BY citizenid DESC LIMIT 1")
    if not result[1] then
        return 1001
    end
    
    return result[1].citizenid + 1
end ```
short citrus
#

I don't think this does what you think it's doing

stark temple
#

it works

#

changes it from CV56CV EXAMPLE

#

to just 1001, 1002 etc

lethal estuary
#

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

full saddle
#

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

lethal estuary
#

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

full saddle
#

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

obsidian dust
#

try this if u want 4 numbers