index 65535
#1

Hey all...
I have improved based script a lot, after this i opened my private server for friends and we were about 10 people and then the server restarted and i checked the server log and found this (I run crashdetect with the server)
as i understand i think its something with INVALID_PLAYER_ID


Код:
[14:32:45] [debug] Run time error 4: "Array index out of bounds"
[14:32:45] [debug]  Accessing element at index 65535 past array upper bound 500
[14:32:45] [debug] AMX backtrace:
[14:32:45] [debug] #0 0005b3d0 in public OnPlayerDeath () from CGRP.amx
here Public OnPlayerDeath()

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(IsPlayerConnected(killerid))
	{
		new hour,minute,second, weaponname[32];
		gettime(hour,minute,second);
		FixHour(hour);
		hour = shifthour;
		GetWeaponName(reason, weaponname, sizeof(weaponname));
		format(PlayerInfo[playerid][pKillLog9], 256, "%s", PlayerInfo[playerid][pKillLog8]);
		format(PlayerInfo[playerid][pKillLog8], 256, "%s", PlayerInfo[playerid][pKillLog7]);
		format(PlayerInfo[playerid][pKillLog7], 256, "%s", PlayerInfo[playerid][pKillLog6]);
		format(PlayerInfo[playerid][pKillLog6], 256, "%s", PlayerInfo[playerid][pKillLog5]);
		format(PlayerInfo[playerid][pKillLog5], 256, "%s", PlayerInfo[playerid][pKillLog4]);
		format(PlayerInfo[playerid][pKillLog4], 256, "%s", PlayerInfo[playerid][pKillLog3]);
		format(PlayerInfo[playerid][pKillLog3], 256, "%s", PlayerInfo[playerid][pKillLog2]);
		format(PlayerInfo[playerid][pKillLog2], 256, "%s", PlayerInfo[playerid][pKillLog1]);
		format(PlayerInfo[playerid][pKillLog1], 256, "%s", PlayerInfo[playerid][pKillLog0]);
	 	format(PlayerInfo[playerid][pKillLog0], 256, "(%d:%d:%d) %s killed me with %s", hour,minute,second,GetPlayerNameEx(killerid), weaponname);

	 	format(PlayerInfo[killerid][pKillLog9], 256, "%s", PlayerInfo[killerid][pKillLog8]);
		format(PlayerInfo[killerid][pKillLog8], 256, "%s", PlayerInfo[killerid][pKillLog7]);
		format(PlayerInfo[killerid][pKillLog7], 256, "%s", PlayerInfo[killerid][pKillLog6]);
		format(PlayerInfo[killerid][pKillLog6], 256, "%s", PlayerInfo[killerid][pKillLog5]);
		format(PlayerInfo[killerid][pKillLog5], 256, "%s", PlayerInfo[killerid][pKillLog4]);
		format(PlayerInfo[killerid][pKillLog4], 256, "%s", PlayerInfo[killerid][pKillLog3]);
		format(PlayerInfo[killerid][pKillLog3], 256, "%s", PlayerInfo[killerid][pKillLog2]);
		format(PlayerInfo[killerid][pKillLog2], 256, "%s", PlayerInfo[killerid][pKillLog1]);
		format(PlayerInfo[killerid][pKillLog1], 256, "%s", PlayerInfo[killerid][pKillLog0]);
	 	format(PlayerInfo[killerid][pKillLog0], 256, "(%d:%d:%d) Killed %s with %s", hour,minute,second,GetPlayerNameEx(playerid), weaponname);
	 	if(GetPVarInt(killerid, "IsInArena") == 0) PlayerInfo[killerid][pDMKills]++;
	}

	new string[128];
	GameTextForPlayer(playerid, "~r~Wasted", 1000, 2);
	pTazer[playerid] = 0;
	InsideShamal[playerid] = INVALID_VEHICLE_ID;
	DisablePlayerCheckpoint(playerid);
	DeletePVar(playerid, "SpeedRadar");
    DeletePVar(playerid, "UsingSprunk");
    KillTimer(GetPVarInt(playerid, "firstaid5"));
  	DeletePVar(playerid, "usingfirstaid");
	if(GetPVarInt(playerid, "MovingStretcher") != -1)
	{
	    KillTimer(GetPVarInt(playerid, "TickEMSMove"));
	    DeletePVar(GetPVarInt(playerid, "MovingStretcher"), "OnStretcher");
	    SetPVarInt(playerid, "MovingStretcher", -1);
	}

	new caller = Mobile[playerid];
	if(IsPlayerConnected(Mobile[playerid]))
	{
		SendClientMessageEx(caller,  COLOR_GRAD2, "The line went dead.");
		format(string, sizeof(string), "* %s puts away their cellphone.", GetPlayerNameEx(caller));
		ProxDetector(30.0, caller, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		CellTime[caller] = 0;
		Mobile[caller] = INVALID_PLAYER_ID;
	}
	Mobile[playerid] = INVALID_PLAYER_ID;
	CellTime[playerid] = 0;
	RingTone[playerid] = 0;

	foreach(Player, i)
	{
		if(EMSAccepted[i] < 999)
		{
 			if(EMSAccepted[i] == playerid)
   			{
     			EMSAccepted[i] = 999;
       			GameTextForPlayer(i, "~w~EMS Caller~n~~r~Has Died", 5000, 1);
	        	EMSCallTime[i] = 0;
	        	DisablePlayerCheckpoint(i);
			}
		}
	}
	
	if(C4RobStatus[playerid] >= 1)
	{
		RemovePlayerAttachedObject(playerid, 8);
		DisablePlayerCheckpoint(playerid);
		C4RobStatus[playerid] = 0;
		C4Robberypossible = 0;
		format(string, sizeof(string), "Due of your death, the C4 Robbery attempt has failed.");
		SendClientMessage(playerid, COLOR_LIGHTRED, string);
		C4RobberyLoop = SetTimer("C4RobberyBreak", 65000, false);
		return 1;
	}
	
	
	if(RobberyStatus[playerid] >= 1)
	{
		RemovePlayerAttachedObject(playerid, 9);
		DisablePlayerCheckpoint(playerid);
		RobberyStatus[playerid] = 0;
		format(string, sizeof(string), "Due of your death, the Bank Robbery attempt has failed.");
		SendClientMessage(playerid, COLOR_LIGHTRED, string);
		robpossible = 0;
		RobberyBreakTimer = SetTimer("RobberyBreak", 65000, false);
		return 1;
	}
	

	
		
	if( GetPVarInt(playerid, "SpecOff" ) == 1 )
	{
		SpawnPlayer(playerid);
		return 1;
	}

	if(GetPVarInt(playerid, "Injured") == 1)
	{
     	SendClientMessageEx(playerid, COLOR_WHITE, "You appear to be stuck in limbo, medics are trying to revive you.");
	    KillEMSQueue(playerid);
	    ResetPlayerWeaponsEx(playerid);
	    //SpawnPlayer(playerid);
	    return 1;
	}
	new Float:px,Float:py,Float:pz;
	if(GetPVarInt(playerid, "EventToken") == 0)
	{
	    if(GetPVarInt(playerid, "IsInArena") == -1)
		{
			SetPVarInt(playerid, "Injured", 1);

			new Float:mX, Float:mY, Float:mZ;
			GetPlayerPos(playerid, mX, mY, mZ);

			SetPVarFloat(playerid, "MedicX", mX);
			SetPVarFloat(playerid, "MedicY", mY);
			SetPVarFloat(playerid, "MedicZ", mZ);
			SetPVarInt(playerid, "MedicVW", GetPlayerVirtualWorld(playerid));
			SetPVarInt(playerid, "MedicInt", GetPlayerInterior(playerid));
		}
	}
	gPlayerSpawned[playerid] = 0;
	if(GetPVarInt(playerid, "IsInArena") >= 0)
	{
	    if(GetPVarInt(playerid, "AOSlotPaintballFlag") != -1)
	    {
     		switch(PlayerInfo[playerid][pPaintTeam])
       		{
         		case 1:
           		{
					DropFlagPaintballArena(playerid, GetPVarInt(playerid, "IsInArena"), 2);
     			}
        		case 2:
          		{
            		DropFlagPaintballArena(playerid, GetPVarInt(playerid, "IsInArena"), 1);
            	}
        	}
	    }

		if(reason >= 0 && reason <= 46)
		{
		    new weapon[24];
		    PlayerInfo[killerid][pKills] += 1;
		    PlayerInfo[playerid][pDeaths] += 1;
			if(PlayerInfo[killerid][pPaintTeam] == 1)
			{
			    if(PlayerInfo[killerid][pPaintTeam] == PlayerInfo[playerid][pPaintTeam])
			    {
			        PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTeamRedKills] -= 1;
			        PaintBallArena[GetPVarInt(playerid, "IsInArena")][pbTeamBlueKills] += 1;
			        SetPlayerHealth(killerid, 0);
			        PlayerInfo[killerid][pKills] -= 2;
			        PlayerInfo[killerid][pDeaths] += 1;
		    		PlayerInfo[playerid][pDeaths] -= 1;
			        SendClientMessageEx(killerid, COLOR_WHITE, "You have been warned, do not team-kill!");
			    }
			    else
			    {
		    		PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTeamRedKills] += 1;
		    		PaintBallArena[GetPVarInt(playerid, "IsInArena")][pbTeamBlueDeaths] += 1;
				}
			}
			if(PlayerInfo[killerid][pPaintTeam] == 2)
			{
			    if(PlayerInfo[killerid][pPaintTeam] == PlayerInfo[playerid][pPaintTeam])
			    {
			        PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTeamBlueKills] -= 1;
			        PaintBallArena[GetPVarInt(playerid, "IsInArena")][pbTeamRedKills] += 1;
			        SetPlayerHealth(killerid, 0);
			        PlayerInfo[killerid][pKills] -= 2;
			        PlayerInfo[killerid][pDeaths] += 1;
		    		PlayerInfo[playerid][pDeaths] -= 1;
			        SendClientMessageEx(killerid, COLOR_WHITE, "You have been warned, do not team-kill!");
			    }
		    	PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTeamBlueKills] += 1;
		    	PaintBallArena[GetPVarInt(playerid, "IsInArena")][pbTeamRedDeaths] += 1;
			}
		    GetWeaponName(reason,weapon,sizeof(weapon));
			if(reason == 0)
			{
			    if(PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTimeLeft] < 12)
			    {
			        GivePlayerCash(killerid, 1000);
			        format(string,sizeof(string),"[Paintball Arena] %s has earned $1000 bonus for a sudden death kill!",GetPlayerNameEx(killerid));
					SendPaintballArenaMessage(GetPVarInt(killerid,"IsInArena"), COLOR_YELLOW, string);
					SendAudioToPlayer(killerid, 19, 100, 0);
			    }
	    		format(string,sizeof(string),"[Paintball Arena] %s has killed %s with their bare hands!",GetPlayerNameEx(killerid),GetPlayerNameEx(playerid));
			}
			else
			{
			    if(PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTimeLeft] < 12)
			    {
			        GivePlayerCash(killerid, 1000);
			        format(string,sizeof(string),"[Paintball Arena] %s has earned $1000 bonus for a sudden death kill!",GetPlayerNameEx(killerid));
					SendPaintballArenaMessage(GetPVarInt(killerid,"IsInArena"), COLOR_YELLOW, string);
					SendAudioToPlayer(killerid, 19, 100, 0);
			    }
			    format(string,sizeof(string),"[Paintball Arena] %s has killed %s with a %s.",GetPlayerNameEx(killerid),GetPlayerNameEx(playerid),weapon);
			}
		}
		else
		{
		    PlayerInfo[playerid][pDeaths] += 1;
			format(string,sizeof(string),"[Paintball Arena] %s has died.",GetPlayerNameEx(playerid));
		}
	    SendPaintballArenaMessage(GetPVarInt(playerid,"IsInArena"), COLOR_RED, string);
	}
	PlayerInfo[playerid][pLocal] = 255;
	GetPlayerPos(playerid, px, py, pz);

	if(GetPVarInt(playerid, "Injured") == 0)
	{
		if( GetPVarInt(playerid, "EventToken") >= 1 || GetPVarInt(playerid, "IsInArena") >= 0)
		{
			ResetPlayerWeapons(playerid);
		}
		else
		{
			ResetPlayerWeaponsEx(playerid);
		}
	}
	if(PlayerInfo[killerid][pAdmin] < 2)
	{
	    if(reason == 49)
	    {
	    	format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has possibly just car-rammed %s (ID %d) to death.", GetPlayerNameEx(killerid), killerid, GetPlayerNameEx(playerid), playerid);
	    	ABroadCast(COLOR_YELLOW, string, 2);
	    	print(string);
	    }
	    if(reason == 50)
	    {
	        if(IsAHelicopter(GetPlayerVehicleID(killerid)))
	        {
	    		format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has possibly just blade-killed %s (ID %d).", GetPlayerNameEx(killerid), killerid, GetPlayerNameEx(playerid), playerid);
	    		ABroadCast(COLOR_YELLOW, string, 2);
	    		print(string);
	    	}
	    	else
	    	{
	    	    if(GetPlayerWeapon(killerid) != 32 || GetPlayerWeapon(killerid) != 28 || GetPlayerWeapon(killerid) != 29)
	    	    {
	    			format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has possibly just car-parked %s (ID %d) to death.", GetPlayerNameEx(killerid), killerid, GetPlayerNameEx(playerid), playerid);
	    			ABroadCast(COLOR_YELLOW, string, 2);
	    			print(string);
	    		}
	    		else
	    		{
	    			format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has possibly just driver-shot %s (ID %d) to death.", GetPlayerNameEx(killerid), killerid, GetPlayerNameEx(playerid), playerid);
	    			ABroadCast(COLOR_YELLOW, string, 2);
	    			print(string);
	    		}
	    	}
	    }
	}
	if (gPlayerCheckpointStatus[playerid] > 4 && gPlayerCheckpointStatus[playerid] < 11)
	{
		DisablePlayerCheckpoint(playerid);
		gPlayerCheckpointStatus[playerid] = CHECKPOINT_NONE;
	}
	if(HaveGPS[playerid])
	{
		KillTimer(GPSTimer[playerid]);
		HaveGPS[playerid] = false;
		GPSTimer[playerid] = 0;
	}

	ClearCrime(playerid);
	if(PlayerInfo[playerid][pHeadValue] >= 1)
	{
		if(IsPlayerConnected(killerid))
		{
			if(GoChase[killerid] == playerid)
			{
				new killer[MAX_PLAYER_NAME],
					name[MAX_PLAYER_NAME];

				new takemoney = PlayerInfo[playerid][pHeadValue] / 4 * 2;
			 	name = GetPlayerNameEx(playerid);
				killer = GetPlayerNameEx(killerid);
				GivePlayerCash(killerid, takemoney);
				GivePlayerCash(playerid, -takemoney);
				format(string,128,"Hitman %s has fulfilled the contract on %s and collected $%d.",killer,name,PlayerInfo[playerid][pHeadValue] / 4 * 2);
				SendFamilyMessage(8, COLOR_YELLOW, string);
				format(string,128,"You have been critically injured by a hitman and lost $%d.",takemoney);
   				ResetPlayerWeaponsEx(playerid);
				// SpawnPlayer(playerid);
				SendClientMessageEx(playerid, COLOR_YELLOW, string);
				// KillEMSQueue(playerid);
				PlayerInfo[playerid][pHeadValue] = 0;
				PlayerInfo[killerid][pCHits] += 1;
				GotHit[playerid] = 0;
				GetChased[playerid] = 999;
				GoChase[killerid] = 999;
			}
		}
	}
	if(IsPlayerConnected(killerid))
 	{
		if(GoChase[playerid] == killerid)
		{
			new killer[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
			new takemoney = PlayerInfo[playerid][pHeadValue] / 4 * 2;
			GivePlayerCash(killerid, takemoney);
			name = GetPlayerNameEx(playerid);
			killer = GetPlayerNameEx(killerid);
			format(string,128,"Hitman %s has failed the contract on %s and lost $%d.",name,killer,PlayerInfo[killerid][pHeadValue] / 4 * 2);
			SendFamilyMessage(8, COLOR_YELLOW, string);
			GivePlayerCash(playerid, -takemoney);
		   	format(string,128,"You have just killed a hitman and gained $%d, removing the contact on your head.",PlayerInfo[killerid][pHeadValue] / 4 * 2);
			SendClientMessageEx(killerid, COLOR_YELLOW, string);
			PlayerInfo[killerid][pHeadValue] = 0;
			PlayerInfo[playerid][pFHits] += 1;
			GotHit[playerid] = 0;
			GetChased[killerid] = 999;
			GoChase[playerid] = 999;
		}
	}
	killerid = INVALID_PLAYER_ID;
	SetPlayerColor(playerid,TEAM_HIT_COLOR);
	return 1;
}
Reply
#2

