Generating random numbers - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Generating random numbers (
/showthread.php?tid=637329)
Generating random numbers -
aoky - 12.07.2017
I'm trying to make it so when a player types a command it result in a random number, and this number cannot be used again. I'm making a column in database called UCPID and it will have the random number generated in this column. If you wish to show code examples please do, or even an explanation.
Re: Generating random numbers -
Paulice - 12.07.2017
Here's one:
PHP код:
new ucp_id[24], next_sql_id = 1 /* next_sql_id = SQL ID of the next INSERT statement */;
format(ucp_id, sizeof(ucp_id), "%d%d", gettime(), next_sql_id);
Re: Generating random numbers -
GoldenLion - 13.07.2017
Or you could set the primary key to UCPID and add auto increment to it.
Re: Generating random numbers -
Paulice - 13.07.2017
Quote:
Originally Posted by GoldenLion
Or you could set the primary key to UCPID and add auto increment to it.
|
The reason I suggested the use of timestamp was to simulate "random numbers".