AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Generate Random String (https://forums.alliedmods.net/showthread.php?t=147762)

P4rD0nM3 01-13-2011 16:06

Generate Random String
 
Hello, how do you generate a random string with 6 length consisting of numbers and letters?

client_print(client, print_center, "9f343948j");

Kinda like that. Thanks.

Exolent[jNr] 01-13-2011 16:47

Re: Generate Random String
 
Easy.

Code:
GenerateString(const choices[], const num_choices, output[], const len) {     for(new i = 0; i < len; i++)     {         output[i] = choices[random(num_choices)];     }         return len; }

Code:
new const choices[] = "abcdefghijklmnopqrstuvwxyz0123456789"; new string[7]; GenerateString(choices, charsmax(choices), string, charsmax(string)); // string is a random string from given choices


All times are GMT -4. The time now is 02:05.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.