[HELP] How to make random passwords
#1

Hi.. I was wondering how to make random passwords.. For example.. Every time you go to rob bank.. You have to guess password among 100 codes.. If someone knows and tell me I will be grateful.. Thank you in advance!
Reply
#2

the password is a string or an integer?
If it's a string then u have to make a list with the Alphabet and using "random(sizeof(urlist))" to select a random letter from that list
if it's an integer then use "random(10)" to generate a random number (0 to 9). if the pass lenth is 5 so use it 5 times and u got it)

if u already have a list of passwords, then the same way as a string, a list that contain ur passwords and a random num.
Reply
#3

Quote:
Originally Posted by mongi
Посмотреть сообщение
the password is a string or an integer?
If it's a string then u have to make a list with the Alphabet and using "random(sizeof(urlist))" to select a random letter from that list
if it's an integer then use "random(10)" to generate a random number (0 to 9). if the pass lenth is 5 so use it 5 times and u got it)

if u already have a list of passwords, then the same way as a string, a list that contain ur passwords and a random num.
Like what mongi said
Reply
#4

Okay thanks.. I can understand some parts of your reply.. I'll be more specific.. I want to use this at bank robbery.. So when someone goes to bank and tries to rob it.. He will get messages like SendClientMessage(playerid, COLOR, "1234 5678 9101); and number of this messages will be more than 10.. So if he misses this 5678 he could not rob bank

And he needs to type in 5678 to successfully rob bank or open some doors.. I know how to create opening doors.. But i dont know how to make 5678 as a password
Reply
#5

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

Use that function in order to get a pseudo-random number and work your way around from that.
Reply
#6

Just generate a random number, save it to a variable and compare it when the user guesses the number.
Reply
#7

Can anyone show me any code? Pleasee
Reply
#8

PHP код:
new password random(9999); 
Then use the password variable to compare it with the user's input text.
Reply
#9

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
PHP код:
new password random(9999); 
Then use the password variable to compare it with the user's input text.
Okay thank you very much! Now can you just give me information how to make random client messages like SendClientMessage(playerid, COLOR, "1234 5678 9101"); and that random password is 5678.. So that in message 5678 is red colour
Reply
#10

Код:
new a = random (9);
new b = random (9);
new c = random (9);
new d = random (9);
new e = random (9);
// use string 
new result = ""+a+b+c+d+e;

// result can show 00130
// if use random(9999)
// result 1 to 9999
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)