Is there an example available somewhere to show just a PNG logo when someone connects and let it stay?
Showing a simple logo on player connection?
Discussion in 'Rust Development' started by Riddle, Apr 1, 2017.
-
Yes, that's possible with the RustCUI from Oxide.
Oxide/RustCui.cs at develop · OxideMod/Oxide · GitHub -
You can do something like this.
Code:void OnPlayerSleepEnded(BasePlayer player) { CuiElementContainer container = new CuiElementContainer(); container.Add(new CuiElement { Name = "logo", Components = { new CuiRawImageComponent { Url = "https://pbs.twimg.com/profile_images/378800000826280720/8f9145eff97d162122af02fc1488c611_400x400.png", Sprite="assets/content/textures/generic/fulltransparent.tga" }, new CuiRectTransformComponent { AnchorMin = "0.00 0.00", AnchorMax = "0.09 0.16" } } }); CuiHelper.AddUi(player, container); }void OnPlayerSleep(BasePlayer player) { CuiHelper.DestroyUi(player, "logo"); }
-
Whoa, I didn't even thought about using that hook. Thanks for the tip, this helps me very much, thanks
-
-
-
-
Code:void OnPlayerInit(BasePlayer player) { AddUi_IfConnected(player); }private void AddUi_IfConnected(BasePlayer player) { if (player.HasPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot)) { timer.Once(1, () => AddUi_IfConnected(player)); return; } // Add Ui here }
-
I think you can get better performance with your code by doing the following instead:
Code:using System.Collections.Generic; using Oxide.Game.Rust.Cui; HashSet<ulong> JustJoined = new HashSet<ulong>(); void OnPlayerInit(BasePlayer player) { JustJoined.Add(player.userID); } void OnPlayerSleepEnded(BasePlayer player) { if (JustJoined.Contains(player.userID)) { CreateUI(player); JustJoined.Remove(player.userID); } } void CreateUI(BasePlayer player) { //UI SHITZ } void OnPlayerDisconnected(BasePlayer player) { if (JustJoined.Contains(player.userID)) //Just in case they leave before getting in game after OnPlayerInit has been called. JustJoined.Remove(player.userID); else CuiHelper.DestroyUi(player, "Sum UI"); }
Last edited by a moderator: Apr 8, 2017 -
Does anyone have the plugin for this please?
-