SA-MP Forums Archive
: error 033: array must be indexed (variable "name") - 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: : error 033: array must be indexed (variable "name") (/showthread.php?tid=522387)



: error 033: array must be indexed (variable "name") - PawnOX - 27.06.2014

These 2 erorrs appears, How can i fix it?

(24589) : error 033: array must be
indexed (variable "name")

(24589) : error 006: must be
assigned to an array
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.


Codes:
The Red text is where the error caming from
Код:
CMD:osetadmin(playerid, params[])
{
	if(IsPlayerAdmin(playerid))
	{

		new string[128], name[MAX_PLAYER_NAME];
		if(sscanf(params, "si", name, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /osetadmin [playername] [time (minutes)] [reason]");

        new giveplayerid = ReturnUser(name);
        if(IsPlayerConnected(giveplayerid))
		{
			SendClientMessage(playerid, COLOR_GRAD2, "That player is online, use /setadmin for online players.");
			return 1;
		}
		if(PlayerInfo[MAX_PLAYERS][pAdmin] == 6) return SendClientMessage(playerid, COLOR_GRAD1, "You cant offline setadmin an Level 6 Admin");
		else if(doesAccountExist(name))
		{
			OnPlayerOfflineLogin(name);
			if(PlayerInfo[MAX_PLAYERS][pPermaBanned] == 1 || PlayerInfo[MAX_PLAYERS][pBanned] >= 1)
			{
				SendClientMessage(playerid, COLOR_WHITE, "That player is banned.");
				return 1;
			}
			else
			{
				
				format(string, sizeof(string), "AdmCmd: %s was offline setadmin to %d by %s", name, GetPlayerNameEx(playerid), params);
				ABroadCast(COLOR_LIGHTRED,string,1);
				PlayerInfo[name][pAdmin] = params;
				OnPlayerOfflineSave(name);
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_WHITE, "That account doesn't exist.");
		}
	}
	return 1;
}



Re: : error 033: array must be indexed (variable "name") - Eth - 27.06.2014

pawn Код:
format(PlayerInfo[name][pAdmin], sizeof(params),params);



Re: : error 033: array must be indexed (variable "name") - PawnOX - 27.06.2014

Quote:
Originally Posted by Eth
Посмотреть сообщение
pawn Код:
format(PlayerInfo[name][pAdmin], sizeof(params),params);
Код:
C:\Users\ASD\Desktop\0.3z Server\ASD\gamemodes\ASDASD(24589) : error 033: array must be indexed (variable "name")
C:\Users\ASD\Desktop\0.3z Server\ASD\gamemodes\ASDASDn(24589) : warning 224: indeterminate array size in "sizeof" expression (symbol "")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: : error 033: array must be indexed (variable "name") - Beckett - 27.06.2014

pawn Код:
CMD:osetadmin(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {

        new string[128], name[MAX_PLAYER_NAME],lvl;
        if(sscanf(params, "ui", name,lvl)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /osetadmin [Playername] [Admin Level]");

        new giveplayerid = ReturnUser(name);
        if(IsPlayerConnected(giveplayerid))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "That player is online, use /setadmin for online players.");
            return 1;
        }
        if(PlayerInfo[MAX_PLAYERS][pAdmin] == 6) return SendClientMessage(playerid, COLOR_GRAD1, "You cant offline setadmin an Level 6 Admin");
        else if(doesAccountExist(name))
        {
            OnPlayerOfflineLogin(name);
            if(PlayerInfo[MAX_PLAYERS][pPermaBanned] == 1 || PlayerInfo[MAX_PLAYERS][pBanned] >= 1)
            {
                SendClientMessage(playerid, COLOR_WHITE, "That player is banned.");
                return 1;
            }
            else
            {

                format(string, sizeof(string), "AdmCmd: %s was offline setadmin to %d by %s.", name,lvl,GetPlayerNameEx(playerid));
                ABroadCast(COLOR_LIGHTRED,string,1);
                PlayerInfo[name][pAdmin] = lvl;
                OnPlayerOfflineSave(name);
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "That account doesn't exist.");
        }
    }
    return 1;
}
Your format was completely missed up, try the code above.


Re: : error 033: array must be indexed (variable "name") - BroZeus - 27.06.2014

use this sscanf line
sscanf(params, "ui", name, params)
use the "u" in it because string variable cannot be used in
EDIT: change name to a int value remove [] thing from its front while declaration


Re: : error 033: array must be indexed (variable "name") - Beckett - 27.06.2014

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
use this sscanf line
sscanf(params, "ui", name, params)
use the "u" in it because string variable cannot be used in
EDIT: change name to a int value remove [] thing from its front while declaration
What BroZues said above "s" stands for a string not playerid or a part of his name.


Re: : error 033: array must be indexed (variable "name") - Stinged - 27.06.2014

It's supposed to me PlayerInfo[playerid][..]
playerid is an integer, while name is a string.