[18:18:49] [debug] Run time error 4: "Array index out of bounds" [18:18:49] [debug] Attempted to read/write array element at index 1032 in array of size 996 [18:18:49] [debug] AMX backtrace: [18:18:49] [debug] #0 0001de20 in public cmd_ocreate (2, 347436) in AdminSys.amx [18:18:49] [debug] #1 native CallLocalFunction () in sampsvr-port_177 [18:18:49] [debug] #2 000006d8 in public OnPlayerCommandText (2, 347380) in AdminSys.amx
CMD:ocreate(playerid, params[]) { if(PlayerInfo[playerid][Level]<3) return SendClientMessage(playerid, COLOR_RED, "SERVER: You're not allowed to use this command"); new objectid; if(sscanf(params,"d", objectid)) return SendClientMessage(playerid,COLOR_RED,"Usage:/ocreate [object id]"); if(objectid < 321 || objectid > 19999) return SendClientMessage(playerid,COLOR_RED,"SERVER: Object ID not found."); { objects++; objectsid[objects]=objectid; new Float:X, Float:Y, Float:Z, str[128]; GetPlayerPos(playerid, X, Y, Z); SpawnedObject[objects] = CreateDynamicObject(objectid, X, Y, Z+1, 0, 0, 0); ObjectSpawned[SpawnedObject[objects]] = 1; format(str, 128, "SERVER: Object ID: %d - Created at your location - Index: %d", objectid, objects); SendClientMessage(playerid, COLOR_RED, str); } return 1; }
[18:18:49] [debug] Attempted to read/write array element at index 1032 in array of size 996
new SpawnedObject[999]; new ObjectSpawned[999];
Just increase 999 to higher value. You need at least 1032. It's not even ysi related.
|
CMD:ocreate(playerid, params[])
{
if(PlayerInfo[playerid][Level]<3) return SendClientMessage(playerid, COLOR_RED, "SERVER: You're not allowed to use this command");
new objectid;
if(sscanf(params,"d", objectid)) return SendClientMessage(playerid,COLOR_RED,"Usage:/ocreate [object id]");
if(objectid < 321 || objectid > 19999) return SendClientMessage(playerid,COLOR_RED,"SERVER: Object ID not found.");
{
objects++;
objectsid[objects]=objectid;
new Float:X, Float:Y, Float:Z, str[128];
GetPlayerPos(playerid, X, Y, Z);
SpawnedObject[objects] = CreateDynamicObject(objectid, X, Y, Z+1, 0, 0, 0);
ObjectSpawned[SpawnedObject[objects]] = 1; // <----- this line
format(str, 128, "SERVER: Object ID: %d - Created at your location - Index: %d", objectid, objects);
SendClientMessage(playerid, COLOR_RED, str);
}
return 1;
}
I found the line if i remove the line the command works
any ideas what should i do to replace it with something else? PHP Code:
|
SpawnedObject[objects] = CreateDynamicObject(objectid, X, Y, Z+1, 0, 0, 0); ObjectSpawned[SpawnedObject[objects]] = 1; // <----- this line