There are a lot of parts that don't check if the killerid is online/valid player before using it in arrays

pawn Код:
// ...
    if(GetPVarInt(playerid, "IsInArena") >= 0)
    {
        if(GetPVarInt(playerid, "AOSlotPaintballFlag") != -1)
        {
            switch(PlayerInfo[playerid][pPaintTeam])
            {
                case 1:
                {
                    DropFlagPaintballArena(playerid, GetPVarInt(playerid, "IsInArena"), 2);
                }
                case 2:
                {
                    DropFlagPaintballArena(playerid, GetPVarInt(playerid, "IsInArena"), 1);
                }
            }
        }

        if(reason >= 0 && reason <= 46)
        {
            new weapon[24];
            PlayerInfo[killerid][pKills] += 1;
            PlayerInfo[playerid][pDeaths] += 1;
            if(PlayerInfo[killerid][pPaintTeam] == 1)
            {
                if(PlayerInfo[killerid][pPaintTeam] == PlayerInfo[playerid][pPaintTeam])
                {
                    PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTeamRedKills] -= 1;
                    PaintBallArena[GetPVarInt(playerid, "IsInArena")][pbTeamBlueKills] += 1;
                    SetPlayerHealth(killerid, 0);
                    PlayerInfo[killerid][pKills] -= 2;
                    PlayerInfo[killerid][pDeaths] += 1;
                    PlayerInfo[playerid][pDeaths] -= 1;
                    SendClientMessageEx(killerid, COLOR_WHITE, "You have been warned, do not team-kill!");
                }
                else
                {
                    PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTeamRedKills] += 1;
                    PaintBallArena[GetPVarInt(playerid, "IsInArena")][pbTeamBlueDeaths] += 1;
                }
            }
            if(PlayerInfo[killerid][pPaintTeam] == 2)
            {
                if(PlayerInfo[killerid][pPaintTeam] == PlayerInfo[playerid][pPaintTeam])
                {
                    PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTeamBlueKills] -= 1;
                    PaintBallArena[GetPVarInt(playerid, "IsInArena")][pbTeamRedKills] += 1;
                    SetPlayerHealth(killerid, 0);
                    PlayerInfo[killerid][pKills] -= 2;
                    PlayerInfo[killerid][pDeaths] += 1;
                    PlayerInfo[playerid][pDeaths] -= 1;
                    SendClientMessageEx(killerid, COLOR_WHITE, "You have been warned, do not team-kill!");
                }
                PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTeamBlueKills] += 1;
                PaintBallArena[GetPVarInt(playerid, "IsInArena")][pbTeamRedDeaths] += 1;
            }
            GetWeaponName(reason,weapon,sizeof(weapon));
            if(reason == 0)
            {
                if(PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTimeLeft] < 12)
                {
                    GivePlayerCash(killerid, 1000);
                    format(string,sizeof(string),"[Paintball Arena] %s has earned $1000 bonus for a sudden death kill!",GetPlayerNameEx(killerid));
                    SendPaintballArenaMessage(GetPVarInt(killerid,"IsInArena"), COLOR_YELLOW, string);
                    SendAudioToPlayer(killerid, 19, 100, 0);
                }
                format(string,sizeof(string),"[Paintball Arena] %s has killed %s with their bare hands!",GetPlayerNameEx(killerid),GetPlayerNameEx(playerid));
            }
            else
            {
                if(PaintBallArena[GetPVarInt(killerid, "IsInArena")][pbTimeLeft] < 12)
                {
                    GivePlayerCash(killerid, 1000);
                    format(string,sizeof(string),"[Paintball Arena] %s has earned $1000 bonus for a sudden death kill!",GetPlayerNameEx(killerid));
                    SendPaintballArenaMessage(GetPVarInt(killerid,"IsInArena"), COLOR_YELLOW, string);
                    SendAudioToPlayer(killerid, 19, 100, 0);
                }
                format(string,sizeof(string),"[Paintball Arena] %s has killed %s with a %s.",GetPlayerNameEx(killerid),GetPlayerNameEx(playerid),weapon);
            }
        }
        else
        {
            PlayerInfo[playerid][pDeaths] += 1;
            format(string,sizeof(string),"[Paintball Arena] %s has died.",GetPlayerNameEx(playerid));
        }
        SendPaintballArenaMessage(GetPVarInt(playerid,"IsInArena"), COLOR_RED, string);
    }
