Run time error 4: "Array index out of bounds" sscanf -
TheNerka - 05.09.2014
Код:
[22:20:48] [debug] Run time error 4: "Array index out of bounds"
[22:20:48] [debug] Accessing element at index 100 past array upper bound 99
[22:20:48] [debug] AMX backtrace:
[22:20:48] [debug] #0 00032a78 in public cmd_createfuelstation () from server.amx
[22:20:48] [debug] #1 native CallLocalFunction () [00472e50] from samp-server.exe
[22:20:48] [debug] #2 00008618 in public OnPlayerCommandText () from server.amx
my error cmd:
Код:
CMD:createfuelstation(playerid, params[])
{
new unit, string[128];
if(sscanf(params, "d", unit)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /createfuelstation [UnitPrice]");
else if(PlayerData[playerid][AdminLevel] < 4) return SendUnathorizedMessage(playerid);
new id = SpawnedFuels++;
new Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);
Fuels[id][FSX] = X;
Fuels[id][FSY] = Y;
Fuels[id][FSZ] = Z ;
Fuels[id][FSUnitPrice] = unit;
mysql_format(Mysql_users, query, sizeof(query), "INSERT INTO `"DEGALINES_LENTELE"` (`FSPickupID`, `FSX`, `FSY`, `FSZ`, `FSUnitPrice`) VALUES ('%i', '%f', '%f', '%f', '%i')", id, X, Y, Z, unit);
mysql_tquery(Mysql_users, query, "", "");
Fuels[id][FSPickupID] = CreateDynamicPickup(1650, 23, X, Y, Z+1, 0, -1, -1, 150.0);
format(string, sizeof(string), "You have created a fuel station(ID: %d) and set the unit price to %d (X = %f | Y = %f | Z = %f).",id, unit, X, Y, Z);
SendClientMessage(playerid, -1, string);
return 1;
}
Re: Run time error 4: "Array index out of bounds" sscanf -
TheNerka - 06.09.2014
help
Re: Run time error 4: "Array index out of bounds" sscanf -
Battlezone - 06.09.2014
Try increasing this string size
Re: Run time error 4: "Array index out of bounds" sscanf -
Stinged - 06.09.2014
One of these 2 might fix the problem:
1) Increase the size of 'string'
2) Increase the size of 'query'
Re: Run time error 4: "Array index out of bounds" sscanf -
TheNerka - 06.09.2014
doesn't work
Код:
[22:20:48] [debug] Run time error 4: "Array index out of bounds"
[22:20:48] [debug] Accessing element at index 100 past array upper bound 99
[22:20:48] [debug] AMX backtrace:
[22:20:48] [debug] #0 00032a78 in public cmd_createfuelstation () from server.amx
[22:20:48] [debug] #1 native CallLocalFunction () [00472e50] from samp-server.exe
[22:20:48] [debug] #2 00008618 in public OnPlayerCommandText () from server.amx
Re: Run time error 4: "Array index out of bounds" sscanf -
IstuntmanI - 06.09.2014
You have too many fuel stations and the array is not that big. Add an error which tells you when you reached the max fuel stations:
pawn Код:
if((SpawnFuels + 1) >= sizeof Fuels) return SendClientMessage(playerid, -1, "There are too many fuel stations !" );
and then try increasing Fuels' array size.
Re: Run time error 4: "Array index out of bounds" sscanf -
TheNerka - 06.09.2014
if im send cmd /createfuelstation 2 // 2 is cost 1 liter $2
im got error: uknown command
or im send cmd /createfuelstation
got SYNTAX: /createfuelstation [UnitPrice]