Amon_PRC8/_module/nss/js_onplayerdying.nss
Jaysyn904 c5cffc37af Initial Commit
Initial Commit [v1.01]
2025-04-03 19:00:46 -04:00

40 lines
1.1 KiB
Plaintext

//:://////////////////////////////////////////////
//:: Name: OnPlayerDying
//:: FileName: js_onplayerdying
//:://////////////////////////////////////////////
/*
Sets the local int to tell the Module that a
PC is hurt/dying and calls that to another int
in case they log off.
Props to 'spilth" for his excellent tutorial.
*/
//:://////////////////////////////////////////////
//:: Created By: SPBTooL
//:: Modified By: Jer Wolfe
//:: Created On:
//:://////////////////////////////////////////////
#include "js_include"
void main()
{
object oPC = GetLastPlayerDying();
// Let the module know somebody is not alive
object oModule = GetModule();
int iPCHealth = GetLocalInt(oPC, "PCHealth");
SetLocalInt(oModule, "PCAlive", FALSE);
SetLocalInt(oPC, "PCHealth", PC_HEALTH_DYING);
// Check if they stablized, disconnected and then reconnected...
if ((iPCHealth != PC_HEALTH_DEAD) && (GetCurrentHitPoints(oPC) <= -10))
{
SetLocalInt(oPC, "PCHealth", PC_HEALTH_DEAD);
SetLocalInt(oPC, "LastHitPoints", GetCurrentHitPoints(oPC));
}
else
{
// OnHeartbeat
}
}