1. I am trying to convert BasePlayer to ConsoleSystem.Arg.

    I know I can do: BasePlayer player = (BasePlayer)arg.connection.player;
    But I don't know how can I do the opposite.
     
  2. Wulf

    Wulf Community Admin

    It's a bit challenging to do the opposite I believe, and it might involve creating it all manually. Why do you need to convert it to Arg?
     
  3. Code:
    [ConsoleCommand("tabinfopanel")]
            void AlternadorTAB(ConsoleSystem.Arg arg)
            {
                if (arg != null && arg?.connection != null && arg?.connection?.player != null)
                {
                    BasePlayer player = (BasePlayer)arg.connection.player;
                    if (InventarioAbierto.Contains(player))
                    {
                        InventarioAbierto.Remove(player);
                        ChangePlayerSettings(player, "enable", "true");
                        RevealGUI(player);                }
                    else
                    {
                        InventarioAbierto.Add(player);
                        ChangePlayerSettings(player, "enable", "false");
                        DestroyGUI(player);
                    }
                }
            }
            void OnLootEntity(BasePlayer looter, BaseEntity target)
            {
                AlternadorTAB(looter);
            }
    I am trying to call AlternadorTAB from OnLootEntity, but OnLootEntity is BasePlayer and AlternadorTAB, ConsoleSystem.Arg
     
  4. Wulf

    Wulf Community Admin

    Why not abstract the GUI stuff into another method and call it from the command and the loot hook instead?
     
  5. Sorry Wulf, I don't follow. Could you explain it again?
     
  6. Wulf

    Wulf Community Admin

    Put your code in something else that accepts BasePlayer, then call that from your command instead of putting it all in there.
     
  7. I did not think on that, I guess my brain needs to take a break :p

    Thank you again Wulf.