No lee OnPlayerDeath
#5

Quote:
Originally Posted by OTACON
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/OnPlayerDeath_Es

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendClientMessage(playerid,-1,"has muerto gil");
    if (playerid != INVALID_PLAYER_ID)
    {
        JugadorInfo[playerid][jMuertes]++;
        JugadorInfo[killerid][jAsesinatos]++;
        GivePlayerMoney(playerid, -100);
        GivePlayerMoney(killerid, 100);
        SetPlayerScore(killerid, GetPlayerScore(playerid) + 25);
        SendClientMessage(playerid,-1,"has muerto gil");
        if(RecibioTextoDesbaneciendo[killerid] == 0)
        {
        TextDrawHideForPlayer(killerid, Textdraw1);
        RecibioTextoDesbaneciendo[killerid] = 1;
        TextDrawColor(Textdraw1, 0x00FF00FF);
        TextDrawSetString(Textdraw1, "+25 XP +100 C");
        TextDrawShowForPlayer(killerid, Textdraw1);
        TimerScoreAsesinato[killerid] = SetTimerEx("TextoDesbaneciendo",125,true,"i",killerid);
        }
    }
    return 1;
}
Primeramente, Jamбs OnPlayerDeath va a ser llamado con INVALID_PLAYER_ID como parametro de playerid

o este
Quote:
Originally Posted by OTACON
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendClientMessage(playerid,-1,"has muerto gil");
    if (killerid == INVALID_PLAYER_ID)
    {
        JugadorInfo[playerid][jMuertes]++;
        JugadorInfo[killerid][jAsesinatos]++;
        GivePlayerMoney(playerid, -100);
        GivePlayerMoney(killerid, 100);
        SetPlayerScore(killerid, GetPlayerScore(playerid) + 25);
        SendClientMessage(playerid,-1,"has muerto gil");
        if(RecibioTextoDesbaneciendo[killerid] == 0)
        {
        TextDrawHideForPlayer(killerid, Textdraw1);
        RecibioTextoDesbaneciendo[killerid] = 1;
        TextDrawColor(Textdraw1, 0x00FF00FF);
        TextDrawSetString(Textdraw1, "+25 XP +100 C");
        TextDrawShowForPlayer(killerid, Textdraw1);
        TimerScoreAsesinato[killerid] = SetTimerEx("TextoDesbaneciendo",125,true,"i",killerid);
        }
    }
    return 1;
}
Este causarб desbordamiento de bъfer lo que lleva a un segmentation fault (Violacion de acceso), dicho segmentation fault no ocurre todo el tiempo

їPor quй?

Si la condicion se cumple es cuando se harб la violacion de acceso(Crash, segmentation fault) ya que se estб intentando acceder a un index del bъfer inexistente(en ingles: array index out of bounds) que es imposible de detectar actualmente por el compilador de pawn(algunos compiladores de la actualidad de otros lenguajes de programaciуn si lo marcan como error, como g++ o gcc de linux) ya que si killerid es igual a INVALID_PLAYER_ID dicho valor serб 65535 y el mбximo index de JugadorInfo seguramente son 500


Serнa asн:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if (killerid != INVALID_PLAYER_ID)
    {
        JugadorInfo[playerid][jMuertes]++;
        JugadorInfo[killerid][jAsesinatos]++;
        GivePlayerMoney(playerid, -100);
        GivePlayerMoney(killerid, 100);
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 25);
       
        if(RecibioTextoDesbaneciendo[killerid] == 0)
        {
        TextDrawHideForPlayer(killerid, Textdraw1);
        RecibioTextoDesbaneciendo[killerid] = 1;
        TextDrawColor(Textdraw1, 0x00FF00FF);
        TextDrawSetString(Textdraw1, "+25 XP +100 C");
        TextDrawShowForPlayer(killerid, Textdraw1);
        TimerScoreAsesinato[killerid] = SetTimerEx("TextoDesbaneciendo",125,true,"i",killerid);
        }
    }
    else
        SendClientMessage(playerid,-1,"has muerto solo, gil!");

    return 1;
}
Reply


Messages In This Thread
No lee OnPlayerDeath - by The_Scope - 05.04.2013, 23:36
Re: No lee OnPlayerDeath - by xDarkuzSx - 05.04.2013, 23:46
Respuesta: Re: No lee OnPlayerDeath - by Parka - 06.04.2013, 00:08
Respuesta: No lee OnPlayerDeath - by OTACON - 06.04.2013, 00:15
Re: Respuesta: No lee OnPlayerDeath - by Jovazxc - 06.04.2013, 00:41
Respuesta: No lee OnPlayerDeath - by The_Scope - 06.04.2013, 02:30

Forum Jump:


Users browsing this thread: 1 Guest(s)