1. When an admin uses any commands such as /godmode, /give, /fly, etc to announce they have activated it or deactivated it, So the community can see if an admin is abusing his powers for example in the ingame chat:

    British89 has activated godmode
    British89 has deactivated godmode
    British89 has activated fly
    British89 has given [name] [amount] [item]

    and so on.

    Thanks.
     
  2. Wulf

    Wulf Community Admin

  3. Thanks, Is it ok for me to tinker with someone else work then?
     
  4. Wulf

    Wulf Community Admin

    The plugins are there for use, but I wouldn't copy it for public release. I'm sure the plugin can be updated with an option though.
     
  5. Here you go British.

    Original Code:
    Code:
    private void OnPlayerCommand(Player player, string command, string[] args)
            {
                if (!CommandLogEnabled) return;
                Log("commands", $"{player.Name} ran the command /{command} {args.JoinToString(" ")}");
            }
    Updated Code:
    Code:
    private void OnPlayerCommand(Player player, string command, string[] args)
            {
                if (!CommandLogEnabled) return;
                Log("commands", $"{player.Name} ran the command /{command} {args.JoinToString(" ")}");
               
                // Array of commands to announce
                string[] notifyList = new string[] { "godmode", "fly", "give", "giveall", "heal", "hydrate", "nourish", "stophunger", "stopthirst" };
               
                //If the command run is in the above array, Notify server.
                foreach (string x in notifyList)
                {
                    if (x.Contains(command))
                    {
                        PrintToChat($"[[64CEE1]Server[-]] {player.Name} just ran /{command} {args.JoinToString(" ")}");
                    }
                }
            }
    Note: this code modification does not check if the player is admin or not. Anyone who types the command whether they have permission to use it or not will be announced.
     
  6. Thank you very much SweetLouHD, much appreciated.
    [DOUBLEPOST=1446073008][/DOUBLEPOST]It works great, It does have its faults though, It will announce the first command, the 2nd announce will announce twice, then 3 times, then 4 and so on
     
  7. I am not having this issue when I test it. Weird that is happening for you.
    [DOUBLEPOST=1446113161][/DOUBLEPOST]Actually I take that back. The give command would fire twice because "give" is also in "giveall". we just need to end the function when the first instance is found so we add a return; after the PrintToChat. Also changed the if statement to check for the exact word not part of a word. (x.Contains(command) vs x == command)

    Updated Code:
    Code:
    private void OnPlayerCommand(Player player, string command, string[] args)
            {
                if (!CommandLogEnabled) return;
                Log("commands", $"{player.Name} ran the command /{command} {args.JoinToString(" ")}");
              
                // Array of commands to announce
                string[] notifyList = new string[] { "godmode", "fly", "give", "giveall", "heal", "hydrate", "nourish", "stophunger", "stopthirst" };
              
                //If the command run is in the above array, Notify server.
                foreach (string x in notifyList)
                {
                    if (x == command.ToLower())
                    {
                        PrintToChat($"[[64CEE1]Server[-]] {player.Name} just ran /{command} {args.JoinToString(" ")}");
                        return;
                    }
                }
            }
     
    Last edited by a moderator: Oct 29, 2015
  8. Thanks again SweetLouHD.
     
  9. Welcome