// ServerInfo: the server's own welcome window, with its logo. /info (and an "Info" button in the inventory screen) // opens a menu with a banner image, the rules and buttons to the other plugins; new players see it once, and the logo // can stay in a corner of the HUD. // Images come from a web address (https) on an image host players' games accept: i.imgur.com, cdn.discordapp.com, // media.discordapp.net, raw.githubusercontent.com, avatars / user-images.githubusercontent.com, rustlegacy.io. Upload your // logo to Imgur or Discord and paste its address in plugins/config/ServerInfo.json. // Install: copy this file into the server's data folder, plugins/ServerInfo.cs. // Script engine rules: test objects with != null, no static fields that change, callbacks with one parameter at most. using RustLegacy; public class ServerInfoLink { public string Label { get; set; } = ""; /// Chat command the button runs, e.g. "/arena menu". public string Command { get; set; } = ""; /// Icon: an image address, or leave empty and give an item name. public string Image { get; set; } = ""; public string Item { get; set; } = ""; } public class ServerInfoConfig { public string Title { get; set; } = "Welcome"; /// Banner at the top of the window (https, see the allowed hosts above). public string Banner { get; set; } = "https://rustlegacy.io/logo.png"; public string Text { get; set; } = "Rules: no cheating, no racism, be nice in the chat. Have fun!"; /// Logo in the top left corner of the HUD (empty: none). public string HudLogo { get; set; } = ""; /// Open the window the first time a player joins. public bool ShowOnFirstJoin { get; set; } = true; public List Links { get; set; } = new List { new ServerInfoLink { Label = "Arena", Command = "/arena menu", Item = "M4" }, new ServerInfoLink { Label = "Airdrop settings", Command = "/airdrop settings", Item = "Supply Signal" }, }; } public class ServerInfoData { /// SteamIDs of the players who already saw the window. public List Seen { get; set; } = new List(); } public class ServerInfo : RustPlugin { ServerInfoConfig _config; ServerInfoData _data; public override void OnLoaded() { _config = LoadConfig(); _data = LoadData(); AddCommand( "info", cmd => Show( cmd.Player ), "About this server" ); foreach ( var p in Players ) Decorate( p ); } public override void OnPlayerConnected( RustPlayer player ) { Decorate( player ); if ( !_config.ShowOnFirstJoin || _data.Seen.Contains( player.SteamId ) ) return; _data.Seen.Add( player.SteamId ); SaveData( _data ); After( 8f, () => Show( player ) ); // once their game has loaded } void Decorate( RustPlayer p ) { SetButton( p, "info", "Info", "/info" ); if ( _config.HudLogo != "" ) SetHudText( p, "logo", "", "topleft", _config.HudLogo ); } void Show( RustPlayer p ) { if ( p == null || !p.IsValid ) return; var menu = new PluginMenu { Title = _config.Title, Image = _config.Banner, Text = _config.Text }; foreach ( var link in _config.Links ) menu.Buttons.Add( new PluginMenuButton { Label = link.Label, Command = link.Command, Image = link.Image, Item = link.Item } ); ShowMenu( p, menu ); } }