Author Topic: Help, script speed color  (Read 737 times)

Legacy_voignar

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help, script speed color
« on: November 05, 2011, 10:37:19 pm »


               Anyone can help me? I am looking for a script for when you enter the chat between ** or in () to change the text color inside. It is said, the script in most role-playing servers.

And if anyone can also a script for when a new player enters or if anything has changed in your account for a password. If the password is invalid, you leave the game.

thanks
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help, script speed color
« Reply #1 on: November 08, 2011, 03:14:18 pm »


               bump.
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Help, script speed color
« Reply #2 on: November 08, 2011, 06:14:38 pm »


               Securing Your Server Without Master Server Authentication - Very handy scripts provided by FunkySwerve

For colored chat text, I personally use an include file to add a ColorText() function in my module's OnPlayerChat script.  I have the chat script look for specific characters at the start of the entered text (// double slashes for grey "OOC" text, .. double periods for "emotes"), then colorize the rest of the text string before replacing the output text (SetChatMessage()?).

I'll see about digging into my chat script to try to dig up the specific code for the text coloring.  It's embedded somewhere in the middle of about 1000 lines of code.

Not sure on the original source of the include file...probably a generous poster on the old BioWare boards.  I've been using it for years.

Edit: Forum seem to be able to properly handle the code for the include file.  Link: inc_colortext.nss (right-click and "Save Link As..." to download.


color chat sample

// Colorized Onchat text
// merge into your own onplayerchat script

#include "inc_colortext"
void main()
{
string sInput = GetPCChatMessage();
string sFirst = GetStringLeft(sInput, 1);
string sLast = GetStringRight(sInput, 1);
if (sFirst == "*" && sLast == "*")  // Special Text Type 1
   {
   sInput = ColorText(sInput, 255, 0, 255);
   SetPCChatMessage(sInput);
   }
else if (sFirst == "(" && sLast == ")")  // Special Text Type 2
   {
   sInput = ColorText(sInput, 200, 200, 200);
   SetPCChatMessage(sInput);
   }
}

               
               

               


                     Modifié par The Amethyst Dragon, 08 novembre 2011 - 07:50 .
                     
                  


            

Legacy_voignar

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help, script speed color
« Reply #3 on: November 12, 2011, 09:55:54 pm »


               Thanks but the color code gives a compilation error in line:
string sInput = GetPCChatMessage();
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help, script speed color
« Reply #4 on: November 12, 2011, 10:15:56 pm »


               Are you running nwn with both expansion packs installed?  
if you are not.  and are not updated to 1.69  I do not think there is any way for you to change the color of the PC's chat.  
GetPCChatMessage was added in the 1.69 update.    So you will at least need to run the critical rebuild if you are not at verson 1.69


http://www.neverwint...characterbasics
               
               

               
            

Legacy_voignar

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help, script speed color
« Reply #5 on: November 13, 2011, 12:38:36 am »


               If I have installed the version 1.69
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help, script speed color
« Reply #6 on: November 13, 2011, 03:50:06 am »


               

voignar wrote...

If I have installed the version 1.69


if you have 1.69 installed,  I do not know, it compiled fine for me. 

What error message are you getting?
               
               

               
            

Legacy_voignar

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help, script speed color
« Reply #7 on: November 13, 2011, 10:09:21 am »


               This is the error:

http://img811.images...sinttulolrv.png
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Help, script speed color
« Reply #8 on: November 13, 2011, 10:48:29 am »


               Line 17: You have it trying to set a variable called "sInput0058", but you've never set up that string variable.  It should actually be "sInput".

If you're still having problems, then I think the problem might be with your game version/patch level.  Which version or patch level is yours?
               
               

               
            

Legacy_voignar

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help, script speed color
« Reply #9 on: November 13, 2011, 12:06:10 pm »


               The variable is solved. But the fault is still on line 7. My game version is 1.69.


Edit.:I reinstalled everything and updated to 1.69 and still does not compile, and of course, does not work.
               
               

               


                     Modifié par voignar, 13 novembre 2011 - 12:46 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Help, script speed color
« Reply #10 on: November 13, 2011, 02:51:40 pm »


               Did you compile the include?

There are two scripts here to incorporate into you mod. One is the include which is accessed at that link, and the rest is the code pasted in the forum. You need both. Compile the include first. Then compile the other script.
               
               

               


                     Modifié par henesua, 13 novembre 2011 - 02:53 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help, script speed color
« Reply #11 on: November 13, 2011, 03:29:21 pm »


               

henesua wrote...

Did you compile the include?

There are two scripts here to incorporate into you mod. One is the include which is accessed at that link, and the rest is the code pasted in the forum. You need both. Compile the include first. Then compile the other script.


umm,  You do not compile Include scripts.   If a Include script does compile on its own, you have a problem.
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Help, script speed color
« Reply #12 on: November 13, 2011, 03:57:06 pm »


               Dragons script only works if the message starts and ends with either ** or ().

This works even if there is "normal" text in the message.
e.g. You could say: I wonder why... *scratches head*

void main()
{
    // Variables
    object oPC = GetPCChatSpeaker();
    string sText = GetPCChatMessage();
    string sFinal = "";
    int iAmRockstar = TRUE;

    // Find color initiation
                   int iStart = FindSubString(sText, "*", 0);
    if (iStart == -1) {iStart = FindSubString(sText, "(", 0); iAmRockstar = FALSE;}
    if (iStart == -1) return;                                           // :C

    // Find color termination
    int iEnd;
    if (iAmRockstar) iEnd = FindSubString(sText, "*", iStart+1);
    else             iEnd = FindSubString(sText, ")", iStart+1);

    // Reconstruct message
    sFinal += GetSubString(sText, 0, iStart) + "<cÞ·/>";
    if (iEnd>-1) sFinal += GetSubString(sText, iStart, iEnd+1 - iStart) + "</c>";
    else iEnd = iStart -1;
    sFinal += GetSubString(sText, iEnd+1, GetStringLength(sText) - iEnd+1);

    // Send message
    SetPCChatMessage(sFinal);
}


It only allows one either ** or (), not both or more then one. Also allows one to type like this
I wonder why... (scratches head
Everything is colored after ( or *, until you get to ) or *, respectively.

Should work as it is if you put it to OnChat event of your module.
               
               

               


                     Modifié par Xardex, 13 novembre 2011 - 04:03 .
                     
                  


            

Legacy_voignar

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Help, script speed color
« Reply #13 on: November 13, 2011, 05:59:09 pm »


               http://img23.imagesh.../sinttulobe.png

Error...
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Help, script speed color
« Reply #14 on: November 13, 2011, 06:33:00 pm »


               If this is the error, you are not updated to the latest patch and it's made perfectly clear by the functions available to you in the screen you provided that you clearly are not, otherwise all these functions would be available to you in your functions filter:

Your screenshot of your own functions filter for GetPC has the following first three missing:

GetPCChatMessage (1.69 addition)
GetPCChatSpeaker (1.69 addition)
GetPCChatVolume (1.69 addition)

(what your function list has)
GetPCIPAddress
GetPCItemLastEquipped
GetPCItemLastEquippedBy
GetPCItemLastUnequipped
GetPCItemLastUnequippedBy
GetPCLevelingUp
GetPCPlayerName
GetPCPublicCDKey
GetPCSpeaker

From the 1.69 release notes:

Script-specific:
· Added new scripting commands:
object GetPCChatSpeaker();
string GetPCChatMessage();
int GetPCChatVolume();
void SetPCChatMessage(string sNewChatMessage="");
void SetPCChatVolume(int nTalkVolume=TALKVOLUME_TALK);


FP!
               
               

               


                     Modifié par Fester Pot, 13 novembre 2011 - 06:49 .