FormatException with custom commandError
I did some console commands like "o.unload ZoneManager" "o.grant group default kits.pvp" "o.reload NoEscape" in one command with this plugin.
when I did it on console all is works but I have this error message, and whent I use Timed execute to launch this command in a realtime timer, I have the same error but nothing works
Merged postI have the same error whent I do the commands in chat command
Merged post
an exemple :
"Command": "purge1",
"Messages": [
"PURGE TIME !"
],
"Permission": "customchatcommands.admin",
"ConsoleCmd": [
"o.grant group default kits.pvp",
"oxide.unload TruePVE",
"oxide.unload ZoneManager",
"oxide.unload DynamicPVP",
"oxide.unload ZoneDomes",
"oxide.unload ZonePVxInfo",
"oxide.unload BuildingBlocker",
"oxide.reload NoEscape",
"oxide.reload SimpleLogo"
],
"UserID": 0,
"Broadcast": true,
"RconCmd": [
"purge1"
],
"Cooldown": 0.0,
"MaxUses": 100
},
Merged post
and the error :
Failed to call hook 'CustomCommand' on plugin 'CustomChatCommands v2.1.2' (FormatException: Input string was not in a correct format.)
at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00057] in <a8ed250850854b439cedc18931a314fe>:0
at System.Number.ParseUInt64 (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) [0x00014] in <a8ed250850854b439cedc18931a314fe>:0
at System.UInt64.Parse (System.String s) [0x00007] in <a8ed250850854b439cedc18931a314fe>:0
at Oxide.Plugins.CustomChatCommands.CustomCommand (Oxide.Core.Libraries.Covalence.IPlayer player, System.String command, System.String[] args) [0x00013] in <6e66462d0822434bbca2add1571fbf1f>:0
at Oxide.Plugins.CustomChatCommands.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00326] in <6e66462d0822434bbca2add1571fbf1f>:0
at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <9affce1cd15c4ec183941adef8db1722>:0
at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <4452f821def6406d834e4149849fe7ea>:0
at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <4452f821def6406d834e4149849fe7ea>:0
I keep getting these error messages in console how do I fix this?
Failed to call hook 'CustomCommand' on plugin 'CustomChatCommands v2.1.2' (FormatException: Input string was not in a correct format.)
at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00057] in <fb001e01371b4adca20013e0ac763>:0
at System.UInt64.Parse (System.String s) [0x00007] in <fb001e01371b4adca20013e0ac763>:0
at Oxide.Plugins.CustomChatCommands.CustomCommand (Oxide.Core.Libraries.Covalence.IPlayer player, System.String command, System.String[] args) [0x00013] in <0a31d2b887b64881840ab9a6445b2>:0
at Oxide.Plugins.CustomChatCommands.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00326] in <0a31d2b887b64881840ab9a6445b2>:0
at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <80b90e8213db44b29ec2d411176>:0
at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <ec05e0208c9149bba43236ca58fe>:0
at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <ec05e0208c9149bba43236ca58fea>:0
I know this is an old thread, sorry.
Have a fix/bodge lol (Someone asked for help re this thread in the Rust Admin Community Discord - thought I'd share here in case anyone still uses)
Just moved all the console command execution above the rest of the code in that function.
Otherwise it errors as the code is trying to check cooldowns/limits from a user ID but if it's the console, it won't have an ID. Checked and permissions are still required, so as long as your command has a permission set in the config file you should be good.
Replace the "void CustomCommand" function with the below (Line 178 onwards)
void CustomCommand(IPlayer player, string command, string[] args)
{
var cmd = config.Commands.SingleOrDefault(x => x.Command.ToLower() == command.ToLower());
if (cmd == null) return;
if (cmd.ConsoleCmd != null && cmd.ConsoleCmd.Count > 0)
{
foreach (var consoleCmd in cmd.ConsoleCmd)
{
player.Command(consoleCmd);
}
return;
}
ulong userID = ulong.Parse(player.Id);
if (!CanUseCommand(userID, cmd.Command))
{
player.Message(GetMessage("Max Uses Reached", player.Id, cmd.MaxUses.ToString()));
return;
}
if (IsOnCooldown(userID, cmd.Command))
{
double timeRemaining = CooldownRemaining(userID, cmd.Command);
double hours;
if (IsHours(timeRemaining, out hours))
{
Puts(hours.ToString());
player.Message(GetMessage("Command On Cooldown - Hours", player.Id, hours.ToString("N1")));
return;
}
double minutes = timeRemaining / 60;
player.Message(GetMessage("Command On Cooldown - Minutes", player.Id, minutes.ToString("N1")));
return;
}
if (cmd.Broadcast) BroadcastMessages(cmd.Messages, cmd.UserID);
else SendMessages(player, cmd.Messages, cmd.UserID);
if (cmd.RconCmd != null && cmd.RconCmd.Count > 0)
{
foreach (var rconCmd in cmd.RconCmd)
{
var newCmd = rconCmd.Replace("{player.name}", player.Name)
.Replace("{player.id}", player.Id);
server.Command(newCmd);
}
}
if (cmd.Cooldown > 0f) AddCooldown(userID, cmd.Command, cmd.Cooldown);
if (cmd.MaxUses > 0) AddUse(userID, cmd.Command);
}