SA-MP Forums Archive
Error: invalid subscript (not an array or too many subscripts): "pInfo" - 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: invalid subscript (not an array or too many subscripts): "pInfo" (/showthread.php?tid=596159)



Error: invalid subscript (not an array or too many subscripts): "pInfo" - Bashur - 13.12.2015

I've been struggling with this error now for a couple off hours and i can't seem to be finding a solution, (BTW i'm new in scripting) So i'm posting this

The error:
invalid subscript (not an array or too many subscripts): "pInfo"

Line 139 Where the error is:

if(pInfo[i][pFaction] == 2)

Full code:

public PoliceBroadcast(color,const string[],level)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pInfo[i][pFaction] == 2)
{
SendClientMessage(i, color, string);
}
}
}
return 1;
}


Re: Error: invalid subscript (not an array or too many subscripts): "pInfo" - Denying - 13.12.2015

Can you show me where you declare pInfo?


Re: Error: invalid subscript (not an array or too many subscripts): "pInfo" - Bashur - 13.12.2015

enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pFac,
pLead,
pBanned
};


Re: Error: invalid subscript (not an array or too many subscripts): "pInfo" - Denying - 13.12.2015

I see. That's not quite how you do it.

After the enum, write: new PlayerInfo[MAX_PLAYERS][pInfo];

Then, in the error line, replace pInfo with PlayerInfo.


Re: Error: invalid subscript (not an array or too many subscripts): "pInfo" - Bashur - 13.12.2015

It's working now Thanks +rep