Array index out of bounds
#1

Server is working fine, but however something is effecting the death list

Server Logs

17:25:39] [debug] Run time error 4: "Array index out of bounds"
[17:25:39] [debug] Attempted to read/write array element at index 65535 in array of size 1000
[17:25:39] [debug] AMX backtrace:
[17:25:39] [debug] #0 000664a8 in public CB_OnPlayerTakeDamage (0, 65535, 1084122727, 54, 3) from CODv15.amx
[17:25:39] [debug] #1 0001337c in public OnPlayerTakeDamage (0, 65535, 1084122727, 54, 3) from CODv15.amx






Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(Captureing{playerid} == true && killerid != INVALID_PLAYER_ID)
{
new killcp[100];
format(killcp,sizeof(killcp),"%s Has Prevented %s From Capturing The Zone & Recieved +1",pName(killerid), pName(playerid));
GivePlayerScore(killerid,1);
}
if(reason == 50)
        {
    new Name[MAX_PLAYER_NAME], Message1[128];
    GetPlayerName(killerid, Name, sizeof(Name));
    format(Message1, sizeof(Message1), "{FF9E00}[AC]Cheat Buster Has Fined %s For {FF9E00}Heli-Blade/Car Parking", Name, playerid);
    SendClientMessageToAll(-1,Message1);
    SCM(killerid, red, "You Are Killed, Fined 2,500$ & 2 Score For Heli-Blade/Car Parking");
    SetPlayerHealth(killerid,0);
    GivePlayerMoney(killerid,-2500);
    GivePlayerScore(killerid,-2);
	}
 	if(gClass[playerid] == DEMOLISHER) {
	new Float:APos[3];
	GetPlayerPos(playerid,APos[0],APos[1],APos[2]);
	CreateExplosion(APos[0],APos[1],APos[2],7,10.0);
	}
	HHelmet{playerid} = false;
	if(IsPrototyping{playerid })
	{
	    DisablePlayerCheckpoint(playerid);
	    IsPrototyping{playerid } = false;
	    TogglePlayerAllDynamicCPs(playerid, 1);
	    SendClientMessage(playerid, red, "ERROR: You Died While Capturing The Enemy's Prototype.");
	}
Reply
#2

It's pointing to OnPlayerTakeDamage so why are you posting OnPlayerDeath? And in OnPlayerTakeDamage you may as well want to check that issuerid is not INVALID_PLAYER_ID (65535) because a player can take damage from other sources than weapons, including but not limited to fall damage.
Reply
#3

Oh lol, yes wrong callback.
Reply
#4

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if (issuerid != INVALID_PLAYER_ID)
    {
     new str[1500];
     KillTimer(TempoMostrarLife2[playerid]);
     TextDrawShowForPlayer(playerid, damage2[playerid]);
     format(str,sizeof(str),"~r~%s -%.2f ~n~~r~%s", pName(issuerid), amount, WeaponNames[weaponid]);
     TextDrawSetString(damage2[playerid], str);
     TempoMostrarLife2[playerid] = SetTimerEx("HideTextoLife2", 3000, 0, "i", playerid);
     MostrandoVida2[playerid] = 1;

     KillTimer(TempoMostrarLife[issuerid]);
     TextDrawShowForPlayer(issuerid, damage[issuerid]);
     format(str,sizeof(str),"~g~%s -%.2f ~n~~g~%s", pName(playerid), amount, WeaponNames[weaponid]);
     TextDrawSetString(damage[issuerid], str);
     TempoMostrarLife[issuerid] = SetTimerEx("HideTextoLife", 3000, 0, "i", issuerid);
     MostrandoVida[issuerid] = 1;
     PlayerPlaySound(issuerid , 17802, 0.0, 0.0, 0.0);
    }
    if(HHelmet{playerid} == true) return HHelmet{playerid} = false, GameTextForPlayer(playerid,"~n~~w~Your Anti-Headshot Helmet Is Destroyed", 2000, 3);
    if(NoHS == 1 && AntiSK[playerid] == 0 && GetPlayerTeam(issuerid) != GetPlayerTeam(playerid) && weaponid == 34 && bodypart == 9 && PlayerInfo[playerid][OnDuty] == 0)
    {
            SetPlayerHealth(playerid, 0.0);
            GameTextForPlayer(playerid, "~n~~r~HEADSHOT", 3000, 3);
            GameTextForPlayer(issuerid, "~n~~g~HEADSHOT", 3000, 3);
            PlayerInfo[issuerid][Headshots] ++;
            new Float:x, Float:y, Float:z, Float:fDistance, hsMessage[90], KName[MAX_PLAYER_NAME], PName[MAX_PLAYER_NAME];
			GetPlayerPos(playerid, x, y, z);
			fDistance = GetPlayerDistanceFromPoint(issuerid, x, y, z);
			GetPlayerName(issuerid, KName, MAX_PLAYER_NAME);
			GetPlayerName(playerid, PName, MAX_PLAYER_NAME);
			PlayAudioStreamForPlayer(playerid, "http://mfi.re/listen/vbjc8i7uum6j1h6/Headshot.wav");
			PlayAudioStreamForPlayer(issuerid, "http://mfi.re/listen/vbjc8i7uum6j1h6/Headshot.wav");
	        format(hsMessage, sizeof(hsMessage), "%s has Headshotted %s from the distance of %0.2f", KName, PName, fDistance);
	        SendClientMessageToAll(green, hsMessage);
            }
	if(gTeam[issuerid] != gTeam[playerid])
	{
	if(weaponid == 4 && bodypart == 9)
	{
	SetPlayerHealth(playerid, 0.0);
	}
	}
	if(gTeam[issuerid] == gTeam[playerid] && gTeam[playerid] != -1 && gTeam[issuerid] != -1)
	{
	   	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;
}
This is the right one
Reply
#5

Like Vince said:

Код:
if(gTeam[issuerid] != gTeam[playerid])
Could easily be the cause if someone gets damaged from something else than a weapon/Player.

Just add a check if the issuerid is valid before accessing any Arrays with issuerid.
Reply
#6

Quote:
Originally Posted by NaS
Посмотреть сообщение
Like Vince said:

Код:
if(gTeam[issuerid] != gTeam[playerid])
Could easily be the cause if someone gets damaged from something else than a weapon/Player.

Just add a check if the issuerid is valid before accessing any Arrays with issuerid.
it's already on the code, Please see above
Reply
#7

Quote:
Originally Posted by Matthew57
Посмотреть сообщение
it's already on the code, Please see above Anyone Fix Please!
Only parts of the code is safe. The issuerid check isn't done on the lower part of the code (which I quoted from). So either put that part into the first if() brackets too, or add another check.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)