Raised This Month: $ Target: $400
 0% 

Array Index Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-22-2012 , 13:56   Array Index Error
Reply With Quote #1

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")
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))

Last edited by ProIcons; 04-22-2012 at 14:30.
ProIcons is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-22-2012 , 14:31   Re: Array Problem Again :D
Reply With Quote #2

g_subindex is a two dimensional array yet you only give it one index.
__________________
fysiks is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-22-2012 , 14:34   Re: Array Index Error
Reply With Quote #3

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.
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-22-2012 , 14:40   Re: Array Index Error
Reply With Quote #4

Quote:
Originally Posted by ProIcons View Post
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.
__________________

Last edited by fysiks; 04-22-2012 at 14:54.
fysiks is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-22-2012 , 14:42   Re: Array Index Error
Reply With Quote #5

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
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))

Last edited by ProIcons; 04-22-2012 at 14:44.
ProIcons is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-22-2012 , 14:53   Re: Array Index Error
Reply With Quote #6

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.
__________________
fysiks is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-22-2012 , 14:58   Re: Array Index Error
Reply With Quote #7

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
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-22-2012 , 15:10   Re: Array Index Error
Reply With Quote #8

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).
__________________
fysiks is offline
Old 04-22-2012, 15:16
ProIcons
This message has been deleted by ProIcons.
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-25-2012 , 01:13   Re: Array Index Error
Reply With Quote #9

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
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-25-2012 , 23:08   Re: Array Index Error
Reply With Quote #10

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.
__________________
Bugsy is offline
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 07:51.


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