Hello all I am making a script for my own server that I am running. I am having problem with the /help command. I am using C# with VS 2015 . Most of my script is working , the help command has pages, i ahve a default in ther but before that like all my other commands i have an
Here is the entire help command. This command works if you use "/help 1" or "/help 2" but not "/help"Code:if (args.Length < 1) { PrintToChat(player, "<size=16><color=yellow>/help [page #]</color></size>"); PrintToChat(player, "<color=yellow>/trr [playername] - Safe Player Trade</color>"); PrintToChat(player, "<color=yellow>/tra - To accept Trade request</color>"); PrintToChat(player, "<color=yellow>/plugins - to see what plugins are active</color>"); }
any help would be appreciatedCode:[ChatCommand("help")] private void helpCmd(BasePlayer player, string command, string[] args) { string _page = args[0]; if (args.Length < 1) { PrintToChat(player, "<size=16><color=yellow>/help [page #]</color></size>"); PrintToChat(player, "<color=yellow>/trr [playername] - Safe Player Trade</color>"); PrintToChat(player, "<color=yellow>/tra - To accept Trade request</color>"); PrintToChat(player, "<color=yellow>/plugins - to see what plugins are active</color>"); } else { switch (_page) { case "1": PrintToChat(player, "<size=16><color=yellow>/help [page #]</color></size>"); PrintToChat(player, "<color=yellow>/trr [playername] - Safe Player Trade</color>"); PrintToChat(player, "<color=yellow>/tra - To accept Trade request</color>"); PrintToChat(player, "<color=yellow>/plugins - to see what plugins are active</color>"); break; case "2": PrintToChat(player, "<size=16><color=yellow>Help Page 2 ~ Rp Commands ~ </color></size>"); PrintToChat(player, "<color=yellow>/me [ACTION]</color>"); PrintToChat(player, "<color=yellow>/do [DESCRIPTON]</color>"); PrintToChat(player, "<color=yellow>/pm [PLAYERNAME] [MESSAGE]</color>"); break; default: PrintToChat(player, "<size=16><color=yellow>/help [page #]</color></size>"); PrintToChat(player, "<color=yellow>/trr [playername] - Safe Player Trade</color>"); PrintToChat(player, "<color=yellow>/tra - To accept Trade request</color>"); PrintToChat(player, "<color=yellow>/plugins - to see what plugins are active</color>"); break; } } }
also a quickie , is it possible to send a player a console commands output. I want to use /plugins and basically run the console command"oxide.plugins" which returns something like this
Code:oxide.plugins [Oxide] Listing 7 plugins: 01 "Day & Night System" (1.0.3) by Mughisi 02 "Rust:IO for Oxide" (2.5.0) by playrust.io / dcode 03 "Death Notes" (3.1.0) by LaserHydra (Original by SkinN) 04 "Hitmarker GUI" (1.1.0) by PaiN 05 "Ingame Clock GUI" (0.0.31) by deer_SWAG 06 "Player Trade" (0.0.9) by emu 07 "Rust Life" (0.1.0) by Bacon8tor
Solved Commands with no arguments errors
Discussion in 'Rust Development' started by Bacon8tor, Aug 16, 2015.
-
Use switch only
-
With just switch statement I receive this error that there is no args
Code:[Oxide] 8:00 AM [Error] Failed to call hook 'helpCmd' on plugin 'RustLife v0.2.0' (IndexOutOfRangeException: Array index is out of range.) [Oxide] 8:00 AM [Debug] at Oxide.Plugins.RustLife.helpCmd (.BasePlayer player, System.String command, System.String[] args) [0x00000] in <filename unknown>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
-
Move the string _page = args[0]; to the else branch
-
Fantastic! Thanks so much!