I Need QUICK HELP Fixing These Errors
#1

I Am Using CrashDetect Plugins And I Got Some Errors In The Server Log
Here is Errors
Код:
[17:07:04]   crashdetect v4.8.5 is OK.
[17:09:26] [debug] Run time error 4: "Array index out of bounds"
[17:09:26] [debug]  Accessing element at index 65535 past array upper bound 999
[17:09:26] [debug] AMX backtrace:
[17:09:26] [debug] #0 0005ec84 in public FC_OnPlayerDeath () from cod8aawv1.1.amx
[17:09:26] [debug] #1 native CallLocalFunction () [00474110] from samp-server.exe
[17:09:26] [debug] #2 00003984 in public OnPlayerDeath () from cod8aawv1.1.amx
[17:09:50] [debug] Run time error 4: "Array index out of bounds"
[17:09:50] [debug]  Accessing element at index 65535 past array upper bound 999
[17:09:50] [debug] AMX backtrace:
[17:09:50] [debug] #0 0005ee4c in public OnPlayerTakeDamage () from cod8aawv1.1.amx
[17:10:24] [debug] Run time error 4: "Array index out of bounds"
[17:10:24] [debug]  Accessing element at index 65535 past array upper bound 999
[17:10:24] [debug] AMX backtrace:
[17:10:24] [debug] #0 0005ee4c in public OnPlayerTakeDamage () from cod8aawv1.1.amx
[17:10:41] [debug] Run time error 4: "Array index out of bounds"
[17:10:41] [debug]  Accessing element at index 65535 past array upper bound 999
[17:10:41] [debug] AMX backtrace:
[17:10:41] [debug] #0 0005ee4c in public OnPlayerTakeDamage () from cod8aawv1.1.amx
[17:10:41] [debug] Run time error 4: "Array index out of bounds"
[17:10:41] [debug]  Accessing element at index 65535 past array upper bound 999
[17:10:41] [debug] AMX backtrace:
[17:10:41] [debug] #0 0005ec84 in public FC_OnPlayerDeath () from cod8aawv1.1.amx
[17:10:41] [debug] #1 native CallLocalFunction () [00474110] from samp-server.exe
[17:10:41] [debug] #2 00003984 in public OnPlayerDeath () from cod8aawv1.1.amx
[17:10:41] [debug] Run time error 4: "Array index out of bounds"
[17:10:41] [debug]  Accessing element at index 65535 past array upper bound 999
[17:10:41] [debug] AMX backtrace:
[17:10:41] [debug] #0 0005ee4c in public OnPlayerTakeDamage () from cod8aawv1.1.amx
Please Help Me Fixing Both OnPlayerdeath And onplayertakedamage

