Refillvitals command not working

The built-in refillvitals command isn't working when the plugin is enabled. It will work when inside a pvp "zone" with raidable bases, but everywhere else on the map the command will refill water and food, but not health. Is there a setting somewhere that i could change to make this work for us? 

for some reason Facepunch decided to heal the player by attacking them with negative damage from a bullet, rather than healing them with the native BasePlayer.Heal method

		private static void AdjustHealth(BasePlayer player, float amount, string bone = null)
		{
			HitInfo hitInfo = new HitInfo(player, player, DamageType.Bullet, 0f - amount);
			if (!string.IsNullOrEmpty(bone))
			{
				hitInfo.HitBone = StringPool.Get(bone);
			}
			player.OnAttacked(hitInfo);
		}​

lol

go to line 920 and add this code below. let me know if it works

            if (isVictim && victim == attacker && hitInfo.damageTypes.GetMajorityDamageType() == DamageType.Bullet && hitInfo.damageTypes.Total() < 0f)
            {
                return true;
            }​

Sorry for the delayed response :) 

I tried adding the code below Line 920 and when reloading the plugin i get the following error.

Error while compiling: TruePVE.cs(924,27): error CS0841: A local variable `attacker' cannot be used before it is declared

This is the code starting at line 920

         var victim = entity as BasePlayer;
			
			//addition for refillvitals
			if (isVictim && victim == attacker && hitInfo.damageTypes.GetMajorityDamageType() == DamageType.Bullet && hitInfo.damageTypes.Total() < 0f)
			{
				return true;
			}
			
            // handle suicide
            if (isVictim && !entity.IsNpc && victim.userID.IsSteamId() && hitInfo.damageTypes?.Get(DamageType.Suicide) > 0)
            {
                if (trace) Trace($"DamageType is suicide; blocked? { (ruleSet.HasFlag(RuleFlags.SuicideBlocked) ? "true; block and return" : "false; allow and return") }", 1);
                if (ruleSet.HasFlag(RuleFlags.SuicideBlocked))
                {
                    Message(entity as BasePlayer, "Error_NoSuicide");
                    return false;
                }
                return true;
            }

 

ah ok

put var attacker = hitInfo.Initiator as BasePlayer; on the line under var victim = entity as BasePlayer

make sure to delete and then put it there

var victim = entity as BasePlayer;​
var attacker = hitInfo.Initiator as BasePlayer;

I'm sorry man, its still giving me errors. This time it says this in the console after reloading the plugin:

Error while compiling: TruePVE.cs(969,17): error CS0128: A local variable named `attacker' is already defined in this scope

 

                        var victim = entity as BasePlayer;​
			var attacker = hitInfo.Initiator as BasePlayer;
			
			//addition for refillvitals
			if (isVictim && victim == attacker && hitInfo.damageTypes.GetMajorityDamageType() == DamageType.Bullet && hitInfo.damageTypes.Total() < 0f)
			{
				return true;
			}
			
            // handle suicide
            if (isVictim && !entity.IsNpc && victim.userID.IsSteamId() && hitInfo.damageTypes?.Get(DamageType.Suicide) > 0)
            {
                if (trace) Trace($"DamageType is suicide; blocked? { (ruleSet.HasFlag(RuleFlags.SuicideBlocked) ? "true; block and return" : "false; allow and return") }", 1);
                if (ruleSet.HasFlag(RuleFlags.SuicideBlocked))
                {
                    Message(entity as BasePlayer, "Error_NoSuicide");
                    return false;
                }
                return true;
            }

as i said make sure to delete and then put it there =p