array index out of bounds Error. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: array index out of bounds Error. (
/showthread.php?tid=160069)
array index out of bounds Error. -
Gforcez - 15.07.2010
Hello,
i have this error:
Код:
: error 032: array index out of bounds (variable "gangname")
This is my code:
Код:
dcmd_makegang(playerid, params[])
{
new gangname[MAX_GANG_NAME+1];
if(sscanf(params, "z", gangname))
return SendClientMessage(playerid, COLOR_GREY, "USAGE: /makegang [gangname]");
if(PlayerInfo[playerid][pLevel] >= 10)
{
new string[92];
format(string, 92, "%s Has created the gang: %s And is Recruiting!", Playername[playerid], params);
SendClientMessageToAll(COLOR_RED, string);
CreateGang(gangname[MAX_GANG_NAME+1], Playername[playerid]);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You need Minimum of Level 10 to create a Gang");
}
return 1;
}
iam using this gang system:
https://sampforum.blast.hk/showthread.php?tid=72784
Please somebody help me..
Re: array index out of bounds Error. -
armyoftwo - 15.07.2010
try
Код:
CreateGang(strval(gangname), Playername[playerid]);
But i doubt it that it will work
Re: array index out of bounds Error. -
Gforcez - 15.07.2010
Nope, it doesn't Work, now i get this error on your line:
Код:
: error 035: argument type mismatch (argument 1)
Re: array index out of bounds Error. -
MadeMan - 15.07.2010
pawn Код:
CreateGang(gangname, Playername[playerid]);
Re: array index out of bounds Error. -
Gforcez - 15.07.2010
Код:
error 047: array sizes do not match, or destination array is too small
:S
Re: array index out of bounds Error. -
MadeMan - 15.07.2010
Can you show CreateGang function?
Re: array index out of bounds Error. -
Gforcez - 15.07.2010
Код:
stock CreateGang(name[MAX_GANG_NAME],owner[MAX_PLAYER_NAME])
{
new string[256],File:hFile;
for(new i = 0; i < MAX_GANGS; i++)
{
format(string, sizeof(string), "/gangs/%d.gang", i);
if(!fexist(string))
{
hFile = fopen(string, io_write);
format(string, sizeof(string), "%s|%s", name,owner);
fwrite(hFile, string);
fclose(hFile);
Gangs[i][gName] = name;
Gangs[i][gOwner] = owner;
hFile = fopen("ganglog.log", io_append);
format(string, sizeof(string), "Gang %d added: %s|%s", i, name,owner);
fwrite(hFile, string);
fclose(hFile);
return i;
}
}
return -1;
}
Here you go.
Re: array index out of bounds Error. -
[HUN]Jaki - 15.07.2010
You will have to replace
pawn Код:
new gangname[MAX_GANG_NAME+1];
with
pawn Код:
new gangname[MAX_GANG_NAME];
(The size of the requested array is MAX_GANG_NAME, not MAX_GANG_NAME+1)
Re: array index out of bounds Error. -
[HiC]TheKiller - 15.07.2010
Or just change it to
stock CreateGang(name[],owner[])