1. Oxide for Rust Legacy has been discontinued and is no longer supported. No updates or additions will be made, and Rust Legacy-specific plugin submissions will no longer be accepted. We recommend upgrading to the latest version of Rust as able.
    Dismiss Notice
  1. mcnovinho08

    mcnovinho08 Plugin Developer

    Code (Text):
    [Oxide] 22:36 [Info] AdminWarn was compiled successfully in 3553ms
    [Oxide] 22:36 [Info] Unloaded plugin AdminWarn v0.1.0 by mcnovinho08
    [Oxide] 22:37 [Info] AdminWarn was compiled successfully in 2905ms
    [Oxide] 22:37 [Info] Unloaded plugin AdminWarn v0.1.0 by mcnovinho08
    [Oxide] 22:37 [Info] Loaded plugin AdminWarn v0.1.0 by mcnovinho08
    [Oxide] 22:37 [Error] Failed to call hook 'AdminCommand' on plugin 'AdminWarn v0
    .1.0' (IndexOutOfRangeException: Array index is out of range.)
    [Oxide] 22:37 [Debug]   at Oxide.Plugins.AdminWarn.AdminCommand (.NetUser netuse
    r, System.String command, System.String[] args) [0x00000] in <filename unknown>:
    0
      at Oxide.Plugins.AdminWarn.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 name, System.Object[] arg
    [Oxide] 22:37 [Error] Failed to call hook 'cmdAvisarPlayer' on plugin 'AdminWarn
    v0.1.0' (IndexOutOfRangeException: Array index is out of range.)
    [Oxide] 22:37 [Debug]   at Oxide.Plugins.AdminWarn.cmdAvisarPlayer (.NetUser net
    user, System.String command, System.String[] args) [0x00000] in <filename unknow
    n>:0
      at Oxide.Plugins.AdminWarn.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 name, System.Object[] arg
     
    This error is persistent even though I have redone the code several times but still the same error continues, could anyone help me?
     
  2. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    According to the hook, you're trying to call an argument or something in an array that doesn't exist.
     
  3. mcnovinho08

    mcnovinho08 Plugin Developer

    Code (Text):
            [ChatCommand("avisar")]
            void Commando(NetUser netuser, string command, string[] args)
            {
              string ID = netuser.userID.ToString();
              if (!WarnSystem) { rust.SendChatMessage(netuser, chatPrefix, string.Format(GetMessage("MSG", ID), Desativado)); return; }
              if (!AcessAdmin(netuser)) { rust.SendChatMessage(netuser, chatPrefix, GetMessage("NoPermission", ID)); return; }
              NetUser targetuser = rust.FindPlayer(args[0]);
              rust.BroadcastChat(chatPrefix, string.Format(GetMessage("MSG2"), targetuser.displayName, netuser.displayName));
              rust.SendChatMessage(targetuser, chatPrefix, string.Format(GetMessage("MSG3", targetuser.userID.ToString()), netuser.displayName));
              WarnData(targetuser);
              Punir(targetuser);
            }
         
            void Punir(NetUser netuser)
            {
            string Name = netuser.displayName;
            if (Warns.Contains(AvisosLimite))
            {
            rust.BroadcastChat(chatPrefix, string.Format(GetMessage("MSG4"), Name, AvisosLimite));
            ClearData(netuser);
            netuser.Ban();
            netuser:Kick(global.NetError.Facepunch_Kick_BadName, true);          
            }
            }
    Tin because everything I put in exists!
     
  4. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    You aren't checking if args[0] actually exists, so it's likely from using the command with no arguments.
     
  5. mcnovinho08

    mcnovinho08 Plugin Developer

    Code (Text):
    using System.Collections.Generic;
    using System.Data;
    using Oxide.Core;
    using Oxide.Core.Plugins;

    namespace Oxide.Plugins
    {
        [Info("AdminWarn", "mcnovinho08", 0.1)]
        [Description("Warn the player about something wrong he did")]
        class AdminWarn : RustLegacyPlugin
        {
            static string chatPrefix = "Warn";
         
            static string Ativado = "Habilitado";
            static string Desativado = "Desabilitado";
         
            static int AvisosLimite = 3;
         
            static bool WarnSystem = true;
         
            const string permiAdmin = "AdminWarn.Use";
         
         
            void WarnData(NetUser netuser)
            {
               string ID = netuser.userID.ToString();
               string Name = netuser.displayName;
               if (Players.Contains(ID))
               {
                   Warns.Add(1);
               }
               else {
               Players.Add(ID);
               Names.Add(Name);
               Warns.Add(1);
               }
            }
         
            void ClearData(NetUser netuser)
            {
              string ID = netuser.userID.ToString();
              string Name = netuser.displayName;
              Names.Remove(Name);
              Players.Remove(ID);
              Warns.Remove(AvisosLimite);
            }
         
            [ChatCommand("avisar")]
            void Commando(NetUser netuser, string command, string[] args)
            {
              string ID = netuser.userID.ToString();
              if (!WarnSystem) { rust.SendChatMessage(netuser, chatPrefix, string.Format(GetMessage("MSG", ID), Desativado)); return; }
              if (!AcessAdmin(netuser)) { rust.SendChatMessage(netuser, chatPrefix, GetMessage("NoPermission", ID)); return; }
              if(args.Length == 0) { rust.SendChatMessage(netuser, chatPrefix, GetMessage("InvalidCommand")); return; }
              NetUser targetuser = rust.FindPlayer(args[1]);
              rust.BroadcastChat(chatPrefix, string.Format(GetMessage("MSG2"), targetuser.displayName, netuser.displayName));
              rust.SendChatMessage(targetuser, chatPrefix, string.Format(GetMessage("MSG3", targetuser.userID.ToString()), netuser.displayName));
              WarnData(targetuser);
              Punir(targetuser);
            }
         
            void Punir(NetUser netuser)
            {
            string Name = netuser.displayName;
            if (Warns.Contains(AvisosLimite))
            {
            rust.BroadcastChat(chatPrefix, string.Format(GetMessage("MSG4"), Name, AvisosLimite));
            ClearData(netuser);
            netuser.Ban();
            netuser.Kick(NetError.Facepunch_Kick_Ban, true);        
            }
            }

            void HelpAdmins(NetUser netuser)
            {
                var id = netuser.userID.ToString();
                rust.SendChatMessage(netuser, chatPrefix, GetMessage("HelpsAdmins", id));
                rust.SendChatMessage(netuser, chatPrefix, GetMessage("HelpsAdmins1", id));
                rust.SendChatMessage(netuser, chatPrefix, GetMessage("HelpsAdmins2", id));
                rust.SendChatMessage(netuser, chatPrefix, GetMessage("HelpsAdmins3", id));
                rust.SendChatMessage(netuser, chatPrefix, GetMessage("HelpsAdmins4", id));
                rust.SendChatMessage(netuser, chatPrefix, GetMessage("HelpsAdmins5", id));        
            }
         
         
            bool AcessAdmin(NetUser netuser){
            if(netuser.CanAdmin())return true;
            if(permission.UserHasPermission(netuser.userID.ToString(), permiAdmin))return true;
            return false;
            }
         
         
        }
    }
    OK, I noticed one of the unic commands that even after editing in Portuguese, when the command is displayed in a msg that is wrong when the button is not working.
     
  6. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Sounds like you're using an outdated Oxide build then in the case.
     
  7. mcnovinho08

    mcnovinho08 Plugin Developer

    Code (Text):
     (FormatException: Index (zero based) must be greater than or equal to zero and
    less than the size of the argument list.)
    New Error
     
  8. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Looks like you're trying to use string.Format with a null or empty variable.
     
  9. mcnovinho08

    mcnovinho08 Plugin Developer

    rust.BroadcastChat(chatPrefix, string.Format(GetMessage("MSG2"), targetuser.displayName, netuser.displayName));
    rust.SendChatMessage(targetuser, chatPrefix, string.Format(GetMessage("MSG3", IDT), netuser.displayName));
    --- Double Post Merged, Mar 27, 2017 ---
    The problem is when entering the nick of the player