This is the plugin in the current state, very simple
I know how to setup a chat command, so I plan to do something like "/rmessage ChatEnabled" true, but how do I set it so the true (or what ever value there is) writes to the config? Mainly I just need to know how to change it with a command, I don't need to know how to create a new command.Code:using Oxide.Core.Plugins; namespace Oxide.Plugins { [Info("RespawnMessages", "Kappasaurus", 0.2)] [Description("Make customized notes players view on respawn!")] class RespawnMessages : RustPlugin { [PluginReference] Plugin PopupNotifications; void LoadDefaultConfig() { Config.Clear(); Config["RespawnMessage"] = "Hey, try not to die this time!"; Config["PopupEnabled"] = false; Config["ChatEnabled"] = true; Config.Save(); } void OnPlayerRespawn(BasePlayer player) { if ((bool)Config["PopupEnabled"] == true) { PopupNotifications?.Call("CreatePopupNotification", Config["RespawnMessage"].ToString()); } if ((bool)Config["ChatEnabled"] == true) { SendReply(player, Config["RespawnMessage"].ToString()); } } [ChatCommand("rmessage")] void TestCommand(BasePlayer player, string command, string[] args) { SendReply(player, "<size=22><color=#cd422b>Respawn Messages v0.1</color></size>"); SendReply(player, "<size=12>Created by </size><size=14>Kappasaurus</size><size=12> with the help of </size><size=14>DylanSMR</size>"); } } }
Setting config with in-game commands
Discussion in 'Rust Development' started by Kappasaurus, Jul 5, 2016.
-
That is a example of how you can do it. So say I did "test 30.0" it would set it like:Code:
[ConsoleCommand("test")] void test(ConsoleSystem.Arg arg) { Config["StarterMultiplyer"] = arg.Args[0]; Config.Save(); }
[DOUBLEPOST=1467746979][/DOUBLEPOST]Of course mine is a float so 30.0 works with it. Otherwise you could do 5, "Or a string"Code:{ "RateOnLevel": 0.1, "StarterMultiplyer": "30.0" } -
well /rm will give credit, how do I make it so I could do /rm set <message> would set the message? because if I make the chat command "rm set", it just triggers /rm
@DylanSMR -
For that you would do a switch(args[0]) . You can look in my IGather plugin for a example.
-
Hey kappa. Just call it as /rmset or /rm_set
It's always the easiest solution as we can't really send the "" to allow for the spaces.. -
Well there is a way, using classes.
Look at LaserHydra's code, he uses a method for BetterChat, for example /group set blabla -
Wulf Community Admin
That space offsets the second part, the second part becomes an argument just like the blabla is. There are numerous plugins that do this.
