AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Arrays not working for some odd reason (https://forums.alliedmods.net/showthread.php?t=25814)

Des12 03-20-2006 20:23

Arrays not working for some odd reason
 
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?

VEN 03-20-2006 20:48

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'.

Des12 03-20-2006 22:31

Thanks. BTW, any other way to do it?


All times are GMT -4. The time now is 16:37.

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