Author Topic: Multiplayer module dialogue  (Read 508 times)

Legacy_Kalindor

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
Multiplayer module dialogue
« on: December 07, 2010, 05:19:59 am »


                 I'm making a module to play multiplayer with some friends and encountered a scripting dilemma. I wanted to draw upon the expertise of the NwN modding community.
  What is the best way to get NPC's to speak to players using the names of other players? For example, I want an NPC to say something along the lines of the following:

"It's good that you are here, <FirstName>. Your companion, (INSERT PLAYER 2'S NAME), already went inside and I haven't heard from (INSERT PLAYER2'S HIM/HER) in hours."

  It's probably a simple answer that I should know already. Thanks for any assistance.
               
               

               
            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
Multiplayer module dialogue
« Reply #1 on: December 07, 2010, 11:20:56 am »


               CUSTOM TOKENS is the key, scripted commands such as SetCustomToken() will suffice to put your data where you need it, thereafter you can use the content of the Custom Token in a convo by <CUSTOM###>  where ### is the number you assigned to the Custom Token.



Hope this helps, if not sufficient, try the NWNLEXICON for more.



Be well. Game on.

GM_ODA
               
               

               
            

Legacy_Kalindor

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
Multiplayer module dialogue
« Reply #2 on: December 07, 2010, 04:49:20 pm »


               Thanks. I'll try my hand at incorporating some custom tokens.

*Edit: Okay, is there some sort of GetFirstName() or GetLastName() function?
               
               

               


                     Modifié par Kalindor, 07 décembre 2010 - 04:57 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Multiplayer module dialogue
« Reply #3 on: December 07, 2010, 05:25:20 pm »


               GetName(oObject)   returns both of them.  Per the lexicon.

Description

Returns the first and last name of oObject. In the case of creatures, returns first and last names together as single concatenated string.






If you need to split them appart, You could search for a space in the name to know where the first name ends and the last begins.



Ill try to find some time later tonight after i get home to look at this a little closer.  I half remember some 2da's that may be of use.
               
               

               
            

Legacy_Kalindor

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
Multiplayer module dialogue
« Reply #4 on: December 07, 2010, 10:22:45 pm »


               I appreciate it. Don't inconvenience yourself too much on my behalf. It's just a cosmetic thing, but it strikes me as rather odd for NPC's to frequently refer to someone they know well by their first and last name.
               
               

               
            

Legacy_Invisig0th

  • Sr. Member
  • ****
  • Posts: 279
  • Karma: +0/-0
Multiplayer module dialogue
« Reply #5 on: December 07, 2010, 10:46:33 pm »


               Just for future reference, there is a separate Scripting Forum
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Multiplayer module dialogue
« Reply #6 on: December 08, 2010, 02:26:06 am »


               Yea, This has turned out to be a scripting question. After looking at the 2da for the tokens used in conversations I have found that it will easier to and faster to just script out what you need without using the 2da.

if you need help on how to set the value for the custom toke in the conversation the lexicon is a good place to look




Function - SetCustomToken - NWN LexiconGetting the value for the token will be different for acording to what you want to get.  For the great mass of male/female tokens I would use something like the following.  Keep in mind that the Bioware Tokenizer is not the most efficient of functions. It is however easy to use. you will also have to #include "x0_i0_stringlib" in order to use it.  

string sToken = GetTokenByPosition("Mister/Miss","/",GetGender(oPC));
string sToken = GetTokenByPosition("boy/girl","/",GetGender(oPC));
string sToken = GetTokenByPosition("Lord/Lady","/",GetGender(oPC));
string sToken = GetTokenByPosition("lord/lady","/",GetGender(oPC));
string sToken = GetTokenByPosition("Master/Mistress","/",GetGender(oPC));

I hope you get the Idea.

For the first/last name I would get the value like this.

string  sFirstName = GetTokenByPosition(GetName(oPC)," ",0);
string  sLastName  = GetTokenByPosition(GetName(oPC)," ",1);

I hope that helps,
L8
               
               

               
            

Legacy_Kalindor

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
Multiplayer module dialogue
« Reply #7 on: December 08, 2010, 04:52:38 am »


               Thanks! I did some string clipping and got the custom tokens to work with the results I was looking for.



 I apologize for posting in the wrong forum... I already knew there was a scripting one and must have gone to the wrong one by accident.
               
               

               
            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
Multiplayer module dialogue
« Reply #8 on: December 08, 2010, 04:55:31 pm »


               deleted, solved.  Be well. Game on!

GM_ODA
               
               

               


                     Modifié par ehye_khandee, 08 décembre 2010 - 04:56 .