Raised This Month: $ Target: $400
 0% 

Random stringt or number


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Artifact
Veteran Member
Join Date: Jul 2010
Old 11-23-2012 , 14:02   Random stringt or number
Reply With Quote #1

How to make when player type 'something' in console to plugin give to him random stringt eg:

alsjdj213idsa0213

or just number

312308921
__________________
Artifact is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 11-23-2012 , 16:52   Re: Random stringt or number
Reply With Quote #2

random number?

PHP Code:
new num random_num10000009000000 ); 
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 11-23-2012 , 16:57   Re: Random stringt or number
Reply With Quote #3

Code:
new szRandom[16] for (new i = 0; i <= charsmax(szRandom); i++) {     szRandom[i] = random_num(0,1) ? random_num(48,57) : random_num(97,122) }

Last edited by jimaway; 11-23-2012 at 16:57.
jimaway is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 11-23-2012 , 17:23   Re: Random stringt or number
Reply With Quote #4

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
random number?

PHP Code:
new num random_num10000009000000 ); 
Oke, but I dont know what is 'a' and 'b', thans anyway...

But how I can make random stringt
__________________
Artifact is offline
izzle
Senior Member
Join Date: Aug 2009
Old 11-23-2012 , 18:00   Re: Random stringt or number
Reply With Quote #5

I am not sure about pawn, but in most languages single characters are assigned ASCII values. By generating a random amount of random numbers within a range you could generate a random string.
__________________
izzle is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 11-23-2012 , 18:15   Re: Random stringt or number
Reply With Quote #6

Just change the string lengths. #1 is assuming you want the number in a string, but you don't have to use that, random(cellmax) is all you need). You could use a randomly generated string length, but I chose not to. You're better off generating some random range from like 16-64.

For number:
PHP Code:
new szRandomNumber[12];
num_to_str(random(cellmax), szRandomNumbersizeof szRandomNumber-1); 
For string:

PHP Code:
new szRandomString[32];
for (new 
0sizeof szRandomStringi++) {
    switch (
random(3)) {
        case 
0szRandomString[i] = random_num('a''z');
        case 
1szRandomString[i] = random_num('A''Z');
        case 
2szRandomString[i] = random_num('0''9');
    }

__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]

Last edited by Tirant; 11-23-2012 at 18:18.
Tirant is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 11-23-2012 , 18:57   Re: Random stringt or number
Reply With Quote #7

PHP Code:
random_num('a''z'
wtf bro? O.o
__________________

Last edited by Artifact; 11-23-2012 at 18:57.
Artifact is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 11-23-2012 , 19:04   Re: Random stringt or number
Reply With Quote #8

A char is a number as well, it works just fine
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 11-24-2012 , 05:24   Re: Random stringt or number
Reply With Quote #9

Oke, thanks, I will try
__________________
Artifact is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:07.


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