1. I am having trouble converting SteamId to Player Name ..
    Can you help me?
     
  2. Wulf

    Wulf Community Admin

    var player = BasePlayer.FindPlayer(steamId);
    var name = player.displayName;
     
  3. Where I put this VAR
    Code:
    namespace Oxide.Plugins
    {
        [Info("Inventory Cleaner", "PaiN", "1.1.3", ResourceId = 0)]
        [Description("This plugin allows players with permission to clean all/their/target's inventory.")]
        class InventoryCleaner : RustPlugin
        {          
            void Loaded() => permission.RegisterPermission(this.Name.ToLower()+".use", this);
            [ChatCommand("Limparinvtodos")]
            void cmdInvCleanAll(BasePlayer player, string cmd, string[] args)
            {
                string steamId = Convert.ToString(player.userID);
                if (permission.UserHasPermission(steamId, "inventorycleaner.use"))
                {
                    if (args.Length == 1)
                    {
                        SendReply(player, "Digite: <color='#007FFF'>/limparinvtodos</color>\n~Para limpar inventario de todos jogadores");
                        return;
                    }
                  
                        var players = BasePlayer.activePlayerList as List<BasePlayer>;
                        foreach (BasePlayer current in BasePlayer.activePlayerList)
                        {
                            current.inventory.Strip();
                            Puts(player.displayName + " Você limpou todos os inventarios!");
                            PrintToChat("<color=orange>[Limpeza]</color> " + player.displayName + " limpou o inventario de todos: (" + players.Count + ") !");
                            SendReply(player, "<color=orange>[Limpeza]</color> " + "Você limpo o inventario dos seguintes jogadores: " + players.Count + "");
                      
                        }
                      
                    }
                    else
                    {
                        SendReply(player, "Você nao tem permissao para usar este comando!");
                        return;      
                    }
                }
    
     
  4. Wulf

    Wulf Community Admin

    You have everything you need there already, so why do you need to find it again? You have the BasePlayer for both the sender (player) and the target (current), both of which offer the .displayName.
     
  5. But when I type there is no game the command it says so no console

    Code:
    Failed to call hook 'cmdInvClean' on plugin 'InventoryCleaner v1.1.3' (NullReferenceException: Object reference not set to an instance of an object)

    LOG

    Code:
    19:20 [Stacktrace]   at Oxide.Plugins.InventoryCleaner.cmdInvClean (.BasePlayer player, System.String cmd, System.String[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.InventoryCleaner.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in <filename unknown>:0 
     
  6. Wulf

    Wulf Community Admin

    That error is coming from cmdInvClean, not the portion you posted above that is cmdInvCleanAll.
     
  7. Code:
    var trajeto = BasePlayer.FindPlayer(steamId);
    ERROR

    Code:
    Error while compiling InventoryCleaner.cs(60,30): error CS0117: `BasePlayer' does not contain a definition for `FindPlayer'
     
    Last edited by a moderator: Feb 14, 2017
  8. Wulf

    Wulf Community Admin

    Try FindPlayerById, but back to my question... why are you trying to find them by an idea when the entire player (name and ID) are already available in the code you showed me?
     
  9. Because when I type the command in the chat it does not clean the player's inventory.

    Ex:
    Code:
    /limparinv "Theusz"
    Does not clean the player inventory and error in the console.
    Only works if I enter the player ID, if I enter the Name does not work
     
  10. Wulf

    Wulf Community Admin

    Is that exactly how the user's name starts, casing and all? Otherwise you won't get a match.