1. OpenFunRus

    OpenFunRus Scavenger Plugin Developer

    • [7DaysToDie] Added return to OnPlayerChat to allow cancelling
    How it work?
     
  2. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Code (C):
    object OnPlayerChat(ClientInfo client, string message)
    {
        return true;
    }
    Basically returning anything other than null will cancel it.
     
  3. OpenFunRus

    OpenFunRus Scavenger Plugin Developer

    Thanks, Wulf =)
     
  4. OpenFunRus

    OpenFunRus Scavenger Plugin Developer

    It is work wrong, if i try use this, all chat not work(
     
  5. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    That's what returning does... I didn't give you an example to exclude, just how to cancel the chat. You'd need to add an if check or whatever you need to isolate a specific message and cancel it from sending.
     
  6. {QaD}Lurch

    {QaD}Lurch Naked Wanderer

    So I tested my understanding of what you are saying here, having wanted to implement a private-message utility and hide other admin only commands from echoing to the chat window when typed. First, I didn't know that OnPlayerChat had a signature override for returning an object. Are there any other hooks with that?

    Second, the below pseudo-code illustrates how I tried to implement what you describe above. It doesn't hide anything. The chat commands all function as normal, but any that I mark specifically to be hidden still show up.
    Code (Text):

    private object OnPlayerChat(ClientInfo client, string message)
    {
         bool? hideChat = null;

         ...Normal chat command processing goes here

         if(command=="PM")
         {
              // Note this is mock-up code
              sendPrivateMessage(playerId, fromPlayer, txtMsg);
              hideChat = true;
         }

        ....Other chat stuff

         return hideChat; // Only set true in special cases
    }
    So my interpretation is either way off, or this feature isn't working either.
     
  7. {QaD}Lurch

    {QaD}Lurch Naked Wanderer

    Not off, one just has to have installed the latest Oxide build is all.

    Works as advertised. You can use the example in my pseudo-code in the message above and it will work.
     
    Wulf likes this.
  8. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    You don't need to set a bool, just return true in that if check, else return null, but that would work yes.
     
  9. OpenFunRus

    OpenFunRus Scavenger Plugin Developer

    Code (Text):
    object OnPlayerChat(ClientInfo client, string message)
    {
        return true;
    }
    Wolf, it is not working. If I use this code/hook chat message not working on server.
     
  10. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    That is how it is supposed to work. You can stop the chat entirely with the hook. If you want to filter a specific one, you need to only return true if that is detected. Example:
    Code (Text):
    object OnPlayerChat(ClientInfo client, string message)
    {
        if (message == "hello world") return true;
        return null;
    }
     
  11. OpenFunRus

    OpenFunRus Scavenger Plugin Developer

    Thanks, Wulf =)