AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Array Problem (https://forums.alliedmods.net/showthread.php?t=183318)

ProIcons 04-20-2012 13:32

Array Problem
 
I created an array

PHP Code:

enum Substatus Status,Time };
new 
g_activesub[32][Substatus]; 

And i want to set the status of a sub of a user example.

g_activesub[ProIcons][Status]="Searching..." ...

i tried to achieve that with

g_activesub[ret_getuser_id(id)][Status]=status;
g_activesub[user][Status]=status;
format(g_activesub[ret_getuser_id(id)][Status],31,"%s",status);
copy(g_activesub[ret_getuser_id(id)][Status],31,status);

but anyway i allready knew that they wouldn't gonna work. but i just test them, any idea? how can i do it...

claudiuhks 04-20-2012 13:38

Re: Array Problem
 
PHP Code:

enum /* Steps */
{
  
STEP_READING 1STEP_WATCHINGSTEPS_COUNT
};

new 
g_iStepsSTEPS_COUNT ];

enum /* Statuses */
{
  
STATUS_IDLE 1STATUS_ACTIVESTATUSES_COUNT
};

new 
g_sPlayersStatuses33 /* MAX_PLAYERS */ ][ STATUSES_COUNT ][ 32 /* Maximum characters in string */ ];

/* Now you'll be able to do this: */

formatexg_sPlayersStatusesiPlayer ][ STATUS_IDLE ], 31"%s""Staying inactived" );
formatexg_sPlayersStatusesiPlayer ][ STATUS_ACTIVE ], 31"%s""Doing something" ); 

And about this, please check function formatex to see the diference between format and formatex.

Quote:

Originally Posted by ProIcons (Post 1693054)
format(g_activesub[ret_getuser_id(id)][Status],31,"%s",status);


ProIcons 04-20-2012 13:42

Re: Array Problem
 
Not sure if i can follow you... what exactly different did you make?

ProIcons 04-20-2012 13:48

Re: Array Problem
 
PHP Code:

enum Substatus 
    
Status,Time 
};
new 
g_activesub[32][Substatus];

else if (
is(text,".sub")) {
    if (
g_administrate == 0) {
        new 
user[32]
        
getuser_id(user,id);
        if (!
istok(g_subqueue,user,32)) {
            
format(g_subqueue,strlen(g_subqueue),"%s %s",g_subqueue,user);
            
msg("[Sub][%s] You are now on the queue list of Subs.",user);
            
msg("[Sub][%s] Queue Position (%d/%d).",user,findtok(g_subqueue,user,32),numtok(g_subqueue,32));
            if (
findtok(g_subqueue,user,32) == 1) {
                new 
status[32];
                
format(status,31,"Searching...");
                
formatex(g_activesub[user][Status],31,"%s",status);
                
//sub
            
}
        }
        else { 
msg("[Sub][%s] You are allready on the Sub Queue. Please Wait...",user); }
    }


I just asked how can i set that array...

Edit: the edit shit make me like an idiot, like i'm writing by my self. stop doing that. Thanks.

claudiuhks 04-20-2012 13:51

Re: Array Problem
 
You are unable to format a variable with one cell. You need at least, a variable with two cells.

PHP Code:

new g_iDecimal;
formatg_iDecimal31"%s""?????????????" ); // NONONONO

new g_cChar32 ];
formatg_cChar31"%s""!!!!!!!!!!!!!!!!" ); 

PHP Code:

new g_iDecimal32 ];
formatg_iDecimal15 ], 31"%s""?????????????" ); // NONONONO

new g_cChar32 ][ 32 ];
formatg_cChar15 ], 31"%s""!!!!!!!!!!!!!!!!" ); 


ProIcons 04-20-2012 13:54

Re: Array Problem
 
PHP Code:

enum Substatus 
    
Status,Time 
};
new 
g_activesub[32][Substatus][32];
formatex(g_activesub[user][Status],31,"%s","Searching..."); 

(724) : error 033: array must be indexed (variable "user")

claudiuhks 04-20-2012 13:55

Re: Array Problem
 
Don't you see the difference!?

Replace

PHP Code:

new g_activesub[32][Substatus]; 

PHP Code:

new g_activesub[32][Substatus][32]; 


ProIcons 04-20-2012 13:56

Re: Array Problem
 
I have replace it maybe?

The error is on array "user" says that is Un-indexed

PHP Code:

new user[32]
                
getuser_id(user,id); 


claudiuhks 04-20-2012 13:59

Re: Array Problem
 
PHP Code:

new g_cChar33 ][ 32 ];
new 
iClient;

formatexg_cChariClient ], 31"%s""Is staying" );

new 
cClient32 ];

formatexg_cCharcClient ], 31"%s""Is staying" ); // NONONONO 


ProIcons 04-20-2012 14:01

Re: Array Problem
 
thats the way i would wanted with String, but its ok i thing. i will do it with IDs, thats the answer i was seeking all this time.


All times are GMT -4. The time now is 07:50.

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