AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   error 033: array must be indexed (https://forums.alliedmods.net/showthread.php?t=130070)

iloveportalz0r 06-19-2010 22:09

error 033: array must be indexed
 
Hi I'm trying to add a "frozen" option to my !spawn command on my HL2DM server so that a prop spawns frozen, (like !spawn <propname> frozen), but when I try to compile my plugin it gives this error: ilp/ilp_sourceop.sp(122) : error 033: array must be indexed (variable "-unknown-") . Here's the code:
Code:

public Action:Command_spawn(Client,args)
{
    if(args < 1)
    {
        ShowMOTDPanel(Client, "FunBox Help - Prop Names", "http://www.thechaoscrewclan.com/104/hl2mp/propnames.html", MOTDPANEL_TYPE_URL);
        return Plugin_Handled;
    }
    decl String:prop[32];
    decl String:isfroxxed[255];
    GetCmdArg(1,prop,32);
    GetCmdArg(2,isfroxxed,255);
    ClientCommand(Client, "e_spawnprop %s", prop);
    if (StringToInt(isfroxxed) ==  "frozen") // <- Line 122
    {
        ClientCommand(Client, "sm_freeze");
    }
    return Plugin_Handled;
}

Help is appreciated :)

fysiks 06-19-2010 22:21

Re: error 033: array must be indexed
 
StringToInt() returns an integer and you are comparing that to a string. It says that "frozen" shoule be index because it is an array and you can't compare an array to an integer.

BTW, you should post in the SourceMod section. This section is for AMX Mod X.

iloveportalz0r 06-20-2010 01:32

Re: error 033: array must be indexed
 
Oops sorry. I thought this was the sourcemod section. How dumb am I? So would I use StringToString or strcompare or what?

fysiks 06-20-2010 02:04

Re: error 033: array must be indexed
 
Quote:

Originally Posted by iloveportalz0r (Post 1213949)
Oops sorry. I thought this was the sourcemod section. How dumb am I? So would I use StringToString or strcompare or what?

I'm not familiar with SourceMod functions but it will be something like string compare or something like that.

EDIT: strcmp()

iloveportalz0r 06-20-2010 02:48

Re: error 033: array must be indexed
 
OK thanks. This worked:
Code:

public Action:Command_spawn(Client,args)
{
    if(args < 1)
    {
        ShowMOTDPanel(Client, "FunBox Help - Prop Names", "http://www.thechaoscrewclan.com/104/hl2mp/propnames.html", MOTDPANEL_TYPE_URL);
        return Plugin_Handled;
    }
    decl String:prop[32];
    decl String:isfroxxed[255];
    GetCmdArg(1,prop,32);
    GetCmdArg(2,isfroxxed,255);
    ClientCommand(Client, "e_spawnprop %s", prop);
    if (strcmp(isfroxxed, "frozen", false) == 0)
    {
        ClientCommand(Client, "sm_freeze");
    }
    return Plugin_Handled;
}



All times are GMT -4. The time now is 14:42.

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