hello,
I'm beginner in C# and i will learnC# with try to develop my own plugins.
i will first try to have a plugin who log all command sent by a player :
Can you help me please ?Code:using System.Data; using Oxide.Core;namespace Oxide.Plugins { [Info("Log Console", "Bourtak", "0.1")] public class LogConsole : RustPlugin { // This is where your plugin will do its magic private void OnRunCommand(){ LogCommand(); } // Sauvegarde le fichier private void LogCommand() { Interface.GetMod().DataFileSystem.SaveDatafile("LogConsole"); } } }
Solved Logging a message? (C#)
Discussion in 'Rust Development' started by Bourtak, Jun 3, 2015.
-
You maybe could just write it into the console as that is also saved as a log.
You are able to do that using
Code:Puts(message);
-
I have try and puts work fine. Thanks.
But i will not log just a message. I will log what is type in the console.
If i type /airdrop.toplayer, i will the server puts"Y:m:d H:i:s playerid :xxxxxxxx => /airdrop.toplayer"
But /airdrop.toplayer is variable. And i don't know how i can capture that. -
-
So that ?
Code:using System.Data; using Oxide.Core;namespace Oxide.Plugins { [Info("Log Console", "Bourtak", "0.1")] public class LogConsole : RustPlugin { // This is where your plugin will do its magic private void OnRunCommand( String args){ Puts(args); LogCommand(args); } // Sauvegarde le fichier private void LogCommand( string args){ Interface.GetMod().DataFileSystem.SaveDatafile("LogConsole"); } } }
-
I think someone who knows C# can help you 4 sure
-
Do you want to log Chat command or Console commands? Or both
-
Console command
-
Code:void OnRunCommand(ConsoleSystem.Arg arg) { }
arg.cmd.namefull
so all you gotta do is, using theCode:Puts(message)
-
Thanks, that work fine
Code:using System.Data; using Oxide.Core;namespace Oxide.Plugins { [Info("Log Console", "Bourtak", "0.1")] public class LogConsole : RustPlugin { // This is where your plugin will do its magic private void OnRunCommand(ConsoleSystem.Arg arg){ string message = arg.cmd.namefull; if ( message != "chat.say" && message != "global.kill" && message != "chat.say" && message != "inventory.endloot" && message != "craft.add" && message != "global.add" && ){ Puts(arg.cmd.namefull); } //LogCommand(); } /* Sauvegarde le fichier private void LogCommand(){ Interface.GetMod().DataFileSystem.SaveDatafile("LogConsole"); } */ } }
Yes i know, my condition is ridiculous
I'm looking for make in c# what i make with !in_array() from PHP
Thanks