[debug] Run time error 4: "Array index out of bounds"
#1

My error:
https://pastebin.com/GCkDLeWx

LoadProperty Script:
https://pastebin.com/qduXTh9L
Reply
#2

Which lines are 31895 and 1618??
Reply
#3

mysql_get_field("Exitx", result); HouseInfo[i][hExitx] = floatstr(result);
LoadSVehicles();
Reply
#4

Okay the error is clear, you've defined result as "100" which means it has got cells from "0" to "99" and you tried to read data from cell 100 which it doesn't even exist, you can increase the size of result string to 101 or something bigger.. about the LoadSVehicles(); show me the surrounding region around it and show me the function itself.
Reply
#5

function LoadSVehicles() {
new Cache: db = mysql_query (SQL, "SELECT * FROM `svehicles` ORDER BY `svehicles`.`vID` ASC");
new x, servervehs = 0, result[256];
for (new i, j = cache_get_row_count (); i != j; ++i) {
servervehs ++;
cache_get_field_content(i, "vID", result); x = strval(result);
ServerVehicles[x][vID] = x;
cache_get_field_content(i, "vModel", result); ServerVehicles[x][vModel] = strval(result);
cache_get_field_content(i, "LocationX", result); ServerVehicles[x][vLocation][0] = floatstr(result);
cache_get_field_content(i, "LocationY", result); ServerVehicles[x][vLocation][1] = floatstr(result);
cache_get_field_content(i, "LocationZ", result); ServerVehicles[x][vLocation][2] = floatstr(result);
cache_get_field_content(i, "Angle", result); ServerVehicles[x][vAngle] = floatstr(result);
cache_get_field_content(i, "Color1", result); ServerVehicles[x][vColor][0] = strval(result);
cache_get_field_content(i, "Color2", result); ServerVehicles[x][vColor][1] = strval(result);
cache_get_field_content(i, "Faction", result); ServerVehicles[x][vFaction] = strval(result);
cache_get_field_content(i, "Rank", result); ServerVehicles[x][vRank] = strval(result);
cache_get_field_content(i, "Virtual", result); ServerVehicles[x][vVirtual] = strval(result);

if(ServerVehicles[x][vModel] >= 400 && ServerVehicles[x][vModel] <= 611) {
ServerVehicles[x][vSpawned] = CreateVehicleEx(ServerVehicles[x][vModel], ServerVehicles[x][vLocation][0], ServerVehicles[x][vLocation][1], ServerVehicles[x][vLocation][2], ServerVehicles[x][vAngle], ServerVehicles[x][vColor][0], ServerVehicles[x][vColor][1], -1);
new idd = ServerVehicles[x][vSpawned];
SetVehicleVirtualWorld(idd, ServerVehicles[idd][vVirtual]);
if(ServerVehicles[idd][vFaction] != 0) {
if(ServerVehicles[idd][vModel] == 411) {
new policecar = CreateObject(19327, 1534.2373, -1643.2886, 5.9373, -87.6999, 90.4001, -87.1805);
SetObjectMaterialText(policecar, "POLICE", 0, 50, "Arial", 25, 1, -16777216, 0, 1);
new lspdcar = CreateObject(19419,0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000);
AttachObjectToVehicle(policecar, idd, 0.0, -1.9, 0.3, 270.0, 0.0, 0.0);
AttachObjectToVehicle(lspdcar, idd, 0.0646, 0.1661, 0.6957, 0.0000, 0.0000, 0.0000);
}
if(ServerVehicles[idd][vModel] == 560) {
if(ServerVehicles[idd][vFaction] == 12 || ServerVehicles[idd][vFaction] == 13) {
new taiddiobj = CreateObject(19308, 0.00000, 0.00000, 0.00000,0.00000, 0.00000, 0.00000);
AttachObjectToVehicle(taiddiobj, idd, -0.00930, -0.23880, 0.92300,0.00000, 0.00000, 0.00000);
}
}
if(ServerVehicles[idd][vModel] == 541) {
if(ServerVehicles[idd][vFaction] == 2) {
new object1 = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
new object2 = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(object1, idd, 0.375000,0.524999,0.375000,0.000000,0.000000,0.000 000);
AttachObjectToVehicle(object2, idd, 0.375000,0.524999,0.375000,0.000000,0.000000,0.000 000);
}
}
if(ServerVehicles[idd][vModel] == 525) {
new object1 = CreateObject(19294, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
new object2 = CreateObject(19294, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(object1, idd, -0.600000,-0.485000,1.450000,0.000000,0.000000,0.000000);
AttachObjectToVehicle(object2, idd, 0.600000,-0.485000,1.450000,0.000000,0.000000,0.000000);
}
}

new str[64];
if(ServerVehicles[idd][vFaction] != 0) format(str, 64, "F%d %d", ServerVehicles[idd][vFaction], idd);
else format(str, sizeof(str), "RO-0%d", ServerVehicles[x][vSpawned]);
SetVehicleNumberPlate(idd, str);
}
}
printf("Server vehicles: %d", servervehs);
cache_delete(db);
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)