17.08.2012, 19:16
Hello everybody! Today I put crashdetect.dll plugin to my server to check errors. And I get this error in server-log file:
This happens in this code, because if I coment this callback called "Kuro" I don't see errors. Take that code:
Can anyone say there is the problem, because I can't find it here.
Код:
[22:24:35] [debug] Run time error 4: "Array index out of bounds" [22:24:35] [debug] Accessing element at negative index -400 [22:24:35] [debug] AMX backtrace: [22:24:35] [debug] #0 0000cff4 in ?? () from SAMP.amx [22:24:35] [debug] #1 001bb3d8 in public Kuro () from SAMP.amx
Код:
new Float:TrDegalai[MAX_VEHICLES];//In top of my gm.
forward Kuro();
public Kuro()
{
for(new vehicleid=0; vehicleid<MAX_VEHICLES; vehicleid++)
{
printf("Vehicleid %d",vehicleid);
if(ArNaudojaDegalus(vehicleid))
{
if(GetVehicleBakas(vehicleid) >= 30 && GetVehicleBakas(vehicleid) <= 200)
{
switch(random(10))
{
case 0: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-20;
case 1: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-18;
case 2: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-14;
case 3: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-2;
case 4: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-10;
case 5: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-15;
case 6: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-16;
case 7: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-7;
case 8: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-5;
case 9: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-11;
}
}
else if(GetVehicleBakas(vehicleid) > 200 && GetVehicleBakas(vehicleid) <= 2000)
{
switch(random(10))
{
case 0: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-150;
case 1: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-100;
case 2: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-89;
case 3: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-20;
case 4: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-28;
case 5: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-40;
case 6: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-120;
case 7: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-169;
case 8: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-57;
case 9: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-66;
}
}
else if(GetVehicleBakas(vehicleid) > 2000)
{
switch(random(10))
{
case 0: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-800;
case 1: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-950;
case 2: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-156;
case 3: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-789;
case 4: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-500;
case 5: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-658;
case 6: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-123;
case 7: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-169;
case 8: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-57;
case 9: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-648;
}
}
else if(GetVehicleBakas(vehicleid) < 30)
{
switch(random(10))
{
case 0: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-4;
case 1: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-5;
case 2: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-1;
case 3: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-2;
case 4: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-3;
case 5: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-1;
case 6: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-4;
case 7: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-3;
case 8: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-2;
case 9: TrDegalai[vehicleid] = GetVehicleBakas(vehicleid)-1;
}
}
}
}
return 1;
}

