The code:
Are generating a message, that is, a first message in the chat, if you reload it it will move to the next message and keep repeating ;-; Please help-me to random mensagem in the list..Code:using System; using System.Collections; using System.Collections.Generic;using Oxide.Core; using Oxide.Core.Configuration; using Oxide.Core.Plugins;namespace Oxide.Plugins { [Info("RandomNotices", "Goku", "1.0.0")] [Description("Show random notices in every time")] class RandomNotices : RustPlugin { // | Prefix | Time | True or false (ONFF) static string chatprefix = "RANDOMNOTICES"; static string colorprefix = "#FF0000"; bool ONOFF = true; float timeRepeat = 0.5f; // GET A LIST: readonly List<string> RandomMessages = new List<string>(new string[]{ "Type /commands list to get a full list commands", "Type /ff (on|off) to enable / disable your friendly fire", "Type /friend [add|remove|list] to add / remover or list your friends." }); // GET A CONFIG FILE void LoadDefaultConfig() { PrintWarning("The config has been created of the plugin: RandomNotices"); Config.Clear(); Config["Tag prefix in chat"] = chatprefix; Config["Tag prefix in chat (COLOR)"] = colorprefix; Config["Active system (TRUE: ON | FALSE: OFF)"] = ONOFF; Config["Time to repeat the notices"] = timeRepeat; Config["Messages"] = RandomMessages; SaveConfig(); } // GET A RANDOM STRING IN THE LIST 'VOID' void TimerT() { System.Random rand = new System.Random(); int next = rand.Next(RandomMessages.Count); string message = RandomMessages[next]; timer.Repeat(timeRepeat * 60, 0, () => { rust.BroadcastChat("<color=" + colorprefix + ">" + chatprefix + "</color> : " + message); PrintWarning(message); }); } void Loaded() { TimerT(); } } }
OBS:. The PrintWarning is for test the messages
Solved Random sending only one message?
Discussion in 'Rust Development' started by Daat, Apr 4, 2018.
-
Wulf Community Admin
Why not use the AutoBroadcast plugin? It already does this.
-
Oh I did not know this plugin, but it's also because I want to study a little more and to know why this happens if I want to create future plugins.
-
Wulf Community Admin
-
Yes, I'm looking as you like, thank you very much Wulf