AlliedModders

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

ProIcons 04-22-2012 13:56

Array Index Error
 
PHP Code:

enum Substatus 
    
Status,Time,Queue,Nickname,ID
};
new 
g_sub[32][Substatus][32];
new 
g_subindex[32][32];

        else if (
is(text,".sub")) {
            if (
g_administrate == 0) {
                new 
user[32]
                
getuser_id(user,id);
(
785)Line            if (!g_sub[g_subindex[g_PlayerIDs[id]]][Queue]) {
                    
g_subs++
(
787)Line            g_sub[g_subs][Queue]=g_subs;
(
788)Line            g_sub[g_subs][ID]=g_PlayerIDs[id];
                    
g_sub[g_subs][Nickname]=g_user[g_PlayerIDs[id]][Username];
(
790)Line            g_subindex[g_PlayerIDs[id]]=g_subs;
                    
msg("[Sub][%s] You are now on the queue list of Subs.",user);
                    
msg("[Sub][%s] Queue Position (%d/%d).",user,g_sub[g_subs][Queue],g_subs);
(
793)Line            if (g_sub[g_subs][Queue] == 1) {
                        
g_sub[g_subs][Status]="Searching..."
                        
//sub.start
                    
}
                    else {
                        
g_sub[g_subs][Status]="Pending..."
                    
}
                }
                else { 
msg("[Sub][%s] You are allready on the Sub Queue. Please Wait...",user); }
            }
        } 

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

D:\Projects\Amxmodx\Gather\addons\amxmodx\scr ipting\Gather.sma(785) : error 033: array must be indexed (variable "g_subindex")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scr ipting\Gather.sma(787) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scr ipting\Gather.sma(788) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scr ipting\Gather.sma(790) : error 033: array must be indexed (variable "g_subindex")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scr ipting\Gather.sma(793) : error 033: array must be indexed (variable "g_sub")

fysiks 04-22-2012 14:31

Re: Array Problem Again :D
 
g_subindex is a two dimensional array yet you only give it one index.

ProIcons 04-22-2012 14:34

Re: Array Index Error
 
I want to Store in it an ID for a Queue List.
lets say

g_subindex[1]=ID.of.someone

at the g_sub now i want to set for every index the ID,Status,NickName and etc.. How i could possible do this. if i make one dimensional array the g_subindex, will appear more errors about indexing in the g_sub.

fysiks 04-22-2012 14:40

Re: Array Index Error
 
Quote:

Originally Posted by ProIcons (Post 1694582)
at the g_sub now i want to set for every index the ID,Status,NickName and etc.. How i could possible do this. if i make one dimensional array the g_subindex, will appear more errors about indexing in the g_sub.

If it is true then you probably have much bigger issues and should consider something much less complicated.

ProIcons 04-22-2012 14:42

Re: Array Index Error
 
PHP Code:

enum Substatus 
    
Status,Time,Queue,Nickname,ID
};
new 
g_sub[32][Substatus][32];
new 
g_subindex[32];

