debug help..
#1

Am getting a array upper bound 199 AMX backtrace


here is the debugs its not just one i get alot of this below..
Код:
[19:56:29] [debug] #0 00033bcc in public UpdateDashCam () from IGRP.amx
[19:56:29] [debug] Run time error 4: "Array index out of bounds"
[19:56:29] [debug]  Accessing element at index 65535 past array upper bound 199
[19:56:29] [debug] AMX backtrace:
public updatedashcam
Код:
public UpdateDashCam(playerid)
{
	if(!IsPlayerInAnyVehicle(playerid)) return 0x0;
	if(IsACopCar(playerid))
	{
		new pcv = GetNearestVehicle(playerid, dcam_Distance);
		new pvid = GetPlayerVehicleID(playerid);
		new Float:vPos[3];
		GetVehiclePos(pvid, vPos[0], vPos[1], vPos[2]);
		new Float:distance = GetVehicleDistanceFromPoint(pcv, vPos[0], vPos[1], vPos[2]);
		new Float:speed = GetVehicleSpeed(pcv, 0);
		new string[40];
		if(floatround(distance) <= dcam_Distance - 5.0)
		{
            format(string, sizeof(string), "P %s~n~S %d kmph~n~D %d m", VehicleNumberPlate[pcv], floatround(speed), floatround(distance));
		}
		else format(string, sizeof(string), "P N/A~n~S N/A kmph~n~D N/A m");
        PlayerTextDrawSetString(playerid, pDashCam[playerid], string);
	}
    return 0x1;
}
Reply
#2

Which one of your arrays has [200] set for the max? Looking at your code, I am presuming it's either VehicleNumberPlate or pDashCam.

pawn Код:
format(string, sizeof(string), "P %s~n~S %d kmph~n~D %d m", VehicleNumberPlate[pcv], floatround(speed), floatround(distance));
        }
        else format(string, sizeof(string), "P N/A~n~S N/A kmph~n~D N/A m");
        PlayerTextDrawSetString(playerid, pDashCam[playerid], string);
I think this is where your problem is. Do some printfs and print out playerid, pcv and pvid, and see which one returns the 65535. If pcv is the one (I have a feeling it is), it's a problem with your GetNearestVehicle() function, it is somehow returning 65535.

Keep in mind that CreateVehicle and AddStaticVehicle return 65535 if the car was not created for whatever reason (vehicle limit reached or invalid vehicle model ID passed), which I think is your main overall problem here. You're trying to access vehicle ID 65535, you saved it to a variable somewhere with CreateVehicle and AddStaticVehicle, and your code is trying to look at array element 65535 in an array with only 200 entries.
Reply
#3

Actually, it passed in the array an invalid vehicle id which is 65535 by default. Like the user above said, check where the max value of the array is 200 and check where it passes values to it. Debugging also your code is helpful, you're going to see the values it inserts.
Reply
#4

Well this system was not created by me it was made by my friend Vyper the VehicleNumberPlate is a issue as well but i cant see it being that tbh.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)