OnPlayerDeath: I'm still alive?
#1

Hey guys I'm having an issue that whenever I die (I've only tested suicide) that my health is at 0 however my character can still run around in the location of the death, in order to initiate OnPlayerSpawn I have to find something in the map that I can jump off in order to get some damage to the player's health in order to initiate OnPlayerSpawn.

Here is what I have under OnPlayerDeath.

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    
/**********************************SUICIDE CASE*********************************/
    
if(killerid == INVALID_PLAYER_ID)
    {
        new 
ce=cell_ref[playerid];
        
PlayerInfo [playerid] [pSkin] = GetPlayerSkin(playerid);
        
SetPVarInt(playerid"NewlyDead"1);
        
SetPVarInt(playerid,"spawned",0);
        
ResetPlayerWeapons(playerid);
        
SetPVarInt(playerid,"Weps",0);
        
PlayerInfo[playerid][Health]=100;
        
PlayerInfo[playerid][Armor]=0;
        
PlayerInfo[playerid][Interior]=-1;
        
GameTextForPlayer(playerid,"~r~~h~WASTED",8000,1);
        
PlayerTextDrawHide(playeridSpeedoText[playerid]);
        
SetPVarInt(playerid"Dead"1);
        
TextDrawHideForPlayer(playerid,txtTimeDisp);
        
PlayerTextDrawHide(playeridTxtZones[playerid]);
        
SetPlayerWantedLevel(playerid,0);
        if(
IsPlayerInAnyVehicle(playerid))
        {
            
PlayerTextDrawHide(playeridSpeedoText[playerid]);
        }
        
PlayerInfo[playerid][WantedLvl]=0;
        if(
gPlayerUsingLoopingAnim[playerid])
        {
            
gPlayerUsingLoopingAnim[playerid] = 0;
            
TextDrawHideForPlayer(playerid,txtAnimHelper);
        }
        if(
GetPVarInt(playerid,"Jailed") == 1)
        {
            
SetSpawnInfo(playeridNO_TEAM,42,cellInfo[ce][cellx],cellInfo[ce][celly],cellInfo[ce][cellz],cellInfo[ce][cella], 000000);
            
SetPlayerInterior(playerid,5);
            
SetPlayerWantedLevel(playerid,0);
            
PlayerInfo[playerid][WantedLvl]=0;
        }
        
GetPlayerClosestHospital(playerid);
        
SetPlayerInterior(playerid0);
        
SendClientMessage(playeridCOLOR_RED"SUCIDE");
        
SetPlayerHealth(playerid, -1000);
    }
    
/************************************************Dealing with a non suicide case ******************************************************************/
    
