Solved Command logging

Discussion in 'Plugin Requests' started by Upperking, May 17, 2015.

  1. Wulf

    Wulf Community Admin

    The existing Logger plugin should be working just fine. If there is a specific feature you are looking for (all of what you mentioned already exists in it), please request it in the plugin's thread.
     
  2. Is there any way to save the log / TPR made on the server?

    Who teleported requests and to whom.
     
  3. I have looked but didnt find anything. Im looking for logs that i will see in chat if a admin uses any command like /vanish or /god. It would also be great if i can get if they spawn in something through f1. I need it only broadcasted to auth2 though. Is there anything atleast alike? Or anyone who can make this? For spawning through F1 im using AdminSpawn plugin so its not broadcasted to everyone.
     
  4. Wulf

    Wulf Community Admin

  5. All players in my game see the logger in chat. How can i make it so only i do. I have authlevel set to 2. Nobody else is auth2
    [DOUBLEPOST=1454983313][/DOUBLEPOST]Its also only shows the commands that i use not my mods
     
  6. Wulf

    Wulf Community Admin

    Set "Broadcast" to false in the config. You can set the "AuthLevel" in the config to 1, and it should only log mod actions.
     
  7. Does it do F1 spawning too? What about Noclip?
     
  8. Wulf

    Wulf Community Admin

    F1 yes, noclip is a client-side function so no to that.
     
  9. Its possible to log the commands and its outputs on oxide?

    For example, I want to use the plugin locations, and when I type /loc I want a log with all the locations that the plugin outputs in the chat.
     
  10. You would need to add the logging to the commands that you want logged yourself and populate it.

    So for example, that "Location" plugin you mentioned has two different functions, one to display your location, and another to display everyone's location.
    The class PlayerPosition() is the one that displays your location
    Code:
    void PlayerPosition(PlayerSession session) => hurt.SendChatMessage(session, prefix, GetLocation(session));
    string GetLocation(PlayerSession session) => session.WorldPlayerEntity.transform.position.ToString();
    static string prefix = "<color=#ff8000>Position</color>: ";
    This can actually be simplified to this to make it easier to understand.
    Code:
    PlayerPosition(PlayerSession session) => hurt.SendChatMessage(session, "<color=#ff8000>Position</color>:  "+session.WorldPlayerEntity.transform.position.ToString());
    Now there's two ways of which you could log command being used. First, lets make a simple string that we can use as our output text with the players name added.
    Code:
    string LocLog = session.Name+" position: "+session.WorldPlayerEntity.transform.position.ToString();
    So now we can use LocLog as our message.

    The first, and easy way to log the command being used would be just to output the command to the console whenever it was executed, you can use Puts(); to send messages to the console. So for this case you can use
    Code:
    Puts(LocLog);
    So whenever someone uses the command, it will send that LocLog string we made to the console window.

    The second method would be to log every time someone uses the command to a list, like I do in the Reporting plugin for logging the chat. All you need to do is create a simple string list (string means just normal messages) You can make a simple list, lets call it CommandLog by using
    Code:
    List<string> CommandLog = new List<string>();
    So now we have our list, we can add messages to that list by using .Add(string); so In this case you can use
    Code:
    CommandLog.Add(LocLog);
    I hope you're still with me :)
    So now we have added the message to a list, we need to save the list, we use Oxide's data handler for that. You need to supply two things, A location and filename, the variable name. Our variable name is what our list is called. (CommandLog) the location and filename can be whatever you want, but lets go ahead and call it LocLogs for simplicity, in the Location directory (The name of the plugin we're using as an example). We can also use it as a class statement, called Save. Which makes it look neater and is easier to use. So the Save would look like this:
    Code:
    void Save() => Interface.GetMod().DataFileSystem.WriteObject("Location/LocLogs", CommandLog);
    Okay so now, the original class GetLocation(); needs to be edited to include these new functions. The change to Puts(); is simple:
    Code:
    void PlayerPosition(PlayerSession session)
    {
        hurt.SendChatMessage(session, "<color=#ff8000>Position</color>:  "+session.WorldPlayerEntity.transform.position.ToString());
        string LocLog = session.Name+" position: "+session.WorldPlayerEntity.transform.position.ToString();
        Puts(LocLog);
    }
    The Saving a list is slightly more tricky, As you need to add the new list, using .Add() instead of Puts, then Save(); Which looks like this:
    Code:
    List<string> CommandLog = new List<string>();
    void Save() => Interface.GetMod().DataFileSystem.WriteObject("Location/LocLogs", CommandLog);void PlayerPosition(PlayerSession session)
    {
        hurt.SendChatMessage(session, "<color=#ff8000>Position</color>:  "+session.WorldPlayerEntity.transform.position.ToString());
        string LocLog = session.Name+" position: "+session.WorldPlayerEntity.transform.position.ToString();
        CommandLog.Add(LocLog);
        Save();
    }
    You can also Load the list if you want to retain the information. As each time this plugin is loaded it will start a new file.

    To Load the file you can use:
    Code:
    void Loaded() => CommandLog = Interface.GetMod().DataFileSystem.ReadObject<List<string>>("Location/LocLogs");
    I hope you understood all of that :)

    So feel free to have a mess around with any of the plugins you use, you can even point them to the same folder and make a folder called CommandLogs or something, then call the file name what the plugin is called, or the command that they use, so it puts them all neatly into one place.

    Feel free to ask questions, I and I'm sure many others here, will be glad to help you :)
     
  11. Is there a plugin that will logged the commands that enter players?
    Example /help, /kit etc.
     
  12. Wulf

    Wulf Community Admin

    The Logger plugin.
     
  13. Doesn't work in console.
     
  14. Wulf

    Wulf Community Admin

    What do you mean it doesn't work in console? It logs all commands used to the console/log/chat even if wanted.
     
  15. Or try plugin Spyon and edit config, it will gona make log o used commands, just dont forget to read overwiev so you have good set up ;)
     
  16. Request a module, you can record the use of G command GM brush items on the day

    希望可以实现一个记录GM刷物品的记录,当然如果可以记录所有命令的日志最好
     
  17. Hi, does anyone know where can I find in FTP txt log or file with commands what have been written in game console? Probably I check all folders and I didn't find it.