SA-MP Forums Archive
array index out of bounds - 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: array index out of bounds (/showthread.php?tid=489985)



array index out of bounds - hossamkandil - 25.01.2014

hey guys whats wrong with this..
Quote:

public OnPlayerConnect(playerid)
{
new file[64];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "/Gold/%s.ini", pname);
if(dini_Exists(file))
{
}
else
{
dini_Create(file);
dini_IntSet(file, "GoldBars",0);
}
return 1;
}
public OnPlayerDisconnect(playerid,reason)
{
new gold = PlayerInfo[MAX_PLAYERS][Gold];
new file[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"/Gold/%s.ini",name);
if(dini_Exists(file))
{
dini_IntSet(file, "GoldBars", gold);
}
return 1;
}
CMD:gold(playerid,params[])
{
new gold = PlayerInfo[MAX_PLAYERS][Gold];
gold += 1;
return 1;
}

it gives me this
Quote:

C:\Users\ALK3KA3\Documents\Hossam\Games and Other\AQW Movies\San Andreas Multiplayer Scripting\SAMP server (GM Files)\filterscripts\GoldBars.pwn(59) : error 032: array index out of bounds (variable "PlayerInfo")
C:\Users\ALK3KA3\Documents\Hossam\Games and Other\AQW Movies\San Andreas Multiplayer Scripting\SAMP server (GM Files)\filterscripts\GoldBars.pwn(240) : error 032: array index out of bounds (variable "PlayerInfo")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: array index out of bounds - Jefff - 25.01.2014

change MAX_PLAYERS to playerid