Raised This Month: $51 Target: $400
 12% 

[L4D2] Set max survivor hp with specified flag.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
foquaxticity
Junior Member
Join Date: Jul 2018
Old 11-25-2018 , 04:27   [L4D2] Set max survivor hp with specified flag.
Reply With Quote #1

For example a survivor joins with flag "o", he has already 150hp.

cvars something like this;
flags_hp "oj" // All the flags that get different health value
maxsurvivor_hp "150" // Health of those flags

Outlines/Speed work the same, no need to make survivor slow at 400hp when he has max hp of 1000, same with outlines, basically its only a hp change which i cant find anywhere, im surprised no one has made it in 10 years, since it could make flagged players stand out not only with tag but with some abilities.

Thanks!
foquaxticity is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 03-09-2019 , 07:44   Re: [L4D2] Set max survivor hp with specified flag.
Reply With Quote #2

Untested:

PHP Code:
#include <sourcemod>

#define FH_VERSION "1.0"

public Plugin myinfo =
{
    
name "[L4D & L4D2] Flag-based Health",
    
author "Psyk0tik (Crasher_3637) & foquaxticity",
    
description "Sets players' health based on their flags.",
    
version FH_VERSION,
    
url "https://forums.alliedmods.net/showthread.php?t=312288"
};

ConVar g_cvEnableg_cvFlagsg_cvMaxHealth;

public 
void OnPluginStart()
{
    
g_cvEnable CreateConVar("fh_enable""1""Enable \"Flag-based Health\"?\n0: OFF\n1: ON"_true0.0true1.0);
    
g_cvFlags CreateConVar("fh_flags""z""Players must have either the \"fh_admin\" override, or one or more of these flags to have custom health.");
    
g_cvMaxHealth CreateConVar("fh_maxhealth""150""Max health for affected players."_true1.0true65535.0);
    
CreateConVar("fh_version"FH_VERSION"Version of \"Flag-based Health.\""FCVAR_NOTIFY|FCVAR_DONTRECORD);

    
HookEvent("player_spawn"vPlayerSpawn);

    
AutoExecConfig(true"l4d_flag-based_health");
}

public 
void vPlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    if (!
g_cvEnable.BoolValue)
    {
        return;
    }

    
int iSurvivor GetClientOfUserId(event.GetInt("userid"));
    if (
iSurvivor <= MaxClients && IsClientInGame(iSurvivor) && GetClientTeam(iSurvivor) == 2)
    {
        
char sFlags[32];
        
g_cvFlags.GetString(sFlagssizeof(sFlags));
        
int iFlags ReadFlagString(sFlags);
        if ((
iFlags != && (GetUserFlagBits(iSurvivor) & iFlags)) || CheckCommandAccess(iSurvivor"fh_admin"ADMFLAG_ROOT))
        {
            
SetEntityHealth(iSurvivorg_cvMaxHealth.IntValue);
        }
    }

Attached Files
File Type: sp Get Plugin or Get Source (l4d_flag-based_health.sp - 350 views - 1.6 KB)
__________________
Psyk0tik is offline
Skyy
AlliedModders Donor
Join Date: Jan 2010
Location: Toronto, Canada
Old 03-10-2019 , 14:48   Re: [L4D2] Set max survivor hp with specified flag.
Reply With Quote #3

because the player_spawn event doesn't always fire for survivors.

SetEntProp(client, Prop_Send, "m_iMaxHealth", 150); -> If an entity health is above this value, it will decay and the health will not affect survivor movements/UI elements properly. Also, if not set here, medkits will not heal above 100 or allow healing when at or above 100, regardless of the players' maximum health!

Instead of using player_spawn , i recommend using player_team , which will always fire.

Last edited by Skyy; 03-10-2019 at 14:49.
Skyy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode