This suppose to work when player spawn at start of map or safe room.
cvar:
survivor_start_health
- 150 is default value, edit code or add cvar in config file.
PHP Code:
bool IsInCheckpoint[10];
ConVar survivor_start_health;
public void OnPluginStart()
{
HookEvent("player_spawn", spawn);
//HookEvent("player_entered_start_area", area);
HookEvent("player_entered_checkpoint", checkpoint);
HookEvent("player_left_checkpoint", checkpoint);
survivor_start_health = CreateConVar("survivor_start_health", "150", " - health amount when map start", _, true, 1.0, true, 9999.0);
}
public void spawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if(GetClientTeam(client) != 2) return;
if(GetEntProp(client, Prop_Send, "m_isInMissionStartArea") || IsInCheckpoint[client])
{
//SetEntityHealth(client, 999);
CreateTimer(1.0, delay, event.GetInt("userid"), TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action delay(Handle timer, any data)
{
int client = GetClientOfUserId(data);
if(!client || !IsClientInGame(client)) return;
SetEntityHealth(client, survivor_start_health.IntValue);
}
public void area(Event event, const char[] name, bool dontBroadcast)
{
}
public void checkpoint(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if(!client) return;
if(StrEqual(name, "player_entered_checkpoint"))
{
IsInCheckpoint[client] = true;
}
else
{
IsInCheckpoint[client] = false;
}
}
__________________