Run time error 4


Započeo Cambio_Operacione, Maj 20, 2021, 14:26:28 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Problem(error/warning): Svaki autorepair izbaci u logu ovo

Deo skripte:

forward Autorepair();
public Autorepair()
{
    for(new i = 0; i <MAX_PLAYERS; i++)
    {
    	if(AdminDuty[i])
    	{
    	    if(PlayerInfo[i][xAdmin] >= 1)
    	    {
            	new Float:health;
            	GetPlayerHealth(i,health);
            	if (health < 98.0)
            	{
            	    SetPlayerHealth(i, 99.0);
            	}
            	new Float:arm;
            	GetPlayerArmour(i,arm);
            	if (arm < 98.0)
            	{
            	    SetPlayerArmour(i, 99.0);
            	}
	        	SetPVarInt(i, "PopravkaVozila", 1);
	        	new Float:vHealth;
	        	new vehicleid = GetPlayerVehicleID(i);
	        	GetVehicleHealth(vehicleid,vHealth);
	        	if(vHealth < 3589.0)
	        	{
      			RepairVehicle(vehicleid);
			SetVehicleHealth( GetPlayerVehicleID( vehicleid ), 3600.0 );
			antiCheatCS[ vehicleid ][ VehRepairTime ] = 3;
			vCanDrive[ GetPlayerVehicleID( vehicleid ) ] = 1;
	        	}
		}
		}
	}
	return 1;
}


Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log):

[13:55:46] [debug] AMX backtrace:
[13:55:46] [debug] #0 0069c8a4 in public Autorepair () from cshp.amx
[13:55:46] [debug] Run time error 4: "Array index out of bounds"
[13:55:46] [debug]  Accessing element at index 311 past array upper bound 49
Poslednja Izmena: Maj 20, 2021, 19:33:06 POSLE PODNE od M Ө M Σ N Z I

forward Autorepair();
public Autorepair()
{
    for(new i = 0; i <MAX_PLAYERS; i++)
    {
    	if(IsPlayerConnected(i))
    	{
	    	if(AdminDuty[i])
	    	{
	    	    if(PlayerInfo[i][xAdmin] >= 1)
	    	    {
	            	new Float:health, Float:arm;
	            	GetPlayerHealth(i,health);
	            	GetPlayerArmour(i,arm);
	            	if(health < 98.0) SetPlayerHealth(i, 99.0);
	            	if(arm < 98.0) SetPlayerArmour(i, 99.0);
		        	SetPVarInt(i, "PopravkaVozila", 1);
		        	new vehicleid = GetPlayerVehicleID(i);
		        	if(vehicleid)
		        	{
			        	new Float:vHealth;
			        	GetVehicleHealth(vehicleid,vHealth);
			        	if(vHealth < 3589.0)
			        	{
			      			RepairVehicle(vehicleid);
							SetVehicleHealth( GetPlayerVehicleID( vehicleid ), 3600.0 );
							antiCheatCS[ vehicleid ][ VehRepairTime ] = 3;
							vCanDrive[ GetPlayerVehicleID( vehicleid ) ] = 1;
			        	}
			        }
				}
			}
		}
	}
	return 1;
}

Nastavio je sa problemom, nenoramlnom brzinom izbacuje u logu error i neprestaje dok nezatvorim

Citat: Cambio_Operacione poslato Maj 20, 2021, 14:48:28 POSLE PODNE
Nastavio je sa problemom, nenoramlnom brzinom izbacuje u logu error i neprestaje dok nezatvorim
Ubaci crashdetect i compiluj sa -d3 parametrom pa salji sta izbacuje u logu

Citat: PazzOnee poslato Maj 20, 2021, 14:49:43 POSLE PODNE
Ubaci crashdetect i compiluj sa -d3 parametrom pa salji sta izbacuje u logu
[14:59:04] [debug] Long callback execution detected (hang or performance issue)
[14:59:04] [debug] AMX backtrace:
[14:59:04] [debug] #0 00009580 in public AMX_OnScriptInit () in cshp.amx
[14:59:04] [debug] #1 00007578 in public Debug_OnScriptInit () in cshp.amx
[14:59:04] [debug] #2 00006f48 in public YVers_OnScriptInit () in cshp.amx
[14:59:04] [debug] #3 000066d0 in public ScriptInit_OnScriptInit () in cshp.amx
[14:59:04] [debug] #4 000063e4 in public SSCANF_OnGameModeInit () in cshp.amx
[14:59:04] [debug] #5 00000754 in public OnGameModeInit () in cshp.amx



[15:02:12] [debug] AMX backtrace:
[15:02:12] [debug] #0 0069c8f4 in public Autorepair () in cshp.amx
[15:02:13] [debug] Run time error 4: "Array index out of bounds"
[15:02:13] [debug]  Attempted to read/write array element at index 845 in array of size 50
[15:02:13] [debug] AMX backtrace:
[15:02:13] [debug] #0 0069c8f4 in public Autorepair () in cshp.amx
[15:02:13] [debug] Long callback execution detected (hang or performance issue)
[15:02:13] [debug] AMX backtrace:
[15:02:13] [debug] #0 00015510 in ?? (0, 33305840, 35089312) in cshp.amx
[15:02:13] [debug] #1 00015e44 in ?? (0, 33305840, 0, 6) in cshp.amx
[15:02:13] [debug] #2 004424f4 in ?? (0) in cshp.amx
[15:02:13] [debug] #3 0046f70c in public ppb_OnPlayerDisconnect (0, 1) in cshp.amx
[15:02:13] [debug] #4 000250c4 in public CB_OnPlayerDisconnect (0, 1) in cshp.amx
[15:02:13] [debug] #5 0001a908 in public Itter_OnPlayerDisconnect (0, 1) in cshp.amx
[15:02:13] [debug] #6 000181c0 in ?? (0, 1) in cshp.amx
[15:02:13] [debug] #7 0000bee8 in public SSCANF_OnPlayerDisconnect (0, 1) in cshp.amx
[15:02:13] [debug] #8 00000868 in public OnPlayerDisconnect (0, 1) in cshp.amx


public OnPlayerUpdate(playerid)
{
    if(AdminDuty[playerid] == 1)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			new Float:HP;
			GetVehicleHealth(GetPlayerVehicleID(playerid), HP);
			if(HP < 999.0)
			{
				RepairVehicle(GetPlayerVehicleID(playerid));
				SetVehicleHealth(GetPlayerVehicleID(playerid), 999.0);
			}
		}
	}
return 1;
}

Galardo

*

mgWhosyGD

Jeste li bolesni?
Provjeravati da li je neko u vozilu svake sekunde?

Citat: Galardo poslato Maj 20, 2021, 16:30:07 POSLE PODNE
Jeste li bolesni?
Provjeravati da li je neko u vozilu svake sekunde?
Skonto sam da je glupo cim sa napisao