SA-MP Forums Archive
OnPlayerDeath - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerDeath (/showthread.php?tid=538530)



OnPlayerDeath - Don_Cage - 22.09.2014

Hello i wonder is there a way to evade onplayerdeath returns SpawnPlayer just came on that part in gm i work on, sometime when i die, i get stucked it keeps respawning player and kills him in console you may see died,died,died it will spam death and all the time will resapwn and kill, respawn and kill.
There is nothing special defined in my OnPlayerDeath so far..

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerTextDrawHide(playerid, cSpeedo[4][playerid]);
    KillTimer(StartCountKM[playerid]);
   
    SetPlayerColor(playerid, 0xBBBBBB00);
    ASI_SetPlayerHealth(playerid, 30);
    PlayerTextDrawShow(playerid, Dead[0][playerid]);
    PlayerTextDrawShow(playerid, Dead[1][playerid]);
    PlayerTextDrawShow(playerid, Dead[2][playerid]);
    SetTimerEx("UnrentVehTime", Seconds(1), 0, "i", playerid);

    new deathreason[20], string[128];
    if(killerid != INVALID_PLAYER_ID)
    {
        if(reason == 0) { deathreason = "Melee"; }
        else if(reason == 36 || reason == 35 || reason == 40 || reason == 16) { deathreason = "Explosion"; }
        else if(reason == 18 || reason == 37) { deathreason = "Fire"; }
        else if(reason == 51) { deathreason = "Explosion"; }
        else if(reason == 50) { deathreason = "Heli-Kill"; }
        else { GetWeaponName(reason, deathreason, sizeof(deathreason)); }
       
        format(string, sizeof(string), "[DEATH]: %s (%i) has been killed by %s (%i) - %s", GetPlayerNameEx(playerid), playerid, GetPlayerNameEx(killerid), killerid, deathreason);
        SendAllAdminMessage(-1, string);
    }
    else
    {
        new text[30];
        if(reason == 51) { text = "Explosion"; }
        else if(reason == 53) { text = "Drowned"; }
        else if(reason == 54) { text = "Collision"; }
        else { text = "Death"; }
       
        format(string, sizeof(string), "[DEATH]: %s (%i) has been killed by Server. (%s)", GetPlayerNameEx(playerid), playerid, text);
        SendAllAdminMessage(-1, string);
    }
    TogglePlayerControllable(playerid, false);
    SetTimerEx("AfterDeath", Seconds(15), false, "i", playerid);
    return true;
}
pawn Код:
forward AfterDeath(playerid);
public  AfterDeath(playerid)
{
    if(pInfo[playerid][LifeInsurance] != 1)
    {
        ASI_SetPlayerHealth(playerid, 30);
        GameTextForPlayer(playerid, "~g~RELEASED FROM THE HOSPITAL", 5000, 4);
        SCM(playerid, -1, "SMS: Hospital: You had no life insurance and we had to charge money from you for hospital bills. (1200$)");
        SCM(playerid, -1, " "COLOR_HELP"HELP: You can buy Life Insurance in closest Insurance Agency!");
        ASI_SetPlayerPos(playerid, 1173.0325, -1323.2419, 15.3973);
        ASI_GiveCash(playerid, -1200);
        ASI_SetPlayerInterior(playerid, 0);
        ASI_SetPlayerVirtualWorld(playerid, 0);
        SetPlayerFacingAngle(playerid, 268.14);
        SetCameraBehindPlayer(playerid);
        SetPlayerToTeamColor(playerid);
        TogglePlayerControllable(playerid, true);
       
        PlayerTextDrawHide(playerid, Dead[0][playerid]);
        PlayerTextDrawHide(playerid, Dead[1][playerid]);
        PlayerTextDrawHide(playerid, Dead[2][playerid]);
    }
    else
    {
        ASI_SetPlayerHealth(playerid, 30);
        GameTextForPlayer(playerid, "~g~RELEASED FROM THE HOSPITAL", 5000, 4);
        SCM(playerid, -1, "SMS: Hospital: We have recieved money from your life insurance for the hospital bills.");
        ASI_SetPlayerPos(playerid, 1173.0325, -1323.2419, 15.3973);
        ASI_SetPlayerInterior(playerid, 0);
        ASI_SetPlayerVirtualWorld(playerid, 0);
        SetPlayerFacingAngle(playerid, 268.14);
        SetCameraBehindPlayer(playerid);
        SetPlayerToTeamColor(playerid);
        TogglePlayerControllable(playerid, true);
       
        PlayerTextDrawHide(playerid, Dead[0][playerid]);
        PlayerTextDrawHide(playerid, Dead[1][playerid]);
        PlayerTextDrawHide(playerid, Dead[2][playerid]);
    }
    return true;
}



Re: OnPlayerDeath - amirab - 22.09.2014

you want to evade from OnPlayerDeath ?


Re: OnPlayerDeath - Don_Cage - 22.09.2014

The point is that sometime keeps respawning and killing player in same time and that can be 100 times in a row, just wondering how to solve that


Re: OnPlayerDeath - amirab - 22.09.2014

set a var that shows player is dead , then OnPlayerSpawn use it to set pos in anywhere you want and freeze


Re: OnPlayerDeath - Don_Cage - 22.09.2014

Quote:
Originally Posted by amirab
Посмотреть сообщение
set a var that shows player is dead , then OnPlayerSpawn use it to set pos in anywhere you want and freeze
I set the pos, it's not problem in coords. It's problem sometime keeps respawn and kill as i told, and why it needs to respawn player at all?


Re: OnPlayerDeath - amirab - 22.09.2014

maybe maybe maybe it's because of this that written in OnPlayerDeath : ASI_SetPlayerHealth(playerid, 30);
don't set the health here , set it when player spawned


Re: OnPlayerDeath - Don_Cage - 22.09.2014

Quote:
Originally Posted by amirab
Посмотреть сообщение
maybe maybe maybe it's because of this that written in OnPlayerDeath : ASI_SetPlayerHealth(playerid, 30);
don't set the health here , set it when player spawned
I did put that after i noticed this happens to see if it wont kill player and respawn spam, but didn't help i'll remove that line anyways. And yet can i evade spawnplayer to be called?