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

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;
}
Reply
#2

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

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.
Reply
#4

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.
Reply
#5

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
Reply
#6

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.
Reply
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)