Added protection to OnPlayerDamage

This commit is contained in:
AkjaHAsLk1IALk0MasH 2021-11-30 21:14:53 +07:00
parent cdeec8aa04
commit a00512fcf4

View file

@ -2178,6 +2178,7 @@ namespace TShockAPI
bool pvp = args.PVP;
bool crit = args.Critical;
byte direction = args.Direction;
PlayerDeathReason reason = args.PlayerDeathReason;
if (id >= Main.maxPlayers || TShock.Players[id] == null)
{
@ -2242,6 +2243,17 @@ namespace TShockAPI
return;
}
/*
* A player must take damage from another player in any case
* I didn't add sourceProjectile because the player can't always die from a projectile.
*/
if (TShock.Config.Settings.DisableCustomDeathMessages &&
(reason._sourcePlayerIndex == -1 || reason._sourceNPCIndex != -1 || reason._sourceOtherIndex != -1 || reason._sourceCustomReason != null))
{
TShock.Log.ConsoleDebug("Bouncer / OnPlayerDamage rejected custom death message from {0}", args.Player.Name);
args.Handled = true;
return;
}
}
/// <summary>Bouncer's KillMe hook stops crash exploits from out of bounds values.</summary>