Raised This Month: $ Target: $400
 0% 

Arrays not working for some odd reason


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Des12
Senior Member
Join Date: Jan 2005
Old 03-20-2006 , 20:23   Arrays not working for some odd reason
Reply With Quote #1

Here is my code:

Code:
//Size is a little bigger than data to be stored, 7>5 new arrayTest[33][7]; // . . . public testMultiple(id) {    new var4 = random_num(1,9);    arrayTest[id][0] = var4;    arrayTest[id][1] = random_num(1,9);    arrayTest[id][2] = '.';    arrayTest[id][3] = random_num(1,9);    arrayTest[id][4] = random_num(1,9);    client_print(id,print_chat,"Array: %s",arrayTest[id]);      return PLUGIN_HANDLED; }

It SHOULD print out: Array: xxx.xx
But it prints out: Array: .

I included new var4 = random_num(1,9); incase the problem was with random numbers...seems not to be the case.

Any ideas?
__________________
-Dest Romano

www.JustRP.com
A TSRP Server

Quote:
Originally Posted by Brad
Don't you go be bringing reality into this.
Des12 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-20-2006 , 20:48  
Reply With Quote #2

You printing a string.

But as you said
Quote:
It SHOULD print out: Array: xxx.xx
I.e. you want to print numbers and char, so do that:
Code:
client_print(id,print_chat,"Array: %d%d%c%d%d", arrayTest[0],arrayTest[1],arrayTest[2],arrayTest[3],arrayTest[4]);

Your mistake is that you thought that number == 'number'
But in fact, for example 7 != '7'.
VEN is offline
Des12
Senior Member
Join Date: Jan 2005
Old 03-20-2006 , 22:31  
Reply With Quote #3

Thanks. BTW, any other way to do it?
__________________
-Dest Romano

www.JustRP.com
A TSRP Server

Quote:
Originally Posted by Brad
Don't you go be bringing reality into this.
Des12 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 16:37.


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