1. So i'm just having a small problem where this bit of code wont compile correctly.
    AntiChatFlood.cs - Pastebin.com

    Any help would be awesome, thanks.
    [DOUBLEPOST=1456188598][/DOUBLEPOST]Error Code: "[Error] AntiChatFlood.cs(73,4): error CS1002 ; expected
     
  2. Wulf

    Wulf Community Admin

    You're missing brackets in one if statement that has two lines. Visual Studio should tell you this if you use it. ;)
     
  3. Right so I fixed all of that, got my plugin working. But with the "OnPlayerChat hook" I am getting a little error when I type in-game.

    Code:
            void OnPlayerChat(ConsoleSystem.Arg arg, BasePlayer player)
            {
                var info = new PlayerInfo(player);
                if (storedData.Players.Contains(info))
                {
                    SendReply(player, "You must wait to send another message.");
                    return;
                }
                if(!storedData.Players.Contains(info))
                {
                    storedData.Players.Add(info);
                    Interface.Oxide.DataFileSystem.WriteObject("MyDataFile", storedData);
                    timer.Repeat(TimeBetweenMessage, 0, () =>
                    {
                        storedData.Players.Remove(info);
                    });
                }
            }
    
    Screenshot
     
  4. Wulf

    Wulf Community Admin

    You're using an invalid argument for the hook, the only valid one is the first one.
     
  5. Wait so how would it be able to call for player if player isn't a variable? AS "BasePlayer player" is what I use to define player.
     
  6. Wulf

    Wulf Community Admin

    You'd need to get the player from arg.connection.player I believe, and cast it as BasePlayer.
     
  7. Right thanks, I got it.
    Code:
    BasePlayer player = (BasePlayer) arg.connection.player;
     
  8. Right so ive done a bit of editing, no errors, and mostly good. But when it does add the player to the data(Which it does), when it tries to read if it is in the file, it say it is.
    Code:
            void OnPlayerChat(ConsoleSystem.Arg arg)
            {
         
                BasePlayer player = (BasePlayer) arg.connection.player;
                var info = new PlayerInfo(player);
                if (storedData.Players.Contains(info))
                {
                    PrintToChat(player, "You are chatting to fast, try again soon");
                    return;
                }
                else
                {
                    storedData.Players.Add(info);
                    Interface.Oxide.DataFileSystem.WriteObject("AntiChatFlood", storedData);
                    timer.Once(WaitTillMsg, () =>
                    {
                        storedData.Players.Remove(info);
                    });
                }
            }
    Just a bit new to data files(DO I do, storedData.Players.Remove(info);), or what would I do
     
  9. Wulf

    Wulf Community Admin

    You can't store the full player, you'd need to store the name, steamid, etc. or whatever else you may want.
     
  10. Odd, I just used the one from the docs.oxidemod.org, then edited it to my needs.
    And is the script(storedData.Players.Remove)?
     
  11. Wulf

    Wulf Community Admin

    Mmm, pretty sure you can't store the entire player in a datafile, only variables/strings from it. You can store the player in a hashset or dictionary though.
     
  12. Heres the entire plugin of what I am working with.
    Code:
    using System.Collections.Generic;
    using Oxide.Core;namespace Oxide.Plugins
    {
        [Info("AntiChatFlood", "DylanSMR", "1.0.0")]
        [Description("Data test stuff.")]    class AntiChatFlood : RustPlugin
        {
       
            int WaitTillMsg = 5;
       
            class StoredData
            {
                public HashSet<PlayerInfo> Players = new HashSet<PlayerInfo>();            public StoredData()
                {
                }
            }        class PlayerInfo
            {
                public string UserId;
                public string Name;            public PlayerInfo()
                {
                }            public PlayerInfo(BasePlayer player)
                {
                    UserId = player.userID.ToString();
                    Name = player.displayName;
                }
            }        StoredData storedData;        void Loaded()
            {
                storedData = Interface.Oxide.DataFileSystem.ReadObject<StoredData>("AntiChatFlood");
            }        void OnPlayerChat(ConsoleSystem.Arg arg)
            {
           
                BasePlayer player = (BasePlayer) arg.connection.player;
                var info = new PlayerInfo(player);
                if (storedData.Players.Contains(info))
                {
                    PrintToChat(player, "You are chatting to fast, try again soon");
                    return;
                }
                else
                {
                    storedData.Players.Add(info);
                    Interface.Oxide.DataFileSystem.WriteObject("AntiChatFlood", storedData);
                    timer.Once(WaitTillMsg, () =>
                    {
                        storedData.Players.Remove(info);
                    });
                }
            }
        }
    }
     
  13. You don't really need to store any data unless you are planning on having the information carry over through restarts, you could just as easily use a list

    Code:
    using System.Collections.Generic;
    using Oxide.Core;namespace Oxide.Plugins
    {
        [Info("AntiChatFlood", "DylanSMR", "1.0.0")]
        [Description("Data test stuff.")]    class AntiChatFlood : RustPlugin
        {        int WaitTillMsg = 5;
            List<ulong> playerWait = new List<ulong>(); // We are going to store the users ID, there isnt much point in taking more data than we need for this plugin
            
            void OnPlayerChat(ConsoleSystem.Arg arg)
            {            BasePlayer player = (BasePlayer)arg.connection.player;
             
                if (playerWait.Contains(player.userID))
                {
                    PrintToChat(player, "You are chatting to fast, try again soon");
                    return;
                }
                else
                {
                    playerWait.Add(player.userID);             
                    timer.Once(WaitTillMsg, () =>
                    {
                        playerWait.Remove(player.userID);
                    });
                }
            }
        }
    }
     
  14. I plan on adding a warning point sytem, so I decided it would be easier to add both to a data file instead.
     
  15. Ok, either way you would still be better off saving the above to memory instead of data, otherwise the plugin will have to read and write a physical file every 5 seconds. You could then use a datafile to save data purely related to the warning system
     
  16. How would I go about saving it to memory(Sorry, just a bit to new to rust data/memory and such)
     
  17. The way I showed you, as long as the plugin is loaded the list is in memory. If you want some help understanding data and how to better manage it to suit what you are doing you can add me on steam. Ill be home later tonight
     
  18. Right, I used a list and got it working, Thanks :D. When you get home though I will need to ask about how to store numbers in data files. Then request that number a bit later on.