Posts: 35
Threads: 13
Joined: Jan 2016
Reputation:
0
Hi!
I want to make a License Plate system witch uses MySQL and when the car is created it generates random 3 character and 3 number (like ABC-123) when the car is made. How can I generate random 3 character and 3 number and how can I save it?
Posts: 6,242
Threads: 8
Joined: Jun 2008
random is the random function.
random(999) will return 0-999, random(100-999) will return 100-999 to keep the 3 numbers.
You'll want to be reading up on how to script, and how to use the MySQL plugin, with a database, to save these.
You will probably have a tricky situation trying to get 3 letters.
You could use random(26) and use that 3 times to get 3 different letters from those random numbers.
When merging the plate, bare in mind that you need them to be a string, so you'll likely use strcat to first make the 3 letter prefix, then have the 3 numbers after.
Posts: 6,242
Threads: 8
Joined: Jun 2008
^^ That is a better method of making the plate (It also makes the whole thing more random by doing each number rather than the number as one), but also, when you do set those plates, you HAVE to set the vehicle to respawn due to it not showing unless you do.
SetVehicleToRespawn after you SetVehicleNumberPlate
Posts: 6,242
Threads: 8
Joined: Jun 2008
Quote:
Originally Posted by Freaksken
False.
random(999) will return numbers from 0 to 998.
If you need values from 0 to 999 you need random(1000).
|
Regardless, I wasn't here to paste out code for people to copy. I was here saying about what functions to use, and what to look at...