can i ask
#1

what is this!

error 033: array must be indexed (variable "playername")
Reply
#2

show me the line..
Reply
#3

lol ok but this is just the line, wont help unless u has all needed, and that is a lot of stuff,

pawn Код:
playername = ReturnUser(tmp);
thats the line^^
Reply
#4

new playername[MAX_PLAYER_NAME];
Reply
#5

i have that

maybe this helps u -_-

pawn Код:
//==============================================================================
    if(strcmp(cmd, "/tempban", true) == 0)
    {
        new playername[MAX_PLAYER_NAME];
        new adminname[MAX_PLAYER_NAME];

        if(PlayerInfo[playerid][Level] >= 4)
        {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, red, "Usage: /tempban [PlayerID] [Day(s)] [Reason]");
                SendClientMessage(playerid, green, "Function: Temporarily bans a player for specified Days");
                return 1;
            }
            new string[128];
            playername = ReturnUser(tmp);
            if(IsPlayerConnected(playername))
            {
                tmp = strtok(cmdtext, idx);
                if (!strlen(tmp))
                {
                SendClientMessage(playerid, red, "Usage: /tempban [PlayerID] [Day(s)] [Reason]");
                SendClientMessage(playerid, green, "Function: Temporarily bans a player for specified Days");
                return 1;
                }
                new days = strval(tmp);
                if(!IsNumeric(tmp))
                return SendClientMessage(playerid, red, "ERROR: Invalid Day! Only Numbers!");

                if(strval(tmp) <= 0 || strval(tmp) > 1000)
                return SendClientMessage(playerid, red, "ERROR: Invalid Day! (1-1000)");

                new reason[128];
                reason = strtok2(cmdtext,idx);
                if (!strlen(reason))
                return SendClientMessage(playerid, red, "ERROR: Reason not Specified!");

                if (strlen(reason) <= 0 || strlen(reason) > 100)
                return SendClientMessage(playerid, red, "ERROR: Invalid Reason length!");

                new ip[15];
                GetPlayerIp(playername,ip,15);
                GetPlayerName(playerid, playername, sizeof playername);
                GetPlayerName(playername, playername, sizeof(playername));
                new File:tempban = fopen("ladmin/Config/TempBans", io_append);
                if (tempban)
                {
                    new year,month,day;
                    getdate(year, month, day);
                    day += days;
                    if (IsMonth31(month))
                    {
                        if (day > 31)
                        {
                            month += 1;
                            if (month > 12)
                            {
                                year += 1;
                                while(day > 31) day -= 31;
                            }
                            else while(day > 31) day -= 31;
                        }
                    }
                    else if (!IsMonth31(month))
                    {
                        if (day > 30)
                        {
                            month += 1;
                            if (month > 12)
                            {
                                year += 1;
                                while(day > 30) day -= 30;
                            }
                            else while(day > 30) day -= 30;
                        }
                    }
                    else if (!IsMonth31(month) && IsMonth29(year) && month == 2)
                    {
                        if (day > 29)
                        {
                            month += 1;
                            if (month > 12)
                            {
                                year += 1;
                                while(day > 29) day -= 29;
                            }
                            else while(day > 29) day -= 29;
                        }
                    }
                    else if (!IsMonth31(month) && !IsMonth29(year) && month == 2)
                    {
                        if (day > 28)
                        {
                            month += 1;
                            if (month > 12)
                            {
                                year += 1;
                                while(day > 28) day -= 28;
                            }
                            else while(day > 28) day -= 28;
                        }
                    }
                    format(string, sizeof string, "%d|%d|%d|%s\n", day, month, year, ip);
                    fwrite(tempban, string);
                    fclose(tempban);
                }
                format(string,128,"Administrator %s Temporarily Banned %s for %d Day(s) | Reason: %s",adminname,playername,days,reason);
                SendClientMessageToAll(red,string);
                Kick(playername);

                format(string, sizeof string, "Admin %s Temporarily Banned %s for %d Day(s) | Reason: %s",adminname,playername,days,reason);
                SaveIn("TempBansLog",string);
            }
            else
            {
                SendClientMessage(adminname, red, "Player is not connected");
            }
        } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
    }
//==============================================================================
and these errors

Код:
(4491) : warning 219: local variable "string" shadows a variable at a preceding level
(4492) : error 033: array must be indexed (variable "playername")
C(4493) : error 035: argument type mismatch (argument 1)
(4518) : error 035: argument type mismatch (argument 1)
(4520) : error 035: argument type mismatch (argument 1)
(4585) : error 035: argument type mismatch (argument 1)
(4592) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#6