(
781Line :     else if (is(text,".sub")) {
            if (
g_administrate == 0) {
                new 
user[32]
                
getuser_id(user,id);
                if (!
g_sub[g_subindex[g_PlayerIDs[id]]][Queue]) {
                    
g_subs++
                    
g_sub[g_subs][Queue]=g_subs;
                    
g_sub[g_subs][ID]=g_PlayerIDs[id];
                    
g_sub[g_subs][Nickname]=g_user[g_PlayerIDs[id]][Username];
                    
g_subindex[g_PlayerIDs[id]]=g_subs;
                    
//format(g_subqueue,charsmax(g_subqueue),"%s %d",g_subqueue,g_PlayerIDs[id]);
                    
msg("[Sub][%s] You are now on the queue list of Subs.",user);
                    
msg("[Sub][%s] Queue Position (%d/%d).",user,g_sub[g_subs][Queue],g_subs);
                    if (
g_sub[g_subs][Queue] == 1) {
                        
g_sub[g_subs][Status]="Searching..."
                        
//sub.start
                    
}
                    else {
                        
g_sub[g_subs][Status]="Pending..."
                    
}
                }
                else { 
msg("[Sub][%s] You are allready on the Sub Queue. Please Wait...",user); }
            }
        }
        else if (
is(text,".mysub")) {
            if (
g_administrate == 0) {
                new 
user[32]
                
getuser_id(user,id);
                if (
g_sub[g_subindex[g_PlayerIDs[id]]][Queue]) {
                    
msg("[Sub][%s] Queue Position (%d/%d).",user,g_sub[g_subindex[g_PlayerIDs[id]]][Queue],g_subs);
                    
msg("[Sub][%s] Sub Status: %s",g_sub[g_subindex[g_PlayerIDs[id]]][Status]);
                }
            }
        }
        else if (
is(text,".nosub")) {
            if (
g_administrate == 0) {
                new 
user[32]
                
getuser_id(user,id);
                if (
g_sub[g_subindex[g_PlayerIDs[id]]][Queue]) {
                    if (
g_sub[g_subindex[g_PlayerIDs[id]]][Queue] == 1) {
                        
//sub.cancel
                        
msg("[Sub][%s] Queue Position (1/%d).",g_sub[1][Nickname],g_subs);
                    }
                    
g_subindex[g_PlayerIDs[id]]=0;
                    for (new 
i=g_sub[g_subindex[g_PlayerIDs[id]]][Queue];i<=g_subs;i++)
                    {
                        if (
g_sub[i+1][ID]) {
                            if (
== 1) {
                                
g_sub[i][Status]="Searching..."
                            
}
                            else {
                                
g_sub[i][Status]="Pending..."
                            
}
                            
g_sub[i][ID]=g_sub[i+1][ID]
                            
g_sub[i][Nickname]=g_sub[i+1][Nickname]
                            
g_subindex[g_sub[i+1][ID]]=i;
                        }
                        else {
                            
g_sub[i][ID]=0;
                            
g_sub[i][Nickname]="";
                            
g_sub[i][Status]="";
                            
g_subindex[g_sub[i][ID]]=0;
                        }
                    }
                    
g_subs--;
                    if (
g_subs >= 1) {
                        
//sub.start
                    
}
                }
            }
        } 

Code:


Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(785) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(787) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(788) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(794) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(809) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(819) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(820) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(825) : error 033: array must be indexed (variable "-unknown-")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(827) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(836) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(839) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(842) : error 033: array must be indexed (variable "g_sub")
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "WeaponShortNames"
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "g_activesub"
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "g_leavers"
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "g_locked_teams"
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "g_nleavers"
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "g_paused"
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "g_players"
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "g_players_retry"
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "g_subcounter"
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "getuser_gid"
D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.sma(2264) : warning 203: symbol is never used: "ret_getuser_id"

12 Errors.
Could not locate output file D:\Projects\Amxmodx\Gather\addons\amxmodx\scripting\Gather.amx (compile failed).

Compilation Time: 3,10 sec


fysiks 04-22-2012 14:53

Re: Array Index Error
 
You are trying to assign a scalar to an array in several places. I think you need to redo the entire thing with a much less complicated method. You don't need to save names or steam ids in the arrays. You can just get them when you need them.

ProIcons 04-22-2012 14:58

Re: Array Index Error
 
The data are external not from the server, from an external Application. The server is contacting with sockets to the core... and getting all the data. with the same way it request a substitute, in order to know what to save in the MySQL of the Substitutes i find neccesairy keep the data of the queue list somewhere.
I just made this so its easy to remake it. BUT, i just need you to guide me, actually i need you to tell me what did i done wrong i don't get it... it seems ok :|

fysiks 04-22-2012 15:10

Re: Array Index Error
 
There is a better way to do it. I know that Bugsy and Exolent both know them but you will have to wait until they see your post (if they want to help).

ProIcons 04-25-2012 01:13

Re: Array Index Error
 
ofc i'm scripting since 10 at the morning and now is 10 afternoon is time for break .. Tommorow Now, thank you however for your help

Bugsy 04-25-2012 23:08

Re: Array Index Error
 
I'm sure there is a simple(r) way of doing this but you need to spell it out in English. I don't have the time\patience to try to guess what you're doing by looking at your code. Based on what you said above, it sounds like you are retrieving data from an outside source and you want to put the data in a queue within your plugin until the server has a chance to process it? Give me an example of how the data comes from the server and what you want your plugin to do with it. Use words\examples, not code.


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

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