Raised This Month: $32 Target: $400
 8% 

error 033: Array must be indexed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lt Llama
Senior Member
Join Date: Aug 2004
Old 02-04-2006 , 12:36   error 033: Array must be indexed
Reply With Quote #1

Last part before plugin is done. Another nub error from my side.
I get "Array must be indexed (variable "-unknown")" from the code below.
I want to read the number which is stored in qryClass.

I'm trying to index it with incrQryClass but then it says unknown

Code:
new qryClass[32] new incrQryClass = 0 while (resultMaps && dbi_nextrow(resultMaps) > 0) {     dbi_result(resultMaps, "playerClass", qryClass[incrQryClass], 31)     if (qryClass[incrQryClass] == "1")         ++scoutSum     if (qryClass[incrQryClass] == "2")         ++sniperSum     if (qryClass[incrQryClass] == "3")         ++soldierSum     if (qryClass[incrQryClass] == "4")         ++demomanSum     if (qryClass[incrQryClass] == "5")         ++medicSum     if (qryClass[incrQryClass] == "6")         ++hwguySum     if (qryClass[incrQryClass] == "7")         ++pyroSum     if (qryClass[incrQryClass] == "8")         ++spySum     if (qryClass[incrQryClass] == "9")         ++engineerSum     if (qryClass[incrQryClass] == "10")         ++civilianSum     ++incrQryClass }
Lt Llama is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-04-2006 , 12:41  
Reply With Quote #2

Post the entire thing, and say what line.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 02-04-2006 , 13:19  
Reply With Quote #3

All your numbers in quotes, should be in apostrophes instead because you're using a single cell, or character, instead of a string. Quotes denote string while apostrophes denote characters. I just ran into this myself.

Fo' instance:
Code:
if (qryClass[incrQryClass] == '1')
Brad is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 02-04-2006 , 14:23  
Reply With Quote #4

Quote:
Originally Posted by Brad
All your numbers in quotes, should be in apostrophes instead because you're using a single cell, or character, instead of a string. Quotes denote string while apostrophes denote characters. I just ran into this myself.

Fo' instance:
Code:
if (qryClass[incrQryClass] == '1')
That was it and +karma for that, it really annoyed me.

Now I have a delicate problem. TFC has the class numbers
1
2
3
4
5
6
7
8
9
11

When I add civilian it adds 11 to the database. But when i use

Code:
if (qryClass[incrQryClass] == '1')

It sees the "1" in "11" and thinks I finnished as scout, and not civvy.

yea, and when i compile with

Code:
if (qryClass[incrQryClass] == '11')
i get
an "Invalid character constant' error.

Can I use regular expressions in between '11'?
Lt Llama is offline
DaSoul
Senior Member
Join Date: Jan 2006
Old 02-04-2006 , 15:06  
Reply With Quote #5

If you are dealing with numbers I think you need to change these...

Code:
if (qryClass[incrQryClass] == '1')

to

Code:
if (qryClass[incrQryClass] == 1)

Do it with all the numbers. If you need to compare strings you need to do:

Code:
if (equal(qryClass[incrQryClass],"1"))
DaSoul is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 02-04-2006 , 15:52  
Reply With Quote #6

If it's strings he has to change up his qryClass variable. Something like:
Code:
new qryClass[32][32];
Brad is offline
DaSoul
Senior Member
Join Date: Jan 2006
Old 02-04-2006 , 16:50  
Reply With Quote #7

Quote:
Originally Posted by Brad
If it's strings he has to change up his qryClass variable. Something like:
Code:
new qryClass[32][32];
Yes. You are correct.
DaSoul is offline
Reply


Thread Tools
Display Modes

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 19:53.


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