pawn Код:
if(strcmp(cmd, "/tempban", true) == 0)
    {
        new adminname[MAX_PLAYER_NAME];

        if(PlayerInfo[playerid][Level] >= 4)
        {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, red, "Usage: /tempban [PlayerID] [Day(s)] [Reason]");
                SendClientMessage(playerid, green, "Function: Temporarily bans a player for specified Days");
                return 1;
            }
            new string[128];
            new playername[24];
            playername = ReturnUser(tmp);
            if(IsPlayerConnected(playername))
            {
                tmp = strtok(cmdtext, idx);
                if (!strlen(tmp))
                {
                SendClientMessage(playerid, red, "Usage: /tempban [PlayerID] [Day(s)] [Reason]");
                SendClientMessage(playerid, green, "Function: Temporarily bans a player for specified Days");
                return 1;
                }
                new days = strval(tmp);
                if(!IsNumeric(tmp))
                return SendClientMessage(playerid, red, "ERROR: Invalid Day! Only Numbers!");

                if(strval(tmp) <= 0 || strval(tmp) > 1000)
                return SendClientMessage(playerid, red, "ERROR: Invalid Day! (1-1000)");

                new reason[128];
                reason = strtok2(cmdtext,idx);
                if (!strlen(reason))
                return SendClientMessage(playerid, red, "ERROR: Reason not Specified!");

                if (strlen(reason) <= 0 || strlen(reason) > 100)
                return SendClientMessage(playerid, red, "ERROR: Invalid Reason length!");

                new ip[15];
                GetPlayerIp(playername,ip,15);
                GetPlayerName(playerid, playername, sizeof playername);
                GetPlayerName(playername, playername, sizeof(playername));
                new File:tempban = fopen("ladmin/Config/TempBans", io_append);
                if (tempban)
                {
                    new year,month,day;
                    getdate(year, month, day);
                    day += days;
                    if (IsMonth31(month))
                    {
                        if (day > 31)
                        {
                            month += 1;
                            if (month > 12)
                            {
                                year += 1;
                                while(day > 31) day -= 31;
                            }
                            else while(day > 31) day -= 31;
                        }
                    }
                    else if (!IsMonth31(month))
                    {
                        if (day > 30)
                        {
                            month += 1;
                            if (month > 12)
                            {
                                year += 1;
                                while(day > 30) day -= 30;
                            }
                            else while(day > 30) day -= 30;
                        }
                    }
                    else if (!IsMonth31(month) && IsMonth29(year) && month == 2)
                    {
                        if (day > 29)
                        {
                            month += 1;
                            if (month > 12)
                            {
                                year += 1;
                                while(day > 29) day -= 29;
                            }
                            else while(day > 29) day -= 29;
                        }
                    }
                    else if (!IsMonth31(month) && !IsMonth29(year) && month == 2)
                    {
                        if (day > 28)
                        {
                            month += 1;
                            if (month > 12)
                            {
                                year += 1;
                                while(day > 28) day -= 28;
                            }
                            else while(day > 28) day -= 28;
                        }
                    }
                    format(string, sizeof string, "%d|%d|%d|%s\n", day, month, year, ip);
                    fwrite(tempban, string);
                    fclose(tempban);
                }
                format(string,128,"Administrator %s Temporarily Banned %s for %d Day(s) | Reason: %s",adminname,playername,days,reason);
                SendClientMessageToAll(red,string);
                Kick(playername);

                format(string, sizeof string, "Admin %s Temporarily Banned %s for %d Day(s) | Reason: %s",adminname,playername,days,reason);
                SaveIn("TempBansLog",string);
            }
            else
            {
                SendClientMessage(adminname, red, "Player is not connected");
            }
        } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
    }
idk that maybe eff it idk about strcmp much im a zcmder
Reply
#7

Quote:
Originally Posted by willsuckformoney
Посмотреть сообщение
what is this!

error 033: array must be indexed (variable "playername")
If something needs to be indexed, it is most likely trying to be assigned some sort of string or something...
According to the code, playername is trying to be assigned the id of the typed user(tmp); playername doesn't need to be indexed for this. If you want the name of this id, you would later have to make a new variable and index THAT(new name[20] Then use GetPlayerName(playername,name,sizeof(name));. If Im wrong then its because strtok is annoying AS HELL and you should switch to dcmd/zcmd and sscanf.
Reply
#8

lol well here

errors
Код:
(4518) : error 035: argument type mismatch (argument 2)
(4518) : error 035: argument type mismatch (argument 2)
(4519) : error 035: argument type mismatch (argument 2)
(4519) : error 035: argument type mismatch (argument 2)
(4591) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
and here the lines

pawn Код:
//4518
GetPlayerName(playerid, playername, sizeof playername);

//4519
GetPlayerName(playerid, playername, sizeof(playername));

//4591
SendClientMessage(adminname, red, "Player is not connected");
btw i fixed it too

pawn Код:
new playername = ReturnUser(tmp);
thats it

EDIT: Fixed last error xD
Reply
#9

Quote:
Originally Posted by willsuckformoney
Посмотреть сообщение
lol ok but this is just the line, wont help unless u has all needed, and that is a lot of stuff,

pawn Код:
playername = ReturnUser(tmp);
thats the line^^
ReturnUser returns a string with an indefined size. You can work around that doing something like this:

pawn Код:
format(playername, sizeof(playername), "%s", ReturnUser(tmp));
Reply
#10

Quote:
Originally Posted by Zamaroht
Посмотреть сообщение
ReturnUser returns a string with an indefined size. You can work around that doing something like this:

pawn Код:
format(playername, sizeof(playername), "%s", ReturnUser(tmp));
I believe he said my way worked, and lets fix these 'easy' errors xD:

1,2,3 and 4: lines 4418 and 4419 are EXACTLY the same. I see your trying to get more than one name. Change the second playerid in the second GetPlayerName to something else like the id of another player(if this other player is stored in tmp, then put tmp here). Make sure playername is defined with an index(new playername[20]. and use another sizeof variable for the second one too because you can't store 2 different names in the same variable.

5: looks right to me, but you said you fixed it....

EDIT: If your using playername for ReturnUser, then YOU MUST make up another variable for the names, because 1 variable can't be 2 things at once...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)