Raised This Month: $32 Target: $400
 8% 

[L4D2] Starting Health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zbeer
SourceMod Donor
Join Date: Aug 2010
Old 02-27-2011 , 07:30   [L4D2] Starting Health
Reply With Quote #1

How can I set the Survivorīs HP when starting maps (safe room) and when they are spawning in a COOP server?

Itīs pretty easy do that with respawn (after death), climbed and revived:
sm_cvar z_survivor_respawn_health
sm_cvar survivor_ledge_grab_health
sm_cvar survivor_revive_health

but I donīt know how to do this with starting health in the spawn (reconnect), and/or in the safe.

Can anybody help?
Thanks!
Zbeer is offline
Hawkins
Senior Member
Join Date: Jul 2021
Old 10-12-2021 , 06:14   Re: [L4D2] Starting Health
Reply With Quote #2

Bumping since i need to know this too.
Hawkins is offline
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
Austin
Senior Member
Join Date: Oct 2005
Old 10-16-2021 , 03:47   Re: [L4D2] Starting Health
Reply With Quote #4

Quote:
Originally Posted by Hawkins View Post
Bumping since i need to know this too.
This plugin will do what you are looking for.
It sets the health of every survivor when the map starts and when they spawn in the safe room.

You can boost the health or reduce the health by setting the one cvar.
Just make sure you use only integer values like:

abs_l4d2_StartingHealth 150
abs_l4d2_StartingHealth 65

This is a modification of a plugin I wrote that when a player spawns in the safe room,
if their health is less then 50% boost them to 50%.
So you will notice when the health is set I also

Reset the incap count
Turn off the is going to die
Turn off the third strike
Reset their temp health
Turn off the heartbeat sound if they were B+W

The only strange thing about this plugin is the health is also set when you take over a bot.
I guess the engine is “spawning” you as the bot and thus player_spawn is called for that too.

Anyone know how I can tell if player_spawn is being called for a bot take over instead of a map start or safe room spawn?
Attached Files
File Type: sp Get Plugin or Get Source (L4D2_HealthSet.sp - 114 views - 2.0 KB)

Last edited by Austin; 10-16-2021 at 05:17.
Austin is offline
Hawkins
Senior Member
Join Date: Jul 2021
Old 10-19-2021 , 13:58   Re: [L4D2] Starting Health
Reply With Quote #5

Ye thats the issue, i dont want survivors to re-fill their HP everytime someone ragequits / joins and takes over a survivor bot.

I need to set it at the start for all survivors and thats it.
Similar to RayMans Admin System chat command: !max_health all 200
Hawkins is offline
Austin
Senior Member
Join Date: Oct 2005
Old 10-21-2021 , 19:30   Re: [L4D2] Starting Health
Reply With Quote #6

Quote:
Originally Posted by Hawkins View Post
Ye thats the issue, i dont want survivors to re-fill their HP everytime someone ragequits / joins and takes over a survivor bot.
Here is a version that doesn't set health on bot takeover.
It only sets health at the start of a campagin and when you spawn in the safe rooms.

Try it out and let me know how it works for you.
I tested it on my server and it seems to work as expected.

It is a hack since I am only allowing the health set when the spawn is less than 40 seconds into the round.

It is taking about 17 seconds for my server to spawn the players after the round starts.
40 seconds should be good for even slow servers?
Attached Files
File Type: sp Get Plugin or Get Source (ABS_L4D2_HealthSet.sp - 135 views - 2.4 KB)

Last edited by Austin; 10-22-2021 at 00:47.
Austin is offline
Hawkins
Senior Member
Join Date: Jul 2021
Old 10-22-2021 , 06:20   Re: [L4D2] Starting Health
Reply With Quote #7

Quote:
Originally Posted by Austin View Post
Here is a version that doesn't set health on bot takeover.
It only sets health at the start of a campagin and when you spawn in the safe rooms.

Try it out and let me know how it works for you.
I tested it on my server and it seems to work as expected.

It is a hack since I am only allowing the health set when the spawn is less than 40 seconds into the round.

It is taking about 17 seconds for my server to spawn the players after the round starts.
40 seconds should be good for even slow servers?
Doesnt work. HP is still being set to 120 when someone takes over a bot by joining the game or changing teams and back to survivors team.
Hawkins is offline
Austin
Senior Member
Join Date: Oct 2005
Old 10-22-2021 , 14:21   Re: [L4D2] Starting Health
Reply With Quote #8

Quote:
Originally Posted by Hawkins View Post
Doesnt work. HP is still being set to 120 when someone takes over a bot by joining the game or changing teams and back to survivors team.
Are you sure you deleted from your server the original one I posted?
Are you using the new one, this link?
https://www.sourcemod.net/vbcompiler.php?file_id=191992

It is working on my server as described.
Austin is offline
Hawkins
Senior Member
Join Date: Jul 2021
Old 10-22-2021 , 14:38   Re: [L4D2] Starting Health
Reply With Quote #9

Yes i am sure. Tested it again the one you posted. Ive edited the sp to activate if lower than 101 and set it to 130. Still sets HP back when changing to spectator and back to survivor team.
I walked around out of safe room for the round to "start" then spawned spitter to damage my team and changed team and then back to survivor.

Last edited by Hawkins; 10-22-2021 at 14:39.
Hawkins is offline
Austin
Senior Member
Join Date: Oct 2005
Old 10-22-2021 , 15:17   Re: [L4D2] Starting Health
Reply With Quote #10

Post your source code and I will take a look at it.
Austin is offline
Reply


Thread Tools
Display Modes

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 02:20.


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