Raised This Month: $ Target: $400
 0% 

Number to String


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shine771
Senior Member
Join Date: Jun 2007
Old 01-05-2008 , 10:23   Number to String
Reply With Quote #1

A month ago i quit scripting. But now i am back! XD. Still learning... Now i am making a cool plugin. Just need some help. I know this is kinda a newbie question. But i can't figure out this:

ok i made:
PHP Code:
new number1
new number2
new number3
new number4
new number5
new my_new_string[32
on round start:

PHP Code:
number1 random_num(1,9)
number2 random_num(1,9)
number3 random_num(1,9)
number4 random_num(1,9)
number5 random_num(1,9
And now i can't make those numbers all together in a string. Like:
if:
number1 = 1
number2 = 2
number3 = 3
...

so the string would to be: 12345
I hope you got the idea XD

I tried converting/making/transforming those numbers to string and then tried putting into the my_new_string... and other methods... nothing...

Maybe someone could make a code? I was searching the forums for tutorials, examples, other plugins... But i couldn't find anything. I know i am a bad searcher... XD. I'm stuck with this for 1h now...It shouldn't be a long script, so maybe someone could help me out?

Thanks.
shine771 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-05-2008 , 10:31   Re: Number to String
Reply With Quote #2

Declaration:
Code:
    new number[5];     new my_new_string[32];

Fill array with random values:
Code:
    for( new i; i < 5; i++ )         number[i] = random_num( 1, 9 );

Make the numbers together:
Code:
    new iLen;     for( new i; i < 5; i++ )         iLen += formatex( my_new_string[ iLen ], 31 - iLen, "%d", number[i] );             log_amx( "string = '%s'", my_new_string );
__________________

Last edited by Arkshine; 01-05-2008 at 10:37.
Arkshine is offline
shine771
Senior Member
Join Date: Jun 2007
Old 01-05-2008 , 10:54   Re: Number to String
Reply With Quote #3

Thanks.
But i will need those 5 numbers later as variables. I'm really a newbie in Strings - never have really worked with them(just a bit).
How to i get those 5 numbers out of Number - and move them to other variables?
like - number[5] - 12345
number1 - 1
number2 - 2
...
Thanks.
Sorry for my english. I'm not really good at it =/

Last edited by shine771; 01-05-2008 at 10:56.
shine771 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-05-2008 , 10:59   Re: Number to String
Reply With Quote #4

I'm not sure to understand very well... Sorry.

Please rephrase.
__________________
Arkshine is offline
shine771
Senior Member
Join Date: Jun 2007
Old 01-05-2008 , 11:03   Re: Number to String
Reply With Quote #5

Ok, i will need number1, number2, number3, number4, number5 later.
So i don't need that number[5] - i need to get those 5 numbers who are in number[5] to number1, number2...

so:
if number[5] = 12345
then:
number1 = 1
number2 = 2
number3 = 3
number4 = 4
number5 = 5
shine771 is offline
Old 01-05-2008, 11:16
Arkshine
This message has been deleted by Arkshine. Reason: nvm
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 01-05-2008 , 11:30   Re: Number to String
Reply With Quote #6

If you do this:
Quote:
Originally Posted by arkshine View Post
Declaration:
PHP Code:
    new number[5];
    new 
my_new_string[32]; 
Fill array with random values:
PHP Code:
    for( new i5i++ )
        
number[i] = random_num1); 
then number[] will be an array of numbers. Every cell is like separate variable, so using number[0], number[1], number[2], number[3], number[4] will work exactly like number1, number2, number3, number4, number5.
__________________
Impossible is Nothing
Sylwester 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 11:09.


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