PDA

View Full Version : OnPlayerDeath: I'm still alive?


Tass007
05/12/2016, 06:23 AM
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.

public OnPlayerDeath(playerid, killerid, reason)
{
/**********************************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(playerid, SpeedoText[playerid]);
SetPVarInt(playerid, "Dead", 1);
TextDrawHideForPlayer(playerid,txtTimeDisp);
PlayerTextDrawHide(playerid, TxtZones[playerid]);
SetPlayerWantedLevel(playerid,0);
if(IsPlayerInAnyVehicle(playerid))
{
PlayerTextDrawHide(playerid, SpeedoText[playerid]);
}
PlayerInfo[playerid][WantedLvl]=0;
if(gPlayerUsingLoopingAnim[playerid])
{
gPlayerUsingLoopingAnim[playerid] = 0;
TextDrawHideForPlayer(playerid,txtAnimHelper);
}
if(GetPVarInt(playerid,"Jailed") == 1)
{
SetSpawnInfo(playerid, NO_TEAM,42,cellInfo[ce][cellx],cellInfo[ce][celly],cellInfo[ce][cellz],cellInfo[ce][cella], 0, 0, 0, 0, 0, 0);
SetPlayerInterior(playerid,5);
SetPlayerWantedLevel(playerid,0);
PlayerInfo[playerid][WantedLvl]=0;
}
GetPlayerClosestHospital(playerid);
SetPlayerInterior(playerid, 0);
SendClientMessage(playerid, COLOR_RED, "SUCIDE");
SetPlayerHealth(playerid, -1000);
}
/************************************************De aling with a non suicide case ************************************************** ****************/
else if(killerid != INVALID_PLAYER_ID)
{
if(IsPlayerInAnyVehicle(playerid))
{
PlayerTextDrawHide(playerid, SpeedoText[playerid]);
}
//new org;
//org=PlayerInfo[killerid][OrgID];
// Generic Player Death Handling//
new ce=cell_ref[playerid];
SendClientMessage(playerid, COLOR_RED, "NOT SUCIDE");
SetPlayerHealth(playerid, -1000);
SetPVarInt(playerid,"spawned",0);
SetPVarInt(playerid, "NewlyDead", 1);
ResetPlayerWeapons(playerid);
SetPVarInt(playerid,"Weps",0);
TextDrawHideForPlayer(playerid,txtTimeDisp);
PlayerTextDrawHide(playerid, TxtZones[playerid]);
PlayerTextDrawHide(playerid, SpeedoText[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(playerid, 0);
}
else if(GetPVarInt(playerid,"Jailed") == 1)//if the player killed is in jail
{
SetSpawnInfo(playerid, NO_TEAM,42,cellInfo[ce][cellx],cellInfo[ce][celly],cellInfo[ce][cellz],cellInfo[ce][cella], 0, 0, 0, 0, 0, 0);//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 :D

TheRohlikar
05/12/2016, 06:40 AM
It's funny, but... couldn't "SetPlayerHealth(payerid, -1000);" do it ? I mean... it could be too much. Idk.

Set "0.0"

itsCody
05/12/2016, 07:06 AM
what is
PlayerInfo[playerid][Health]=100;

linked to?.. under suicide

Tass007
05/12/2016, 08:05 AM
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 :D

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.

oMa37
05/12/2016, 08:12 AM
You don't have to put everything under the check of killerid != INVALID_PLAYER_ID.
Only the functions/arrays (etc.) which has killerid parameters.