Errors in crashdetect "Array index out of bounds" HELP
#1

PHP код:
[19:47:10] [debugRun time error 4"Array index out of bounds"
[19:47:10] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[19:47:10] [debugAMX backtrace:
[
19:47:10] [debug#0 0002d724 in ?? (21, 65535, 255) from Mundito.amx
[19:47:10] [debug#1 0000cd7c in public OnPlayerDeath (21, 65535, 255) from Mundito.amx 
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
SendDeathMessage(killerid,playerid,reason);
//-----------------------------------------
new string[256];
KillingSpree[killerid] ++;
KillingSpree[playerid] = 0;
kills[playerid]=0;//nuevo
SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
format(string,sizeof(string), "~n~~w~HAS SIDO ASESINADO POR~n~~r~%s"Nombre(killerid));
GameTextForPlayer(playerid,string,2000,3);
format(string,sizeof(string),">> Recibido +1 score y +$200 por matar a '%s', Asesinatos seguidos: %d",Nombre(playerid), KillingSpree[killerid]);
SendClientMessage(killerid,0x00FF00FF,string);
GivePlayerCash(killerid,200);
//===================================================
if(KillingSpree[killerid] == 3)
{
format(string,sizeof(string),"» Recompensa « %s lleva 3 asesinatos seguidos, el que lo mate ganara $300.",Nombre(killerid));
SendClientMessageToAll(0xFF8000FF,string);
Cantidad[killerid] = 1;
Cantidad[killerid] = 300;
}
if(
KillingSpree[killerid] == 5)
{
format(string,sizeof(string),"» Recompensa « %s lleva 5 asesinatos seguidos, el que lo mate ganara $500.",Nombre(killerid));
SendClientMessageToAll(0xFF8000FF,string);
Cantidad[killerid] = 1;
Cantidad[killerid] = 500;
}
if(
KillingSpree[killerid] == 10)
{
format(string,sizeof(string),"» Recompensa « %s lleva 10 asesinatos seguidos, el que lo mate ganara $700.",Nombre(killerid));
SendClientMessageToAll(0xFF8000FF,string);
Cantidad[killerid] = 1;
Cantidad[killerid] = 700;
}
if(
KillingSpree[killerid] == 15)
{
format(string,sizeof(string),"» Recompensa « %s lleva 15 asesinatos seguidos, el que lo mate ganara $900.",Nombre(killerid));
SendClientMessageToAll(0xFF8000FF,string);
Cantidad[killerid] = 1;
Cantidad[killerid] = 900;
}
if(
Cantidad[playerid] > && killerid != playerid)
{
format(stringsizeof(string), "» Recompensa « %s a recibido $%i por matar a %s."Nombre(killerid), Cantidad[playerid], Nombre(playerid));
SendClientMessageToAll0xFF9900FF string);
GivePlayerCash(killeridCantidad[playerid]);
Cantidad[playerid] = 0;
return 
0;
}
//===================================================
//GivePlayerCash(playerid, -100);
TextDrawHideForPlayer(playeridAbajoVida[playerid]);
//Vida y chaleco
new stringasda[256];
TextDrawHideForPlayer(playeridArmadura[playerid]);
format(stringasdasizeof(stringasda), "_KILL");
TextDrawSetString(Vidaa[playerid], stringasda);
//
   
new
       
sString[128],
         
//Name[MAX_PLAYER_NAME],
         
zName[MAX_PLAYER_NAME],
         
Float:Health,
         
Float:Armor;
    if((
reason == 50)||(reason == 49))
    {
    new 
string2[500];
    
format(string2128"** %s ha sido encarcelado por el Administrador MuNdo InFerNal | Razуn: Matar en Vehiculo {E30000}(Carkill/Helikill) |"PlayerName2(killerid));
    
SendClientMessageToAll(COLOR_YELLOWstring2);
    
SendClientMessage(killeridCOLOR_YELLOW"{FF0000}has sido encarcelado por 1 minuto | Razon: Matar Con vehiculo {E30000}(Carkill/HeliKill) |");
    
ResetPlayerWeapons(playerid);
    
Encarcelar(killerid1);
    return 
1;
    }
    
//**********************[Sistema de Combos/Racha]***************************
    
GameTextForPlayer(killerid,KSMensajes[random(sizeof(KSMensajes))], 30006);
    
//**************************************************************************
    //sistema de eventos
    
if(PlayerInfoE[playerid][NoEvento] >= 1)
    {
        
SetPlayerVirtualWorld(playerid0);
        
SetPlayerInterior(playerid0);
        
PlayerInfoE[playerid][NoEvento] = 0;
        if(
PlayerInfoE[playerid][Carro] >= 1)
        {
            
DestroyVehicle(PlayerInfoE[playerid][Carro]);
            
PlayerInfoE[playerid][Carro] = 0;
        }
    }
//sistema de duelo
if (EnDuelo[playerid] == && EnDuelo[killerid] == 1)
     {
        for (new 
i=1i<= ARENASi++)
        {
            if ((
Duelos[i][DesaId] == playerid || Duelos[i][DesaId] == killerid) && (Duelos[i][DesafiadoId] == playerid) || (Duelos[i][DesafiadoId] == killerid))
            {
                new 
str[128];
                new 
Float:healthkillerFloat:armourkiller;
                
GetPlayerHealth(killerid,healthkiller);
                
GetPlayerArmour(killerid,armourkiller);
                if(
healthkiller 90.0 && armourkiller 90.0)
                  {
                
format(strsizeof(str),"* » FINAL « %s Obtiene >> OWNED << Contra %s en el Duelo |Con %0.0f de Vida y %0.0f de Chaleco|",PlayerName2(killerid),PlayerName2(playerid),healthkiller,armourkiller);
                  
SendClientMessageToAll(azul_clarostr);
                  
format(str,sizeof(str),"» Desafio « has perdido el Duelo contra %s, Suerte en la prуxima...",PlayerName2(killerid));
                
SendClientMessage(playerid,COLOR_DUELO,str);
                
format(str,sizeof(str),"» Desafio « has ganado el Duelo contra %s, Felicidades!!",PlayerName2(playerid));
                   
SendClientMessage(killerid,COLOR_DUELO,str);
                
EnDuelo[playerid] = 0;
                
EnDuelo[killerid] = 0;
                
Duelos[i][DesafiadoId] = -1;
                   
Duelos[i][DesaId] = -1;
                
Duelos[i][ArmasId] = -1;
                
Duelos[i][Libre] = 0;
                
PlayerInfo[killerid][dGanados]++;
                
PlayerInfo[playerid][dPerdidos]++;
                
SetPlayerVirtualWorld(killerid,0);
                
SetPlayerVirtualWorld(playerid,0);
                return 
1;
                   }
                   else
                {
                
format(str,sizeof(str),"» FINAL « %s ha ganado el Duelo contra %s |Con %0.0f de Vida y %0.0f de Chaleco|",PlayerName2(killerid),PlayerName2(playerid), healthkillerarmourkiller);
                
SendClientMessageToAll(azul_claro,str);
                
format(str,sizeof(str),"» Desafio « has perdido el Duelo contra %s, Suerte en la prуxima...",PlayerName2(killerid));
                
SendClientMessage(playerid,COLOR_DUELO,str);
                
format(str,sizeof(str),"» Desafio « has ganado el Duelo contra %s, Felicidades!!",PlayerName2(playerid));
                   
SendClientMessage(killerid,COLOR_DUELO,str);
                 
EnDuelo[playerid] = 0;
                
EnDuelo[killerid] = 0;
                
Duelos[i][DesafiadoId] = -1;
                   
Duelos[i][DesaId] = -1;
                
Duelos[i][ArmasId] = -1;
                
Duelos[i][Libre] = 0;
                
PlayerInfo[killerid][dGanados]++;
                
PlayerInfo[playerid][dPerdidos]++;
                
SetPlayerVirtualWorld(killerid,0);
                
SetPlayerVirtualWorld(playerid,0);
                switch (
i)
                {
                    case 
1: {SpawnPlayer(killerid);}
                    case 
2: {SpawnPlayer(killerid);}
                    case 
3: {SpawnPlayer(killerid);}
                    case 
4: {SpawnPlayer(killerid);}
                    case 
5: {SpawnPlayer(killerid);}
                    case 
6: {SpawnPlayer(killerid);}
                }
                for (new 
j=0j<= MAX_PLAYERSj++)
                {
                    if (
ViendoDuelo[j] == i)
                    {
                        new 
str2[80];
                        
format(str2,sizeof(str2),"~r~%s ~w~es el ganador del duelo, Felicidades!",PlayerName2(killerid));
                        
GameTextForPlayer(j,str2,5000,0);
                        
ViendoDuelo[j] =-1;
                        
SetPlayerVirtualWorld(j,0);
                    }
                }
                return 
1;
            }
        }
    }
    }
    if (
EnDuelo[playerid] == && EnDuelo[killerid] == 0)
    {
    }
if(
Joined[playerid] == true)
{
        
JoinCount--;
        
Joined[playerid] = false;
        
DestroyVehicle(CreatedRaceVeh[playerid]);
        
DisablePlayerRaceCheckpoint(playerid);
        
TextDrawHideForPlayer(playeridRaceInfo[playerid]);
        
CPProgess[playerid] = 0;
        
KillTimer(InfoTimer[playerid]);
        
#if defined RACE_IN_OTHER_WORLD
        
SetPlayerVirtualWorld(playerid0);
        
#endif
}
if(
BuildRace == playerid+1BuildRace 0;
#if defined USE_STATS
PlayerInfo[playerid][Deaths]++;
new 
cName[MAX_PLAYER_NAME];
//zName[MAX_PLAYER_NAME],
//Float:Health,
//Float:Armor;
#endif
//InDuel[playerid] = 0;
if(IsPlayerConnected(killerid) && killerid != INVALID_PLAYER_ID)
{
#if defined USE_STATS
PlayerInfo[killerid][Kills]++;
#endif
if(InDuel[playerid] == && InDuel[killerid] == 1)
{
GameTextForPlayer(playerid,"Perdedor !",3000,3);
GameTextForPlayer(killerid,"Ganador !",3000,3);
InDuel[killerid] = 0;
SetPlayerPos(killerid0.00.00.0);
SpawnPlayer(killerid);
}
else if(
InDuel[playerid] == && InDuel[killerid] == 0)
{
GameTextForPlayer(playerid,"Perdedor !",3000,3);
}
}
if(
g_IsPlayerDueling[playerid] == && g_IsPlayerDueling[killerid] == 1)
{
GetPlayerHealth(killeridHealth);
GetPlayerArmour(killeridArmor);
GetPlayerName(playeridcNameMAX_PLAYER_NAME);
GetPlayerName(killeridzNameMAX_PLAYER_NAME);
if(
Health 90.0 && Armor 90.0)
{
format(sStringsizeof(sString),"» Desafio « %s Tiene \"OWNED\" Sobre %s en el duelo y %.2f Vida y %.2f Chaleco!"zName,cName,Health,Armor);
SendClientMessageToAll(COLOR_ORANGEsString);
g_GotInvitedToDuel[playerid] = 0;g_HasInvitedToDuel[playerid] = 0;g_IsPlayerDueling[playerid]  = 0;
g_GotInvitedToDuel[killerid] = 0;g_HasInvitedToDuel[killerid] = 0;g_IsPlayerDueling[killerid]  = 0;
g_DuelInProgress 0;
SetPlayerHealth(killerid100);
SetPlayerArmour(killerid100);
SpawnPlayer(killerid);
return 
1;
}
else
{
format(sStringsizeof(sString),"» Desafio « %s Ha ganado el Duelo contra %s con %.2f Vida y %.2f Chaleco!"zName,cName,Health,Armor);
SendClientMessageToAll(COLOR_ORANGEsString);
g_GotInvitedToDuel[playerid] = 0;g_HasInvitedToDuel[playerid] = 0;g_IsPlayerDueling[playerid]  = 0;
g_GotInvitedToDuel[killerid] = 0;g_HasInvitedToDuel[killerid] = 0;g_IsPlayerDueling[killerid]  = 0;
g_DuelInProgress 0;
SetPlayerHealth(killerid100);
SetPlayerArmour(killerid100);
SpawnPlayer(killerid);
return 
1;
}
}
#if defined ENABLE_SPEC
for(new x=0x<MAX_PLAYERSx++)
if(
GetPlayerState(x) == PLAYER_STATE_SPECTATING && PlayerInfo[x][SpecID] == playerid)
AdvanceSpectate(x);
#endif
if(AntiFreeScore==1){
if(
IsPlayerConnected(killerid) && IsPlayerConnected(playerid)){
new 
Float:a,Float:b,Float:c;
GetPlayerPos(playerid,a,b,c);
if(
XDeaths[playerid] == 0)
{
LastDeath[playerid] = gettime();
}
XDeaths[playerid]++;
if(
XDeaths[playerid] == 5)
{
if((
gettime() - LastDeath[playerid]) <= 5)
{
KickearFree(playerid);
}
else
if((
gettime() - LastDeath[playerid]) > 5)
{
XDeaths[playerid]=0;
}
}
}
}
if(
USERCHUCK[killerid] == && ADMINCHUCK[playerid] == 1)
{
GetPlayerName(killeridzNameMAX_PLAYER_NAME);
GameTextForPlayer(killerid,"Has Ganado !",3000,3);
format(sStringsizeof(sString),"* [InfoEvento] %s ha ganado en el Evento, /LoroLoco!"zName,cName,Health,Armor);
SendClientMessageToAll(COLOR_ORANGEsString);
for(new 
iGetMaxPlayers(); ++)
{
if(
USERCHUCK[i] == 1)
{
SpawnPlayer(i);
Adentro[i] = 0;
ADMINCHUCK[i] = 0;
USERCHUCK[i] = 0;
}
}
}
    
//MTAS TE DISE ASD
    
new mereexita[256];
    new 
asd[24];
    
kills[killerid]++;
        if(
kills[killerid]==Multikills) {
        
GetPlayerName(killerid,asd,24);
        
format(mereexita,256,"« %s « Tiene una Racha de \"4\" \"ASESINATOS\" Seguidos, Sin MORIR |$300|",asd);//3
        
SendClientMessageToAll(0xFF2400FF,mereexita);
        
GivePlayerCash(killerid,300);
        }
        if(
kills[killerid]==Ultrakills) {
        
GetPlayerName(killerid,asd,24);
        
format(mereexita,256,"« %s « Tiene una Racha de \"6\" \"ASESINATOS\" Seguidos, e_e!! |$500|",asd);//5
        
SendClientMessageToAll(0xFF2400FF,mereexita);
        
GivePlayerCash(killerid,500);
        }
        if(
kills[killerid]==Arrasador) {
        
GetPlayerName(killerid,asd,24);
        
format(mereexita,256,"« %s « Tiene una Racha de \"12\" \"ASESINATOS\" Seguidos, Pro Detect! |$800|",asd);//10
        
SendClientMessageToAll(0xFF2400FF,mereexita);
        
GivePlayerCash(killerid,800);
        }
        if(
kills[killerid]==Jason) {
        
GetPlayerName(killerid,asd,24);
        
format(mereexita,256,"« %s « Tiene una Racha de \"16\" \"ASESINATOS\" Seguidos, seguro tiene cheat XD! |$1000|",asd);//15
        
SendClientMessageToAll(0xFF2400FF,mereexita);
        
GivePlayerCash(killerid,1000);
        }
        if(
kills[killerid]==Kratos) {
        
GetPlayerName(killerid,asd,24);
        
format(mereexita,256,"« %s « Tiene una Racha de \"20\" \"ASESINATOS\" Seguidos, Estб violando a Todos! |$1500|",asd);
        
SendClientMessageToAll(0xFF2400FF,mereexita);
        
GivePlayerCash(killerid,1500);
        }
return 
1;

I would appreciate it very much if you helped me
Reply
#2

killerid returns INVALID_PLAYER_ID if playerid died by itself (falling)

INVALID_PLAYER_ID is defined as 65535.

You're trying to put the 65535 value inside your (i guess) MAX_PLAYERS array, it does not have space to be there.

You should add a check in order for this to not happen:

Код:
if(killerid == INVALID_PLAYER_ID) return 1;
on top most of the callback.
Reply
#3

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
if(
killerid == INVALID_PLAYER_ID) return 1;
SendDeathMessage(killerid,playerid,reason);
//-----------------------------------------
new string[256];
KillingSpree[killerid] ++;
KillingSpree[playerid] = 0;
kills[playerid]=0;//nuevo
SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
format(string,sizeof(string), "~n~~w~HAS SIDO ASESINADO POR~n~~r~%s"Nombre(killerid));
GameTextForPlayer(playerid,string,2000,3);
format(string,sizeof(string),">> Recibido +1 score y +$200 por matar a '%s', Asesinatos seguidos: %d",Nombre(playerid), KillingSpree[killerid]);
SendClientMessage(killerid,0x00FF00FF,string);
GivePlayerCash(killerid,200);
//===================================================
if(KillingSpree[killerid] == 3
asi?
Reply
#4

Quote:
Originally Posted by Troydere
Посмотреть сообщение
killerid returns INVALID_PLAYER_ID if playerid died by itself (falling)

INVALID_PLAYER_ID is defined as 65535.

You're trying to put the 65535 value inside your (i guess) MAX_PLAYERS array, it does not have space to be there.

You should add a check in order for this to not happen:

Код:
if(killerid == INVALID_PLAYER_ID) return 1;
on top most of the callback.
That's bad, deaths won't increase unless the killerid be valid, a condition checking if the killerid isn't valid should be added where something related to killerid is called, with exception of SendDeathMessage.

PHP код:
if(killerid != INVALID_PLAYER_ID)
{
   
Kills[killerid]++; //example
}
//Rest of the code where killerid isn't involved. 
Reply
#5

Exactly, but that way the specific playerid options wont work at all.

As an example, if some player dies from whatever circumstance other than being killed, it wont display the text "Has sido asesinado por". And that may be a problem in some cases.

If that's how it should work in your GM, then leave it like that.

If you have some specific function that does not require the killerid to be valid, move it on top of the line we just created:

Код:
//here would be your playerid specific function
if(killerid == INVALID_PLAYER_ID) return 1;
EDIT: The same as what the guy above said, I was prepared to tell you this but I did not refresh the page on time. But that's how it should work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)