Raised This Month: $ Target: $400
 0% 

Error: Array must be indexed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
skis
Junior Member
Join Date: Jul 2008
Old 07-23-2008 , 19:34   Error: Array must be indexed
Reply With Quote #1

Can someone please look at this code and see if you can see anything wrong? I get this error:

Error: Array must be indexed (variable "-unknown-") on line 31

Code:
22 public bombpickup() {
23     new players[32];
24     new num, i;
25     get_players(players, num, "e", "TERRORIST");
26     for(i = 0;i < num; i++) {
27         new weapons[32];
28         new numweapons, j;
29         get_user_weapons(i, weapons, numweapons);
30         for (j = 0; j < numweapons; j++) {
31             if (weapons[j] == "weapon_c4") {
32                 //do something if he has the bomb
33             }
34         }
35     }
36 }
Does the variable "j" not work as an index in a for loop or something?
skis is offline
Jon
Veteran Member
Join Date: Dec 2007
Old 07-23-2008 , 19:56   Re: Error: Array must be indexed
Reply With Quote #2

You can't compare strings that way. Use:
Code:
if(equal(weapons[j], "weapon_c4"))
Jon is offline
skis
Junior Member
Join Date: Jul 2008
Old 07-23-2008 , 20:21   Re: Error: Array must be indexed
Reply With Quote #3

Thanks
skis 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 05:40.


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