Hello,
I use this system cooldown and I have a few questions.
1. What happens with the time of cooldown if the server is crash/off. Is it reset then?
2. Is it possible to read how much time is left?
^^Code:using System.Collections.Generic; //Using directive containing the HashSet classnamespace Oxide.Plugins //Namespace where plugins must go { [Info("TestPlugin", "JoeSheep", "1.0.0")] [Description("A Test Plugin.")] class TestPlugin : RustPlugin { HashSet<ulong> Cooldowns = new HashSet<ulong>(); //Create our list to store the players currently in cooldown const string Perm = "TestPlugin.test"; //Create the permission void OnServerInitialized() { permission.RegisterPermission(Perm, this); //Register the permission when the server initializes } [ChatCommand("test")] //Create the chat command to do the following void cmdTestCommand(BasePlayer player, string cmd) { if (permission.UserHasPermission(player.UserIDString, Perm)) //Check if the player has the permission "Perm" { if (!Cooldowns.Contains(player.userID)) //Check if the player is listed in the HashSet "Cooldowns", if not continue { Cooldowns.Add(player.userID); //Add the player to the Cooldowns HashSet so they cannot run the command again until removed timer.Once(10, () => Cooldowns.Remove(player.userID)); //Create and start a timer for 10 seconds, when it expires remove the player from the Cooldowns HashSet SendReply(player, "Test command."); //Send a chat message to the player saying "Test command." } else SendReply(player, "Cooldown in effect."); //If the player is in the Cooldowns HashSet send this chat message to them } else SendReply(player, "You do not have permission to run this command"); //If the player doesn't have the permission Perm then send this chat message to them } } }
I rewrite this code to Hurtworld
Sorry for my English
Regards
Adding a command cooldown, reading time left?
Discussion in 'Hurtworld Development' started by MonkeY12, Aug 7, 2017.