View Single Post
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-13-2021 , 03:52   Re: [L4D2] Starting Health
Reply With Quote #3

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"_true1.0true9999.0);
}

public 
void spawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
    if(
GetClientTeam(client) != 2) return;
    
    if(
GetEntProp(clientProp_Send"m_isInMissionStartArea") || IsInCheckpoint[client])
    {
        
//SetEntityHealth(client, 999);

        
CreateTimer(1.0delayevent.GetInt("userid"), TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action delay(Handle timerany data)
{
    
int client GetClientOfUserId(data);
    
    if(!
client || !IsClientInGame(client)) return;

    
SetEntityHealth(clientsurvivor_start_health.IntValue);
}

public 
void area(Event event, const char[] namebool dontBroadcast)
{
}

public 
void checkpoint(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
    if(!
client) return;

    if(
StrEqual(name"player_entered_checkpoint"))
    {
        
IsInCheckpoint[client] = true;
    }
    else
    {
        
IsInCheckpoint[client] = false;
    }
    

__________________
Do not Private Message @me
Bacardi is offline