23.05.2015, 11:49
Hi all as the title says I have run time error 4 in my script
where is the red color there is the problem. IDK what is
there is my stock for the vehicle names:
Please help. rep+
Код:
Run time error 4: "Array index out of bounds" [23/05/2015 14:42:32] [debug] Accessing element at negative index -400 [23/05/2015 14:42:32] [debug] AMX backtrace: [23/05/2015 14:42:32] [debug] #0 00007970 in ?? (0) from BulgEdition.amx [23/05/2015 14:42:32] [debug] #1 0000b4f8 in public OnPlayerThings (0) from BulgEdition.amx
Код:
public OnPlayerThings(playerid) { new string[500], vehicleid = GetPlayerVehicleID(playerid), Float:vX, Float:vY, Float: vZ; GetVehiclePos(vehicleid, vX, vY, vZ); format(string, sizeof(string), "Speed: %s~n~Health: %d~n~Fuel: 100/100 l", GetVehicleSpeed(vehicleid, KMPH), GetVehicleHP(vehicleid)); if(IsBoat(vehicleid) || IsPlane(vehicleid) || IsChopper(vehicleid)) { format(string, sizeof(string), "Speed: %s~n~Health: %d~n~Fuel: 100/100 l", GetVehicleSpeed(vehicleid, KNOTS), GetVehicleHP(vehicleid)); } if(IsPlane(vehicleid) || IsChopper(vehicleid)) { format(string, sizeof(string), "Speed: %s~n~Health: %d~n~Fuel: 100/100 l~n~Height: %.0f", GetVehicleSpeed(vehicleid, KNOTS), GetVehicleHP(vehicleid), vZ); } TextDrawSetString(Draw[playerid][2], string); format(string, sizeof(string), "%s", GetVehicleName(vehicleid)); TextDrawSetString(Draw[playerid][1], string); return 1; }
there is my stock for the vehicle names:
Код:
stock GetVehicleName(vehicleid) { new string[123]; format(string, sizeof(string), "%s", VehicleNames[(GetVehicleModel(vehicleid) - 400)]); return string; }