AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Multi-dimensional Arrays format (https://forums.alliedmods.net/showthread.php?t=171367)

da_ciouzan_oan 11-05-2011 05:23

Multi-dimensional Arrays format
 
I have this declared as global var:
Code:
g_playerReady[33][2][32]

And I'm trying to format.. but smthing it's wrong. What am I doing wrong?..
Code:
get_user_name(id, plr_name, charsmax(plr_name)) formatex(g_playerReady[id][0], charsmax(g_playerReady[]), "Unready") formatex(g_playerReady[id][1], charsmax(g_playerReady[]), plr_name)

I used this to display the string on the screen so I can see where the problem is..
Code:
if(equali(command, "check")) {     client_print(id, print_chat, "%s a", g_playerReady[id][0])     client_print(id, print_chat, "%s a", g_playerReady[id][1]) }
In chat shows " a"...

ConnorMcLeod 11-05-2011 05:24

Re: Multi-dimensional Arrays format
 
I don't think (actually i'm 100% sure) you need such an array for what you do...
Anyway, try charsmax(g_playerReady[][])

da_ciouzan_oan 11-05-2011 05:53

Re: Multi-dimensional Arrays format
 
Quote:

Originally Posted by ConnorMcLeod (Post 1590405)
I don't think (actually i'm 100% sure) you need such an array for what you do...
Anyway, try charsmax(g_playerReady[][])

Well.. instead of making 2 variables, I choose making 1 cause it's easier to work with xD.

Anyway.. it work'd, thanks.

fysiks 11-05-2011 15:39

Re: Multi-dimensional Arrays format
 
I agree with Connor, there is a better way.

Bugsy 11-05-2011 15:57

Re: Multi-dimensional Arrays format
 
Quote:

Originally Posted by fysiks (Post 1590777)
I agree with Connor, there is a better way.

+1

Tell us what exactly you're trying to accomplish instead of how to do what you think is best.

Emp` 11-05-2011 16:54

Re: Multi-dimensional Arrays format
 
Btw, reason for why it was only displaying two characters was because your charsmax(g_playerReady[]) is reading the second size of the array g_playerReady[33][2][32] (ie. 2)

And as for the others' comments about doing it "better", you most likely don't need even need this array. You should only have one array for the players' ready state. You can then use "Unready" and "Ready" instead based on their ready state.

You also don't really need to store players' names in the array, and should instead just directly get their name in the function.

Those are based on assumptions, but obviously there would be rare cases where you are doing it correctly.


All times are GMT -4. The time now is 14:22.

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