Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DeathmatchPlugin/DeathmatchPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
_killstreakManager.OnKill(attacker);

RefillPlayerAmmo.Do(attacker);
RefillPlayerHealth.onKill(attacker);

return HookResult.Continue;
}
Expand Down
33 changes: 33 additions & 0 deletions DeathmatchPlugin/Effects/RefillPlayerHealth.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using DeathmatchPlugin.Config;
using DeathmatchPlugin.Utilities;
namespace DeathmatchPlugin.Effects;

public static class RefillPlayerHealth {

public static void onKill(CCSPlayerController player)
{
if (player.Health == 100) return;
string giveBack = "weapon_healthshot";
string playerName = player.PlayerName;
player.PlayerPawn.Value.Health = 100; // give health
player.PlayerPawn.Value.MaxHealth = 100;
player.PlayerPawn.Value.ArmorValue = 100; // give armor
// PrintChat giveHealth
player.PrintToChat($"{DeathmatchConfig.ChatPrefix} {Colored.Blue(playerName)} : {Colored.Green("+100")} hp");
/*
Due to the nature of the HUD, the HUD is not updated until an action is taken by an external factor,
so the HUD is updated using healthShot.
*/
foreach (var weapon in player.PlayerPawn.Value.WeaponServices!.MyWeapons)
{
if (weapon is { IsValid:true, Value.IsValid: true } && weapon.Value.DesignerName.Contains("healthshot")) {
giveBack = weapon.Value.DesignerName;
weapon.Value.Remove();
}
}
// give HealthShot
VirtualFunctions.GiveNamedItem(player.PlayerPawn.Value.ItemServices!.Handle, giveBack, 0, 0, 0, 0);
}
}