SA-MP Forums Archive
invalid subscript (not an array or too many subscripts) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: invalid subscript (not an array or too many subscripts) (/showthread.php?tid=502743)



invalid subscript (not an array or too many subscripts) - Blackazur - 25.03.2014

Hello, how to fix it?

Код:
        format(cmdstring, sizeof(cmdstring), "unbanip %s", pIP(playerid));



Re: invalid subscript (not an array or too many subscripts) - TLN - 25.03.2014

Try this.
pawn Код:
format(cmdstring, sizeof(cmdstring), "unbanip %s", pIP[playerid]);



AW: invalid subscript (not an array or too many subscripts) - Blackazur - 25.03.2014

nop still this is the pIP on the enum:

Quote:

pIP[22]




Re: invalid subscript (not an array or too many subscripts) - TLN - 25.03.2014

Tested this with your enum thingy, should work.
pawn Код:
format(cmdstring, sizeof(cmdstring), "unbanip %s", pIP);



AW: invalid subscript (not an array or too many subscripts) - Blackazur - 25.03.2014

1 warning:

symbol is assigned a value that is never used: "string"


Re: invalid subscript (not an array or too many subscripts) - TLN - 25.03.2014

Give me the line please.


AW: invalid subscript (not an array or too many subscripts) - Blackazur - 25.03.2014

Thats the command, any help were appreciated:

Код:
CMD:unban(playerid, params[])
{
    new string[128],tname[24];
    if(sscanf(params, "s[24]", tname)) return SendClientMessage(playerid,-1,""chat" Usage: /unban [playerid]");
    new filestring[79];
    format(filestring, sizeof(filestring), "/Users/%s.ini", tname);
    if(!fexist(filestring)) return SendClientMessage(playerid,-1,""chat""COL_RED" This player does not exist!");
    else
    {
        new INI:File = INI_Open(filestring);
        INI_SetTag(File, "data");
        INI_WriteInt(File, "pBanned",0);
        INI_Close(File);
        INI_ParseFile(filestring, "LoadIP_%s", .bExtra = true , .extra = playerid);
        new cmdstring[44];
        format(cmdstring, sizeof(cmdstring), "unbanip %s", pIP);
        SendRconCommand(cmdstring);
        SendRconCommand("reloadbans");
    }
    return 1;
}



Re: invalid subscript (not an array or too many subscripts) - TLN - 25.03.2014

The warning should be fixed now.
pawn Код:
CMD:unban(playerid, params[])
{
    new tname[24];
    if(sscanf(params, "s[24]", tname)) return SendClientMessage(playerid,-1, ""chat""Usage: /unban [playerid]");
    new filestring[79];
    format(filestring, sizeof(filestring), "
/Users/%s.ini", tname);
    if(!fexist(filestring)) return SendClientMessage(playerid,-1,"
"chat""COL_RED" This player does not exist!");
    else
    {
        new INI:File = INI_Open(filestring);
        INI_SetTag(File, "
data");
        INI_WriteInt(File, "
pBanned",0);
        INI_Close(File);
        INI_ParseFile(filestring, "
LoadIP_%s", .bExtra = true , .extra = playerid);
        new cmdstring[44];
        format(cmdstring, sizeof(cmdstring), "
unbanip %s", pIP);
        SendRconCommand(cmdstring);
        SendRconCommand("
reloadbans");
    }
    return 1;
}



Re: invalid subscript (not an array or too many subscripts) - DerickClark - 25.03.2014

You cannot use "string". use something like "tmpString"


Re: invalid subscript (not an array or too many subscripts) - Spydah - 25.03.2014

Quote:
Originally Posted by TLN
Посмотреть сообщение
The warning should be fixed now.
pawn Код:
CMD:unban(playerid, params[])
{
    new tname[24];
    if(sscanf(params, "s[24]", tname)) return SendClientMessage(playerid,-1, ""chat""Usage: /unban [playerid]");
    new filestring[79];
    format(filestring, sizeof(filestring), "
/Users/%s.ini", tname);
    if(!fexist(filestring)) return SendClientMessage(playerid,-1,"
"chat""COL_RED" This player does not exist!");
    else
    {
        new INI:File = INI_Open(filestring);
        INI_SetTag(File, "
data");
        INI_WriteInt(File, "
pBanned",0);
        INI_Close(File);
        INI_ParseFile(filestring, "
LoadIP_%s", .bExtra = true , .extra = playerid);
        new cmdstring[44];
        format(cmdstring, sizeof(cmdstring), "
unbanip %s", pIP);
        SendRconCommand(cmdstring);
        SendRconCommand("
reloadbans");
    }
    return 1;
}
Make it easier for him, man.

pawn Код:
CMD:unban(playerid, params[])
{
    new cmdstring[128],tname[24],filestring[79];
    if(sscanf(params, "s[24]", tname)) return SendClientMessage(playerid,-1, ""chat""Usage: /unban [playerid]");
    format(filestring, sizeof(filestring), "
/Users/%s.ini", tname);
    if(!fexist(filestring)) return SendClientMessage(playerid,-1,"
"chat""COL_RED" This player does not exist!");
    else
    {
        new INI:File = INI_Open(filestring);
        INI_SetTag(File, "
data");
        INI_WriteInt(File, "
pBanned",0);
        INI_Close(File);
        INI_ParseFile(filestring, "
LoadIP_%s", .bExtra = true , .extra = playerid);
        format(cmdstring, sizeof(cmdstring), "
unbanip %s", pIP);
        SendRconCommand(cmdstring);
        SendRconCommand("
reloadbans");
    }
    return 1;
}
You had this in the middle of the script:
pawn Код:
new cmdstring[44]
Don't make your script look messy, it's better for yourself..

So I've moved the rule up.

pawn Код:
new cmdstring[128], tname[24];