Raised This Month: $ Target: $400
 0% 

How is revive from ledge health calculated?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-22-2023 , 20:53   Re: How is revive from ledge health calculated?
Reply With Quote #2

AFAIK, u suppose to lose 1 health per sec when u r ledge hanging

I don't know if there is a native to adjust the post hanged health

but you could store client pre health before ledge hanging and then restore it after being revived

something like this

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <left4dhooks>

int g_iPermHealth_Pre[MAXPLAYERS+1];
int g_iTempHealth_Pre[MAXPLAYERS+1];

int g_iPermHealth_Post[MAXPLAYERS+1];
int g_iTempHealth_Post[MAXPLAYERS+1];

public 
void OnPluginStart()
{
    
HookEvent("revive_success"Event_ReviveSuccessEventHookMode_Post);
}

public 
Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat vel[3], float angles[3], int &weapon)
{
    if (!
client || !IsClientInGame(client) || GetClientTeam(client) != || !IsPlayerAlive(client) || GetEntProp(clientProp_Send"m_isHangingFromLedge") == 0) return Plugin_Handled;
    
    
g_iPermHealth_Pre[client] = GetClientHealth(client);
    
g_iTempHealth_Pre[client] = RoundToFloor(L4D_GetTempHealth(client));
    return 
Plugin_Continue;
}

void Event_ReviveSuccess(Event event, const char[] namebool dontBroadcast)
{
    if (!
event.GetBool("ledge_hang")) return;
    
    
int client GetClientOfUserId (event.GetInt("subject"));
    if (!
client || !IsClientInGame(client)) return;
    
    
g_iPermHealth_Post[client] = g_iPermHealth_Pre[client];
    
g_iTempHealth_Post[client] = g_iTempHealth_Pre[client];
    
    
CreateTimer(0.1Timer_RestoreClientHealthGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}

Action Timer_RestoreClientHealth(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    if(
client == || !IsClientInGame(client)) return Plugin_Stop;
    
    
SetEntProp(clientProp_Send"m_iHealth"g_iPermHealth_Post[client], 1);
    
L4D_SetTempHealth(clientfloat(g_iTempHealth_Post[client]));
    return 
Plugin_Handled;

__________________

Last edited by alasfourom; 06-22-2023 at 21:04.
alasfourom is offline
 



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


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