PDA

View Full Version : error 033: array must be indexed


Stefand
18/09/2012, 03:59 PM
command(makeowner, playerid, params[])
{
new Confirm[128], id, string[128], string1[128];
if(sscanf(params, "dz", id, Confirm))
{
if(Player[playerid][FactionRank] == 7 && Factions[Player[playerid][Faction]][FOwner] == GetName(playerid))
{
format(string1, sizeof(string1), "You wanna make %s the owner of your faction? [Yes? Type '/makeowner [id] Confirm'] ", GetName(id));
SendClientMessage(playerid, WHITE, string1);
}
}
else
{
if(Player[playerid][FactionRank] == 7 && Factions[Player[playerid][Faction]][FOwner] == GetName(playerid))
{
format(string, sizeof(string), "Factions/Faction_%d.ini", id);
if(strcmp(Confirm, "Confirm", true) == 0)
{
if(Player[id][Faction] == Player[playerid][Faction])
{
format(Factions[Player[playerid][Faction]][FOwner], 255, "%s", GetName(id));
format(string1, sizeof(string1), "You made %s owner of the faction, you are now %s.", GetName(id), Factions[Player[id][Faction]][RankName6]);
SendClientMessage(playerid, WHITE, string1);
Player[playerid][FactionRank] = 6;
format(string1, sizeof(string1), "%s made you owner of the faction, he is now %s.", GetName(playerid), Factions[Player[id][Faction]][RankName6]);
SendClientMessage(id, ADMINBLUE, string1);
Player[id][FactionRank] = 7;
SaveFaction(Player[id][Faction]);
SavePlayerData(playerid);
SavePlayerData(id);
}
else
{
SCM(playerid, RED, "This player is not in your faction.");
}
}
}
}
return 1;
}

I have a working stock for the GetName it works for other commands.



C:\Users\Stefan Dorst\Desktop\Scratch RolePlay\gamemodes\RP.pwn(528) : error 033: array must be indexed (variable "GetName")
C:\Users\Stefan Dorst\Desktop\Scratch RolePlay\gamemodes\RP.pwn(536) : error 033: array must be indexed (variable "GetName")
C:\Users\Stefan Dorst\Desktop\Scratch RolePlay\gamemodes\RP.pwn(2834) : error 006: must be assigned to an array
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.


EDIT:

Error line's are the same it's:


if(Player[playerid][FactionRank] == 7 && Factions[Player[playerid][Faction]][FOwner] == GetName(playerid))
{

This is my stock


stock GetName(playerid)
{
new Name[MAX_PLAYER_NAME];

if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, Name, sizeof(Name));
}
else
{
Name = "Disconnected/Nothing";
}

return Name;
}

Jason`
18/09/2012, 04:01 PM
Try

GetName[playerid]

Stefand
18/09/2012, 04:06 PM
Try

GetName[playerid]

Won't work...



C:\Users\Stefan Dorst\Desktop\Scratch RolePlay\gamemodes\RP.pwn(546) : error 028: invalid subscript (not an array or too many subscripts): "GetName"
C:\Users\Stefan Dorst\Desktop\Scratch RolePlay\gamemodes\RP.pwn(546) : warning 215: expression has no effect
C:\Users\Stefan Dorst\Desktop\Scratch RolePlay\gamemodes\RP.pwn(546) : error 001: expected token: ";", but found "]"
C:\Users\Stefan Dorst\Desktop\Scratch RolePlay\gamemodes\RP.pwn(546) : error 029: invalid expression, assumed zero
C:\Users\Stefan Dorst\Desktop\Scratch RolePlay\gamemodes\RP.pwn(546) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

Jason`
18/09/2012, 04:14 PM
So, try the code below:


command(makeowner, playerid, params[])
{
new Confirm[128], id, string[128], string1[128];
if(sscanf(params, "dz", id, Confirm))
{
if(Player[playerid][FactionRank] == 7 && !strcmp(Factions[Player[playerid][Faction]][FOwner], GetName(playerid), true))
{
format(string1, sizeof(string1), "You wanna make %s the owner of your faction? [Yes? Type '/makeowner [id] Confirm'] ", GetName(id));
SendClientMessage(playerid, WHITE, string1);
}
}
else
{
if(Player[playerid][FactionRank] == 7 && !strcmp(Factions[Player[playerid][Faction]][FOwner], GetName(playerid), true))
{
format(string, sizeof(string), "Factions/Faction_%d.ini", id);
if(strcmp(Confirm, "Confirm", true) == 0)
{
if(Player[id][Faction] == Player[playerid][Faction])
{
format(Factions[Player[playerid][Faction]][FOwner], 255, "%s", GetName(id));
format(string1, sizeof(string1), "You made %s owner of the faction, you are now %s.", GetName(id), Factions[Player[id][Faction]][RankName6]);
SendClientMessage(playerid, WHITE, string1);
Player[playerid][FactionRank] = 6;
format(string1, sizeof(string1), "%s made you owner of the faction, he is now %s.", GetName(playerid), Factions[Player[id][Faction]][RankName6]);
SendClientMessage(id, ADMINBLUE, string1);
Player[id][FactionRank] = 7;
SaveFaction(Player[id][Faction]);
SavePlayerData(playerid);
SavePlayerData(id);
}
else
{
SCM(playerid, RED, "This player is not in your faction.");
}
}
}
}
return 1;
}