1. Is there an example available somewhere to show just a PNG logo when someone connects and let it stay?
     
  2. 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");
    }
    Just replace the Url with a link to your logo and adjust AnchorMin/AnchorMax for changing its position and size.
     
  3. Whoa, I didn't even thought about using that hook. Thanks for the tip, this helps me very much, thanks
     
  4. This wouldn't be the best way to do this, as it would be called every time a player exits sleeping (respwaning, teleporting etc), using OnPlayerInit would probably be the best way of doing this, as its only called when they connect
     
  5. That's true. But it would complicate things, because OnPlayerInit gets called too early. You would have to use a timer to make it work.
     
  6. Not necessarily, I played around with something like this a while ago and didn't have to use timers ;) regardless, its still better than using the other hook
     
  7. Well, now it's not working anymore. ;) But you're right, the following is probably the better solution:

    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
    }
    Adapted from: Solved - CUI not working in OnPlayerInit? | Oxide
     
  8. 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");
            }
    
    That way you don't have a timer constantly looping until they wake up.
     
    Last edited by a moderator: Apr 8, 2017
  9. Does anyone have the plugin for this please?
     
  10. if you put UI stuff from a couple posts ago into the latest post from @JoeSheep you got a super basic one that should work