[16:32:52] [debug] Run time error 4: "Array index out of bounds"
[16:32:52] [debug] Accessing element at negative index -400
[16:32:52] [debug] Backtrace (most recent call first):
[16:32:52] [debug] #0 public LuX_SpeedoMeterUp()+0x1d5e30 from TalDmMod.amx
Public -
forward LuX_SpeedoMeterUp();
public LuX_SpeedoMeterUp()
{
new Float:LPosX;
new Float:LPosY;
new Float:LPosZ;
new Float:PlayerSpeedDistance;
new value;
new Float:L_VehHealth;
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerSpeedo[i] == 0)
{
GetPlayerPos(i, LPosX, LPosY, LPosZ);
GetPlayerVehicleID(i);
GetVehicleHealth(GetPlayerVehicleID(i), L_VehHealth);
PlayerSpeedDistance = floatsqroot(floatpower(floatabs(floatsub(LPosX,LuX_ReadPlayerPosition[i][ReadX])),2)+floatpower(floatabs(floatsub(LPosY,LuX_ReadPlayerPosition[i][ReadY])),2)+floatpower(floatabs(floatsub(LPosZ,LuX_ReadPlayerPosition[i][ReadZ])),2));
value = floatround(PlayerSpeedDistance * 5000);
new LuxZone[MAX_ZONE_NAME];
GetPlayer2DZone(i, LuxZone, MAX_ZONE_NAME);
LKPH[i] = floatround(value/1000);
format(lstring,sizeof(lstring),"~b~Vehicle: ~w~%s~n~~b~Health: ~w~%.2f~n~~b~Gps: ~w~%s~n~%sKM/H: ~w~~n~%sNitro:",LVehiclesName[GetVehicleModel(GetPlayerVehicleID(i))-400],L_VehHealth,LuxZone,MPH_KPH_Color,MPH_KPH_Color);
TextDrawSetString(LFunc[i], lstring);
TextDrawShowForPlayer(i, LFunc[i]);
LuX_ReadPlayerPosition[i][ReadX] = LPosX, LuX_ReadPlayerPosition[i][ReadY] = LPosY, LuX_ReadPlayerPosition[i][ReadZ] = LPosZ;
}
}
return 1;
}
for(new i = 0; i <= MAX_PLAYERS; i++)
for(new i = 0; i < MAX_PLAYERS; i++)
Run time error 4: "Array index out of bounds"
format(lstring,sizeof(lstring),"~b~Vehicle: ~w~%s~n~~b~Health: ~w~%.2f~n~~b~Gps: ~w~%s~n~%sKM/H: ~w~~n~%sNitro:",LVehiclesName[GetVehicleModel(GetPlayerVehicleID(i))-400],L_VehHealth,LuxZone,MPH_KPH_Color,MPH_KPH_Color);
LVehiclesName[GetVehicleModel(GetPlayerVehicleID(i))-400]
iam sure this line
pawn Код:
or better: this part: pawn Код:
try to add a debug print at the IsPlayerInAnyVehicle() to make sure that the vehicle(model) wont return 0 (cell [0-400] as result). |
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerSpeedo[i] == 0)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInAnyVehicle(i))
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
if(PlayerSpeedo[i] == 0)
{
}
}
}
}
new debug[128];
if(IsPlayerConnected(i))
{
format(debug,sizeof(debug),"Player %d is connected",i);
SendClientMessageToAll(0xaa3333ff,debugstring);
if(IsPlayerInAnyVehicle(i))
{
format(debug,sizeof(debug),"in vehicleid %d",GetPlayerVehicleID(i));
SendClientMessageToAll(0xaa3333ff,debugstring);
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
format(debug,sizeof(debug),"player is driver");
SendClientMessageToAll(0xaa3333ff,debugstring);
if(PlayerSpeedo[i] == 0)
{
}
}
}
}
it's good to do -400, because -
I insert the id of infernus, in the List it's 11, but the model id is 411, so what we need to do is 411-400 = 11, understood ? |