pawn Код:
// ...
    if(PlayerInfo[killerid][pAdmin] < 2)
    {
        if(reason == 49)
        {
            format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) has possibly just car-rammed %s (ID %d) to death.", GetPlayerNameEx(killerid), killerid, GetPlayerNameEx(playerid), playerid);
            ABroadCast(COLOR_YELLOW, string, 2);
            print(string);
        }
Reply
#3

what did you change on your post from the source code of mine?

also i found that, its belong to cellphone calls with IDs

Quote:

[18:42:14] [zcmd] [Joker] [ID: 0]: /call 1
[18:42:16] [zcmd] [Joker] [ID: 0]: /number 1
[18:42:20] [zcmd] [Joker] [ID: 0]: /call 912
[18:42:21] DEBUG: Mobile[Mobile[i]] is 65535
[18:42:21] DEBUG: Mobile[i] is 1
[18:42:22] DEBUG: Mobile[Mobile[i]] is 65535
[18:42:22] DEBUG: Mobile[i] is 1
[18:42:23] DEBUG: Mobile[Mobile[i]] is 65535
[18:42:23] DEBUG: Mobile[i] is 1
[18:42:23] [zcmd] [MrGun] [ID: 1]: /p
[18:42:24] DEBUG: Mobile[Mobile[i]] is 0
[18:42:24] DEBUG: Mobile[i] is 1
[18:42:25] DEBUG: Mobile[Mobile[i]] is 0
[18:42:25] DEBUG: Mobile[i] is 1
[18:42:26] DEBUG: Mobile[Mobile[i]] is 0
[18:42:26] DEBUG: Mobile[i] is 1
[18:42:27] DEBUG: Mobile[Mobile[i]] is 0
[18:42:27] DEBUG: Mobile[i] is 1
[18:42:28] [chat] [Joker]: EO!
[18:42:28] DEBUG: Mobile[Mobile[i]] is 0
[18:42:28] DEBUG: Mobile[i] is 1

Reply
#4

Nothing, I just posted the parts that uses killerid inside [] without checking if the player is valid player. You'll need to add those checks yourself like you did with the rest.

I saw the Mobile thing before but it is fine because you don't use it as an invalid index anywhere.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)