else if(killerid != INVALID_PLAYER_ID)
    {
        if(
IsPlayerInAnyVehicle(playerid))
        {
            
PlayerTextDrawHide(playeridSpeedoText[playerid]);
        }
        
//new org;
        //org=PlayerInfo[killerid][OrgID];
        // Generic Player Death Handling//
        
new ce=cell_ref[playerid];
        
SendClientMessage(playeridCOLOR_RED"NOT SUCIDE");
        
SetPlayerHealth(playerid, -1000);
        
SetPVarInt(playerid,"spawned",0);
        
SetPVarInt(playerid"NewlyDead"1);
        
ResetPlayerWeapons(playerid);
        
SetPVarInt(playerid,"Weps",0);
        
TextDrawHideForPlayer(playerid,txtTimeDisp);
        
PlayerTextDrawHide(playeridTxtZones[playerid]);
        
PlayerTextDrawHide(playeridSpeedoText[playerid]);
        if(
gPlayerUsingLoopingAnim[playerid])
        {
            
gPlayerUsingLoopingAnim[playerid] = 0;
            
TextDrawHideForPlayer(playerid,txtAnimHelper);
        }
        if(
GetPVarInt(playerid,"Jailed") == 0)//if the person who is murdered (Not suicide) is not jailed
        
{
            
GetPlayerClosestHospital(playerid);//set coords for hosp
            
SetPlayerInterior(playerid0);
        }
        else if(
GetPVarInt(playerid,"Jailed") == 1)//if the player killed is in jail
        
{
            
SetSpawnInfo(playeridNO_TEAM,42,cellInfo[ce][cellx],cellInfo[ce][celly],cellInfo[ce][cellz],cellInfo[ce][cella], 000000);//set coords for jail spawn
            
SetPlayerInterior(playerid,5);
            
SetPlayerWantedLevel(playerid,0);
        }
    
/*==========================================================Dealing with the Murderer========================*/
        
if(PlayerInfo[killerid][pInJail] ==1)// if the murderer is in prison
        
{
            new 
string[100];
            
format(string,sizeof(string),"[JAIL]Your sentence has been extended due to the murder of %s in prison",GetName(playerid));
            
SendClientMessage(killerid,COLOR_YELLOW,string);
            
KillTimer(JailTimer[killerid]);
            
PlayerInfo[killerid][pInJailTime] += 2;
            
format(string,sizeof(string),"Your time has been extended due to your crimes within Prison, New Time:%d Minutes",PlayerInfo[killerid][pInJailTime]);
            
SendClientMessage(killerid,COLOR_YELLOW,string);
            
JailTimer[killerid]= SetTimerEx("UnjailTimer",60000,false,"ii",killerid,PlayerInfo[killerid][pInJailTime]);
        }
        if(
IsInJob[playerid] == 1)
        {
            
IsInJob[playerid]=0;TipTime[playerid]=0;
            
KillTimer(InfoTimer[playerid]);
            
PlayerTutorialTime[playerid]=0;
            
DestroyDynamicCP(PizzaBoiCP[playerid]);
            
PlayerCheckpoint[playerid]=CHECKPOINT_NONE;
            
PlayerTips[playerid]=0;
            
PlayerEarnings[playerid]=0;
            if(
IsValidActor(PlayerCustomer[playerid])) { DestroyActor(PlayerCustomer[playerid]); }
            
PlayerSkin[playerid]=0;
            
HidePlayerIntroTexts(playerid);
            
HidePlayerInfoTexts(playerid);
            
HidePlayerPizzaBikeTexts(playerid);
            
HideTipTimeText(playerid);
            
SendClientMessage(playerid,-1," You have died and the part-time job has been canceled!");
        }
        
DestroyDynamicCP(CourierCP[playerid]);
        
DestroyDynamicCP(PizzaBoiCP[playerid]);
        
DestroyDynamicCP(FireTruckingCP[0][playerid]);
        
DestroyDynamicCP(FireTruckingCP[1][playerid]);
        
DestroyDynamicCP(FireTruckingCP[2][playerid]);
        
DestroyDynamicCP(FireTruckingCP[3][playerid]);
        
DestroyDynamicCP(FireTruckingCP[4][playerid]);
        
DestroyDynamicCP(FireTruckingCP[5][playerid]);
        
DestroyDynamicCP(TruckCP[playerid]);
        
InJob[playerid] = false;
        
DeliveryMan[playerid] = false;
        
PlayerInfo[playerid][Hunger]=100;
    }
    return 
1;

If anyone has any ideas about how to fix this please suggestions
Reply
#2

It's funny, but... couldn't "SetPlayerHealth(payerid, -1000);" do it ? I mean... it could be too much. Idk.

Set "0.0"
Reply
#3

what is
PlayerInfo[playerid][Health]=100;

linked to?.. under suicide
Reply
#4

Quote:
Originally Posted by TheRohlikar
Посмотреть сообщение
It's funny, but... couldn't "SetPlayerHealth(payerid, -1000);" do it ? I mean... it could be too much. Idk.

Set "0.0"
I added this to see if I could try to fix it

Quote:
Originally Posted by itsCody
Посмотреть сообщение
what is
PlayerInfo[playerid][Health]=100;

linked to?.. under suicide
I deleted both of these and it now works. I didn't think it'd do anything as it was working before I believe. So thanks for that I guess it was just so simple I didn't think about it.
Reply
#5

You don't have to put everything under the check of killerid != INVALID_PLAYER_ID.
Only the functions/arrays (etc.) which has killerid parameters.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)