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

I want to keep the survivor's Health - L4D2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gamer_kanelita
Senior Member
Join Date: Jun 2019
Location: Peru
Old 03-05-2021 , 23:53   I want to keep the survivor's Health - L4D2
Reply With Quote #1

Does anyone know how to maintain the health of a partner who has more than 100HP? I have a plugin that makes each chapter have 100HP all the survivors, the problem on my server is that when someone has for example 1500HP as a reward, but when changing the chapter they lose their 1500HP and have 100HP again, if someone would help me to A player who has more than 100HP does not lose his HP, but those who have less than 100HP start with 100HP in each chapter? :llorar::llorar:
gamer_kanelita is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-06-2021 , 05:35   Re: I want to keep the survivor's Health - L4D2
Reply With Quote #2

Not perfect... haven't tested in L4D2.

This works when player not reconnect.
- Player need stay on server at end of map and wait map change.

PHP Code:
public void OnPluginStart()
{

    
HookEvent("player_spawn"player_spawn);
}

StringMap remember;

public 
void OnClientDisconnect(int client)
{
    if(!
IsClientInGame(client) || !IsPlayerAlive(client) || IsFakeClient(client)) return;

    if(
remember == null)
        
remember CreateTrie();

    
int hp GetClientHealth(client);

    
char userid[60];
    
Format(useridsizeof(userid), "%i"GetClientUserId(client));

    
remember.SetValue(useridhptrue);
}

public 
void player_spawn(Event event, const char[] namebool dontBroadcast)
{
    if(
remember == null) return;

    
char userid[60];
    
int id event.GetInt("userid");
    
    
Format(useridsizeof(userid), "%i"id);
    
    
int client GetClientOfUserId(id);
    
    if(
IsFakeClient(client) || GetClientTeam(client) <= || !IsPlayerAlive(client)) return;

    
// userid found from Trie array
    
int hp;
    if(!
remember.GetValue(useridhp)) return;

    
remember.Remove(userid);

    if(
hp <= GetClientHealth(client)) return;

    
// Delay 1 sec
    
DataPack pack;
    
CreateDataTimer(1.0delaypack);
    
pack.WriteCell(id);
    
pack.WriteCell(hp);
    
pack.Reset();
}

public 
Action delay(Handle timerDataPack pack)
{
    
int client GetClientOfUserId(pack.ReadCell());

    if(!
client || !IsClientInGame(client) || !IsPlayerAlive(client)) return Plugin_Continue;

    
int hp pack.ReadCell();

    
SetEntProp(clientProp_Send"m_iHealth"hp);
    
PrintToChat(client"[SM] HP restored");

    return 
Plugin_Continue;


Maybe there is already plugin what do this.
__________________
Do not Private Message @me
Bacardi 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 06:05.


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