Raised This Month: $ Target: $400
 0% 

How is revive from ledge health calculated?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
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 #1

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
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-24-2023 , 02:52   Re: How is revive from ledge health calculated?
Reply With Quote #2

Quote:
Originally Posted by alasfourom View Post
something like this
PHP Code:
// Gets the health of the survivor from before they were incapacitated
native int L4D2Direct_GetPreIncapHealth(int client);

// Gets the temporary health of the survivor from before they were incapacitated
native int L4D2Direct_GetPreIncapHealthBuffer(int client); 
__________________
Silvers is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-24-2023 , 10:17   Re: How is revive from ledge health calculated?
Reply With Quote #3

Quote:
Originally Posted by Silvers View Post
PHP Code:
// Gets the health of the survivor from before they were incapacitated
native int L4D2Direct_GetPreIncapHealth(int client);

// Gets the temporary health of the survivor from before they were incapacitated
native int L4D2Direct_GetPreIncapHealthBuffer(int client); 
Ahh, you are right, didn't check that, this should make it a lot easier now
__________________
alasfourom 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 01:51.


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