Cellphone 4 Digit Generator
#1

Hi, its me again! I have some doubt about how to generate a 4 digit number without repeating, is there any way you guys can help me on that... ?

I dont need something very elaborate, but hey, Any feedback is good feed back!

Best Regards Sagoza
Reply
#2

Use MySQL, create a table just for the phones number and their respective owners.

Use the phone number as a primary key and use auto increment starting from 1000.

And create the player phone by just inserting a new how with his name or ID on the table.

You can now get the created phone number using the owner name or id (depending on how you stored it on table)

Good luck
Reply
#3

Quote:
Originally Posted by arakuta
Посмотреть сообщение
Use MySQL, create a table just for the phones number and their respective owners.

Use the phone number as a primary key and use auto increment starting from 1000.

And create the player phone by just inserting a new how with his name or ID on the table.

You can now get the created phone number using the owner name or id (depending on how you stored it on table)

Good luck
Never thought of doing it this way, it's a really good idea. I was just going to say make an array with a bunch of numbers then use random to combine x amount of them.
Reply
#4

Quote:
Originally Posted by (*|Flake|*)
Посмотреть сообщение
Never thought of doing it this way, it's a really good idea. I was just going to say make an array with a bunch of numbers then use random to combine x amount of them.
MySQL is a powerful database system

Or you can just use a global variable for the last number created, and store it in some file.

Just read it properly when the server loads, then just create number based on var + 1, of course not forgeting to add 1 on every number creation.
Reply
#5

Quote:

I dont need something very elaborate

https://sampwiki.blast.hk/wiki/Random
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)