1. Code:
    object OnRunCommand(ConsoleSystem.Arg arg)
    {
        string message = arg.GetString(0);
        BasePlayer player = arg.connection.player as BasePlayer;    if (permission.UserHasPermission(player.UserIDString, "commandblock.have"))
        {
            if (message.StartsWith("/"))
            {
                SendReply(player,"You are expelled. Chat commands don't work for you.");
            }       
            return true;
        }
        return null;
    }

    Want to just restrict every command for someone who got the perm .
    Commands still run :s
     
    Last edited by a moderator: May 22, 2016
  2. Wulf

    Wulf Community Admin

    You'll likely need to hook into OnPlayerChat if you are trying to handle chat commands, the OnRunCommand hook is only for console commands.
     
  3. Did that change?
    The docs still state: "Useful for intercepting commands before they get to their intended target (like chat.say)"
     
  4. Wulf

    Wulf Community Admin

    That is a console command.
     
  5. Sure, but all chat commands (and chat messages) are effectively executed as chat.say (or atleast they used to), meaning OnRunCommand can (could?) handle chat commands and chat messages as well.
    I'm not saying that it'd be the best approach, since OnPlayerChat exists, but I'm wondering whether it's still the case that OnRunCommand can be used to work with all chat messages and commands.
     
  6. Wulf

    Wulf Community Admin

    You can, you'd just need to handle it using a check like you mentioned. The hooks will all be getting overhauled for Covalence, so this is something we'll likely tidy up.
     
  7. OnPlayerChat
    void OnPlayerChat(ConsoleSystem.Arg arg)
    {
    Puts("OnPlayerChat works!");
    }

    • Called when a player sends chat to the server
    • Returning true overrides default behavior of chat, not commands


    - Not commands..... so.... its useless for what i wanted it?
     
  8. -snip-
    OnPlayerChat for chat commands, OnRunCommand for commands.
    OnRunCommand can be used for both as well.
     
  9. Wulf

    Wulf Community Admin

    Chat commands are chat, and can be handled in that hook. You can use OnRunCommand thought like @sqroot mentioned, you'd just need to check for chat.say as the command as well as check the message from the chat to see what command it is. If you want to just handle chat commands, then it would work with either hook.
     
  10. aaaaaah..... i got it wrong. xd yea. " not commands" there are ment the console ones. Allright. Thanks