C#:
// ╔═══════════════════════════════════════════════════════════════════════════╗
// ║
// ║ Plugin : ServerLogo
// ║ Author : WuyZar
// ║ Discord : https://discord.gg/NVwRcQwGwh
// ║ Shop : https://codefling.com/wuyzar
// ║
// ║ All rights reserved. Redistribution and modification are forbidden !
// ║
// ╚═══════════════════════════════════════════════════════════════════════════╝
using Oxide.Game.Rust.Cui;
using Oxide.Core;
using UnityEngine;
using System.Collections.Generic;
namespace Oxide.Plugins
{
[Info("ServerLogo", "WuyZar", "1.2.0")]
[Description("Discord: https://discord.gg/NVwRcQwGwh")]
public class ServerLogo : RustPlugin
{
private const string Layer = "UI.ServerLogo";
private const string Perm = "serverlogo.use";
private PluginConfig config;
private class PluginConfig
{
public string ServerName { get; set; } = "SERVER NAME";
public string LogoUrl { get; set; } = "https://image.noelshack.com/fichiers/2025/49/1/1764607052-testlogo.png";
public string RedColor { get; set; } = "0.8 0.2 0.15 1";
public string BlackColor { get; set; } = "0.1 0.1 0.1 1";
public string WhiteColor { get; set; } = "1 1 1 1";
public string ClickCommand { get; set; } = "chat.say \"Thank you for using ServerLogo !\" ";
}
protected override void LoadDefaultConfig() { config = new PluginConfig(); SaveConfig(); }
protected override void SaveConfig() => Config.WriteObject(config, true);
protected override void LoadConfig() { base.LoadConfig(); config = Config.ReadObject<PluginConfig>() ?? new PluginConfig(); }
private void Init()
{
permission.RegisterPermission(Perm, this);
}
private void OnServerInitialized()
{
timer.Once(1f, () =>
{
foreach (var player in BasePlayer.activePlayerList)
{
if (permission.UserHasPermission(player.UserIDString, Perm))
ShowUI(player);
}
});
}
private void Unload()
{
foreach (var player in BasePlayer.activePlayerList)
DestroyUI(player);
}
private void OnPlayerConnected(BasePlayer player)
{
if (player == null) return;
timer.Once(1f, () =>
{
if (player != null && player.IsConnected && permission.UserHasPermission(player.UserIDString, Perm))
ShowUI(player);
});
}
private void ShowUI(BasePlayer player)
{
DestroyUI(player);
var elements = new CuiElementContainer();
float textWidth = (config.ServerName.Length * 5f) + 3f;
if (textWidth < 100f) textWidth = 100f;
elements.Add(new CuiElement { Name = Layer, Parent = "Hud", Components = {
new CuiImageComponent { Color = config.RedColor },
new CuiRectTransformComponent { AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = $"-{textWidth + 215} 17", OffsetMax = "-215 43" }
}});
elements.Add(new CuiElement { Name = Layer + ".Inner", Parent = Layer, Components = {
new CuiImageComponent { Color = config.BlackColor },
new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "3 3", OffsetMax = "-3 -3" }
}});
elements.Add(new CuiElement { Name = Layer + ".Text", Parent = Layer + ".Inner", Components = {
new CuiTextComponent { Text = config.ServerName, FontSize = 10, Align = TextAnchor.MiddleCenter, Color = config.WhiteColor },
new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" }
}});
elements.Add(new CuiElement { Name = Layer + ".Logo", Parent = "Hud", Components = {
new CuiRawImageComponent { Url = config.LogoUrl, Color = "1 1 1 1" },
new CuiRectTransformComponent { AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-265 48", OffsetMax = "-215 98" }
}});
elements.Add(new CuiButton { Button = { Command = "serverlogo.click", Color = "0 0 0 0" }, Text = { Text = "" },
RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }
}, Layer + ".Logo", Layer + ".Logo.Btn");
CuiHelper.AddUi(player, elements);
}
private void DestroyUI(BasePlayer player)
{
if (player == null) return;
CuiHelper.DestroyUi(player, Layer);
CuiHelper.DestroyUi(player, Layer + ".Logo");
}
[ConsoleCommand("serverlogo.click")]
private void CmdClick(ConsoleSystem.Arg arg)
{
var player = arg.Player();
if (player == null || string.IsNullOrEmpty(config.ClickCommand)) return;
player.SendConsoleCommand(config.ClickCommand);
}
}
}