Here is mine Onplayertakedamage
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
	if(gTeam[issuerid] == gTeam[playerid])
	{
	   	GameTextForPlayer(issuerid,"~r~Don't attack your team mates!", 3000, 3);
	}
	if(issuerid != INVALID_PLAYER_ID)
	{
	  	new str[26];
	  	format(str, sizeof(str),"-%.0f", amount);
      	SetPlayerChatBubble(playerid, str, 0xFF0000FF, 100.0, 2000);
      	PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
	}
	if(PlayerInfo[playerid][OnDuty] == 1 || PlayerInfo[playerid][God] == 1)
	{
		SetPlayerHealth(playerid, 1000.0);
		GameTextForPlayer(issuerid,"~r~Don't attack admins on-duty!", 3000, 3);
	}
    return 1;
}
Here Is Mine Onplayerdeath
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(DuelActive == true)
 {DuelActive = false;
  if(killerid != INVALID_PLAYER_ID && killerid != playerid)
   {new cName[32],tName[32],string[128];
    GetPlayerName(playerid,cName,sizeof(cName));
    GetPlayerName(killerid,tName,sizeof(tName));
    format(string,sizeof(string),"%s(%i) has won the duel against %s(%i) and has been given $%i as the reward",tName,killerid,cName,playerid,WinningPrice);
    SendClientMessageToAll(0xFF9900FF,string);
    SetPlayerInterior(killerid,0);
    SpawnPlayer(killerid);
    GivePlayerMoney(killerid,WinningPrice);}
  WinningPrice = 0;}
        Update3DTextLabelText(RankLabel[playerid], 0xFFFFFFFF, " ");
        if(Captured[playerid][SNAKE] == 0 && IsPlayerCapturing[playerid][SNAKE] == 1)
        {
			LeavingSnakeFarm(playerid);
		}
		if(Captured[playerid][BAY] == 0 && IsPlayerCapturing[playerid][BAY] == 1)
        {
			LeavingBay(playerid);
		}
		if(Captured[playerid][BIG] == 0 && IsPlayerCapturing[playerid][BIG] == 1)
		{
			LeavingEar(playerid);
		}
		if(Captured[playerid][ARMY] == 0 && IsPlayerCapturing[playerid][ARMY] == 1)
		{
			LeavingArmy(playerid);
		}
		if(Captured[playerid][PETROL] == 0 && IsPlayerCapturing[playerid][PETROL] == 1)
		{
			LeavingPetrol(playerid);
		}
		if(Captured[playerid][OIL] == 0 && IsPlayerCapturing[playerid][OIL] == 1)
		{
			LeavingOil(playerid);
		}
		if(Captured[playerid][DESERT] == 0 && IsPlayerCapturing[playerid][DESERT] == 1)
		{
			LeavingDesert(playerid);
		}
		if(Captured[playerid][QUARRY] == 0 && IsPlayerCapturing[playerid][QUARRY] == 1)
		{
			LeavingQuarry(playerid);
		}
		if(Captured[playerid][GUEST] == 0 && IsPlayerCapturing[playerid][GUEST] == 1)
		{
			LeavingGuest(playerid);
		}
		if(Captured[playerid][EAR] == 0 && IsPlayerCapturing[playerid][EAR] == 1)
		{
			LeavingEar(playerid);
		}
		if(Captured[playerid][AIRPORT] == 0 && IsPlayerCapturing[playerid][AIRPORT] == 1)
		{
			LeavingAirport(playerid);
		}
		if(Captured[playerid][SHIP] == 0 && IsPlayerCapturing[playerid][SHIP] == 1)
		{
			LeavingShip(playerid);
		}
		if(Captured[playerid][GAS] == 0 && IsPlayerCapturing[playerid][GAS] == 1)
		{
			LeavingGas(playerid);
		}
		if(Captured[playerid][RES] == 0 && IsPlayerCapturing[playerid][RES] == 1)
		{
			LeavingRes(playerid);
		}
		/*if(Captured[playerid][NPP] == 0 && IsPlayerCapturing[playerid][NPP] == 1)
		{
			LeavingNuclear(playerid);
		}*/
		if(Captured[playerid][MOTEL] == 0 && IsPlayerCapturing[playerid][MOTEL] == 1)
		{
			LeavingMOTEL(playerid);
		}
		if(Captured[playerid][BATTLESHIP] == 0 && IsPlayerCapturing[playerid][BATTLESHIP] == 1)
		{
			LeavingBattleShip(playerid);
		}
		if(Captured[playerid][HOSPITAL] == 0 && IsPlayerCapturing[playerid][HOSPITAL] == 1)
		{
			LeavingHospital(playerid);
		}
		if(IsPlayerInArea(playerid, -353.515625,2574.21875,-113.28125,2796.875))
		{
			if(gTeam[playerid] == TEAM_USA)
			{
				if(IsPlayerInAnyVehicle(killerid))
				{
					if(GetVehicleModel(GetPlayerVehicleID(killerid)) == 432 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 520 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 425)
					{
						SetPlayerHealth(killerid, 0.0);
						new str[100];
						format(str, sizeof(str),"%s has been killed for spawn killing!", PlayerName2(killerid));
						SendClientMessageToAll(red, str);
					}
				}
			}
		}
		if(IsPlayerInArea(playerid, 994.1957, 1817.512, 1185.533, 2049.596))
		{
			if(gTeam[playerid] == TEAM_PAKISTAN)
			{
				if(IsPlayerInAnyVehicle(killerid))
				{
					if(GetVehicleModel(GetPlayerVehicleID(killerid)) == 432 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 520 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 425)
					{
						SetPlayerHealth(killerid, 0.0);
						new str[100];
						format(str, sizeof(str),"%s has been killed for spawn killing!", PlayerName2(killerid));
						SendClientMessageToAll(red, str);
					}
				}
			}
		}
		if(IsPlayerInArea(playerid, -1599.869, 2545.777, -1389.667, 2697.589))
		{
			if(gTeam[playerid] == TEAM_NEPAL)
			{
				if(IsPlayerInAnyVehicle(killerid))
				{
					if(GetVehicleModel(GetPlayerVehicleID(killerid)) == 432 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 520 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 425)
					{
						SetPlayerHealth(killerid, 0.0);
						new str[100];
						format(str, sizeof(str),"%s has been killed for spawn killing!", PlayerName2(killerid));
						SendClientMessageToAll(red, str);
					}
				}
			}
		}
		if(IsPlayerInArea(playerid, -309.375,1024.21875,103.125,1211.71875))
		{
			if(gTeam[playerid] == TEAM_CHINA)
			{
				if(IsPlayerInAnyVehicle(killerid))
				{
					if(GetVehicleModel(GetPlayerVehicleID(killerid)) == 432 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 520 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 425)
					{
						SetPlayerHealth(killerid, 0.0);
						new str[100];
						format(str, sizeof(str),"%s has been killed for spawn killing!", PlayerName2(killerid));
						SendClientMessageToAll(red, str);
					}
				}
			}
		}
		if(IsPlayerInArea(playerid, -875.8406, 1389.667, -607.2495, 1623.225))
		{
			if(gTeam[playerid] == TEAM_INDIA)
			{
				if(IsPlayerInAnyVehicle(killerid))
				{
					if(GetVehicleModel(GetPlayerVehicleID(killerid)) == 432 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 520 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 425)
					{
						SetPlayerHealth(killerid, 0.0);
						new str[100];
						format(str, sizeof(str),"%s has been killed for spawn killing!", PlayerName2(killerid));
						SendClientMessageToAll(red, str);
					}
				}
			}
		}
		if(IsPlayerInArea(playerid, -1628.90625,2513.671875,-1417.96875,2730.46875))
		{
			if(gTeam[playerid] == TEAM_DUBAI)
			{
				if(IsPlayerInAnyVehicle(killerid))
				{
					if(GetVehicleModel(GetPlayerVehicleID(killerid)) == 432 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 520 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 425)
					{
						SetPlayerHealth(killerid, 0.0);
						new str[100];
						format(str, sizeof(str),"%s has been killed for spawn killing!", PlayerName2(killerid));
						SendClientMessageToAll(red, str);
					}
				}
			}
		}
		if(IsPlayerInArea(playerid, 1007.8125,-1371.09375,1212.890625,-1201.171875))
		{
			if(gTeam[playerid] == TEAM_ML)
			{
				if(IsPlayerInAnyVehicle(killerid))
				{
					if(GetVehicleModel(GetPlayerVehicleID(killerid)) == 432 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 520 || GetVehicleModel(GetPlayerVehicleID(killerid)) == 425)
					{
						SetPlayerHealth(killerid, 0.0);
						new str[100];
						format(str, sizeof(str),"%s has been killed for spawn killing!", PlayerName2(killerid));
						SendClientMessageToAll(red, str);
					}
				}
			}
		}
		SendDeathMessage(killerid, playerid, reason);
		GivePlayerMoney(killerid, 256);
		//---------
		SendClientMessage(killerid, -1, "You killed your enemy. You got 256$ and {00FF22}+1 Score. {FFFFFF}You got some ammo for your current weapon");
		new weaponid = GetPlayerWeapon(killerid);
		switch(weaponid)
		{
			case 2 .. 15: GivePlayerWeapon(killerid, GetPlayerWeapon(killerid), 1);
			case  16 .. 18: GivePlayerWeapon(killerid, GetPlayerWeapon(killerid), 1);
			case 22 .. 32: GivePlayerWeapon(killerid, GetPlayerWeapon(killerid), 60);
			case 35 .. 46: GivePlayerWeapon(killerid, GetPlayerWeapon(killerid), 1);
		}
		SetPlayerScore(killerid, GetPlayerScore(killerid) +1);
        Streak[playerid] = 0;
        if(killerid != INVALID_PLAYER_ID)
        {
            	new text[128];
                Streak[killerid] ++;
                if(Streak[killerid] == 3)
                {
                    	format(text, sizeof(text), "%s is is on (3 killing spree)!", PlayerName2(killerid));
                    	SendClientMessageToAll(orange, text);
                        SendClientMessage(killerid, lightblue, "You get $1500 and +2 score! (killing spree bonus)");
                        GivePlayerMoney(playerid, 1500);
                        GivePlayerScore(playerid, 2);
                }
                if(Streak[killerid] == 5)
                {
                    	format(text, sizeof(text), "%s is is on (5 killing spree)!", PlayerName2(killerid));
                        SendClientMessageToAll(orange, text);
                        SendClientMessage(killerid, lightblue, "You get $2500 and +3 score! (killing spree bonus)");
                        GivePlayerMoney(playerid, 2500);
                        GivePlayerScore(playerid, 3);
                }
                if(Streak[killerid] == 10)
                {
                    	format(text, sizeof(text), "%s is on (10 killing spree)!", PlayerName2(killerid));
                        SendClientMessageToAll(orange, text);
                        SendClientMessage(killerid, lightblue, "You get $5000 and +4 score! (killing spree bonus)");
                        GivePlayerMoney(playerid, 5000);
                        GivePlayerScore(playerid, 4);
                }
                if(Streak[killerid] == 15)
                {
                    	format(text, sizeof(text), "%s is is on (15 killing spree)!", PlayerName2(killerid));
                        SendClientMessageToAll(orange, text);
                        SendClientMessage(killerid, lightblue, "You get $7 500 and +6 score! (killing spree bonus)");
                        GivePlayerMoney(playerid, 7500);
                        GivePlayerScore(playerid, 6);
                }
                if(Streak[killerid] == 20)
                {
                    	format(text, sizeof(text), "%s is is on (20 killing spree)!", PlayerName2(killerid));
                        SendClientMessageToAll(orange, text);
                        SendClientMessage(killerid, lightblue, "You get $12 500 and +10 score! (killing spree bonus)");
                        GivePlayerMoney(playerid, 12500);
                        GivePlayerScore(playerid, 10);
                }
                if(Streak[killerid] == 25)
                {
                    	format(text, sizeof(text), "%s is is on (25 killing spree)!", PlayerName2(killerid));
                        SendClientMessageToAll(orange, text);
                        SendClientMessage(killerid, lightblue, "You get $20 000 and +15 score! (killing spree bonus)");
                        GivePlayerMoney(playerid, 20000);
                        GivePlayerScore(playerid, 15);
                }
                if(Streak[killerid] == 50)
                {
                    	format(text, sizeof(text), "%s is on (50 killing spree)!", PlayerName2(killerid));
                        SendClientMessageToAll(orange, text);
                        SendClientMessage(killerid, lightblue, "You get $50 000 and +20 score! (killing spree bonus)");
                        GivePlayerMoney(playerid, 50000);
                        GivePlayerScore(playerid, 20);
                }
                if(Streak[killerid] == 100)
                {
                    	format(text, sizeof(text), "%s is on (100 killing spree)!", PlayerName2(killerid));
                        SendClientMessageToAll(orange, text);
                        SendClientMessage(killerid, lightblue, "You get $1 00 000 and +20 score! (killing spree bonus)");
                        GivePlayerMoney(playerid, 100000);
                        GivePlayerScore(playerid, 20);
                }
        }
	    Anti_heal[playerid] = 0;
	    Anti_Give[playerid] = 0;
	    PlayerInfo[playerid][Deaths] ++;
	    PlayerInfo[killerid][Kills] ++;

		#if defined ENABLE_SPEC
		for(new x=0; x<MAX_PLAYERS; x++)
		    if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && PlayerInfo[x][SpecID] == playerid)
		       AdvanceSpectate(x);
		#endif
		return 1;
}
Reply
#2

change the sixe of variable str in onplayertakedamage from 26 to higher value for eg 70
Reply
#3

Once again, not checking if killerid/issuerid is valid before using it as an array index. In OnPlayerTakeDamage it's abundantly clear because it's literally the first line in that callback. In OnPlayerDeath less so because that callback is a complete mess. It's there somewhere, I just can't be bothered to pinpoint it for you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)