Author Topic: Player chat hooking script  (Read 335 times)

Legacy_Epitaffio

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Player chat hooking script
« on: November 21, 2011, 12:34:18 pm »


               Hi all,

i'm scripting a modification to hook the chat of player when he is unconscious (bleeding or resting) to prevent that he can read what other player had say when he "stand up" (i don't know how to say it in english, lol).

I use nwnx and the chat plugin.

Let's imagine that we have 2 PC, PC1 say something, PC2 is unconscious. The chat plugin seem to hook only to PC1 using this:


#include "nwnx_chat"

void main(){

    object oPc = OBJECT_SELF;

    struct chat_message cmMessage;
    cmMessage = NWNXChat_GetMessage();
    int iMode = cmMessage.Mode;
    object oTo = cmMessage.Recipient;
    string sText= cmMessage.Text;

    int iType = NWNXChat_GetCCMessageType();
    int iSubtype = NWNXChat_GetCCMessagSubtype();

     //Unconscious
    if(GetLocalInt(oPc, MORTE_SVENUTO) == TRUE ||
       GetLocalInt(oPc, "riposo") == TRUE  ){

        if(iMode == CHAT_CHANNEL_TALK ||
           iMode == CHAT_CHANNEL_WHISPER){
                NWNXChat_SuppressMessage();
        }
        return;
    }

}


This seems to work only for the Pc who said something, not for who is listening to him (no debug message for PC2, only the normal chat message)


For other things i use the on_player_chat, i was thinking if i can use it to complete the task, but i think i can't do this in this way, something like this:



    object oArea = GetArea(oPc);
    object oObject;

    oObject = GetFirstObjectInArea(oArea);
    while(GetIsObjectValid(oObject)){
        if( GetIsPC(oObject) || GetIsDMPossessed(oObject) ){

            if( GetObjectHeard(oObject, oPc) ){
                //SUPPRESSING MESSAGE?
            }
        }
        oObject = GetNextObjectInArea(oArea);
    }



What do you think? Thanks in advance
               
               

               
            

Legacy_virusman

  • Sr. Member
  • ****
  • Posts: 448
  • Karma: +0/-0
Player chat hooking script
« Reply #1 on: November 21, 2011, 12:51:53 pm »


               That's right, the chat hook fires only when someone says something. It won't fire for every creature in the hearing range.
               
               

               


                     Modifié par virusman, 21 novembre 2011 - 12:52 .
                     
                  


            

Legacy_Epitaffio

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Player chat hooking script
« Reply #2 on: November 21, 2011, 01:33:36 pm »


               Hum, i was right then.. other ways to accomplish this?

With the on_player_chat i can cycle through the PCs in the area and check that they can listen to PC1, but how i can suppress the message only for them?

I can make a custom function to suppress every normal and whisper chat message and emulate the chat with the NWNXChat_SendMessage function cycling through every PCs that can hear the PC1, but i don't know if it can work (i can't test it now) or if it will use too much resources..
               
               

               
            

Legacy_virusman

  • Sr. Member
  • ****
  • Posts: 448
  • Karma: +0/-0
Player chat hooking script
« Reply #3 on: November 21, 2011, 01:59:47 pm »


               With the current functionality of NWNX Chat, you can't override default Talk and Whisper hearing logic.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Player chat hooking script
« Reply #4 on: November 21, 2011, 02:22:48 pm »


               Also, as much realistic it seems, do you really think its effective feature? Players need comunicate with each other, if you disable them this option and few server already did (though not technically, they simply pusnishing anyone who is chating unappropriately) do you know what happens? Unless they leave your module they will use external communication programms like teamspeak, msn, irc.

My friend even created a irc2nwn tool where he could communicate with us on irc within NWN.
               
               

               


                     Modifié par ShaDoOoW, 21 novembre 2011 - 02:24 .
                     
                  


            

Legacy_Epitaffio

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Player chat hooking script
« Reply #5 on: November 21, 2011, 02:34:39 pm »


               No, wait.. i don't want to block tells and the other channel .. only the chat and the whisper channels and only for 1 minute at maximum (time for bleeding or resting)


virusman wrote...

With the current functionality of NWNX Chat, you can't override default Talk and Whisper hearing logic.

Yes, it's why i say i'm thinking to suppress the normal chat and create a custom system with the chat plugin to "resend" the message to who can hear this, it's crazy, i know, but i can't see any other ways.

Assuming i will do it, obviosly.