Raised This Month: $ Target: $400
 0% 

Multi-dimensional Arrays format


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
da_ciouzan_oan
Junior Member
Join Date: Jun 2010
Old 11-05-2011 , 05:23   Multi-dimensional Arrays format
Reply With Quote #1

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"...
da_ciouzan_oan is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-05-2011 , 05:24   Re: Multi-dimensional Arrays format
Reply With Quote #2

I don't think (actually i'm 100% sure) you need such an array for what you do...
Anyway, try charsmax(g_playerReady[][])
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-05-2011 at 05:29.
ConnorMcLeod is offline
da_ciouzan_oan
Junior Member
Join Date: Jun 2010
Old 11-05-2011 , 05:53   Re: Multi-dimensional Arrays format
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
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.
da_ciouzan_oan is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-05-2011 , 15:39   Re: Multi-dimensional Arrays format
Reply With Quote #4

I agree with Connor, there is a better way.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-05-2011 , 15:57   Re: Multi-dimensional Arrays format
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
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.
__________________
Bugsy is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-05-2011 , 16:54   Re: Multi-dimensional Arrays format
Reply With Quote #6

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.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
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 14:22.


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