Shoutbox

[Request] Script to make sent messages gradient - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Request] Script to make sent messages gradient (/showthread.php?tid=61294)

[Request] Script to make sent messages gradient by t_pass6 on 06-25-2006 at 01:24 PM

Hello everybody,

I'd like to make a script that would make every message i send gradient, and i need some help.
Anyone has ideas?


RE: Script to make sent messages gradient by vaccination on 06-25-2006 at 01:49 PM

In the conversation window click the Format panel icon then click the lil "T" in the top right coner of the format panel and select gradient, then select two colours you like and type your text and it will be sent in a gradient!

Hope this helps!


RE: Script to make sent messages gradient by Val on 06-25-2006 at 01:56 PM

quote:
Originally posted by vaccination

In the conversation window click the Format panel icon then click the lil "T" in the top right coner of the format panel and select gradient, then select two colours you like and type your text and it will be sent in a gradient!

Hope this helps!
Vaccination, I think he knows how to do this but wants to have script that does this for every message he sends. Please read posts carefully next time.
RE: Script to make sent messages gradient by t_pass6 on 06-25-2006 at 03:04 PM

That's exactly what i meant ValSpy. I know i have to make a script with OnEvent_ChatWndSendMessage, but i don't what to do next. Can someone help me?


RE: Script to make sent messages gradient by mathieumg on 06-25-2006 at 03:07 PM

You got to surround the sent message (Message variable) with the approriate gradient color tags ([c=#color1]Message[/c=#color2]) and return this value (so it is sent instead of the initial Message)


RE: [Request] Script to make sent messages gradient by t_pass6 on 06-25-2006 at 03:19 PM

Then i must do
Function OnEvent_ChatWndSendMessage(ChatWnd, ChatMsg)
{
ChatMsg = "[c=58]" + ChatMSg + "[/c=47]";
ChatWnd.SenMessage (ChatMsg);
}

Is This correct?


RE: [Request] Script to make sent messages gradient by mathieumg on 06-25-2006 at 03:21 PM

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
   var MsgOutput = null;
   MsgOutput= "[c=58]" + Message + "[/c=47]";

   return MsgOutput;
}


Try that

Edit: Just tested it and it works 100% ;)
RE: [Request] Script to make sent messages gradient by t_pass6 on 06-25-2006 at 03:23 PM

Thanks a lot!


RE: [Request] Script to make sent messages gradient by mathieumg on 06-25-2006 at 03:24 PM

No problem :) You're welcome


RE: [Request] Script to make sent messages gradient by t_pass6 on 06-26-2006 at 08:50 AM

Another question : I want to have different effects based on the contact i send messages to. I made a function to replace the message to avoid being redundant

here's the code i use :
var MsgOutput = null;
var Color1 = null;
var Color2 = null;
function Replace_Text(Color1, Color2, Message, MsgOutput)
{
    MsgOutput = "[c=" + Color1 + "]" + Message + "[/c=" + Color2 + "]";
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    if (Contact.Email == xxxxx@xxxxxxx) {
        Color1 = "#010176";
        Color2 = "#2D0352";
        Replace_Text(Color1, Color2, Message, MsgOutput);
    }
    return MsgOutput;
}

But i can't start the script, i get an error. Has anybody ideas why?


RE: [Request] Script to make sent messages gradient by Ezra on 06-26-2006 at 09:04 AM

code:
var MsgOutput = null;
var Color1 = null;
var Color2 = null;

function Replace_Text(Color1, Color2, Message, MsgOutput)
{
  MsgOutput = "[c=" + Color1 + "]" + Message + "[/c=" + Color2 + "]";
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
  var Contacts = ChatWnd.Contacts; 
  var e = new Enumerator(Contacts);
 
  for(; !e.atEnd(); e.moveNext())
  {
    var Contact = e.item();
    if (Contact.Email == xxx@yyy.zzz)
    {
      Color1 = "#010176";
      Color2 = "#2D0352";
      Replace_Text(Color1, Color2, Message, MsgOutput);
     
      return MsgOutput;
    }
  } 
  return Message;
}

This might work, can't test, network is acting up.

This will iterate trough a list of contacts in the current ChanWnd, and if it finds the contact it will send the gradiented message, else it will send the message unaltered.
RE: [Request] Script to make sent messages gradient by t_pass6 on 06-26-2006 at 09:15 AM

Well, as i'm seeing it, if it finds the Contact il will send both the unaltered and the altered message, because os the return Message at the end of the function.

Edit : and i as was seeing it, i didn't want to use it in a chat with 2 or 3 contacts.


RE: [Request] Script to make sent messages gradient by Ezra on 06-26-2006 at 09:19 AM

The correct behavior for a function is to stop after returning IIRC, but if this happends use this:

code:
var MsgOutput = null;
var Color1 = null;
var Color2 = null;
var sendUnaltered = true;

function Replace_Text(Color1, Color2, Message, MsgOutput)
{
  return "[c=" + Color1 + "]" + Message + "[/c=" + Color2 + "]";
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
  var Contacts = ChatWnd.Contacts; 
  var e = new Enumerator(Contacts);
 
  for(; !e.atEnd(); e.moveNext())
  {
    var Contact = e.item();
    if (Contact.Email == nemo_569@hotmail.com)
    {
      Color1 = "#010176";
      Color2 = "#2D0352";
     
      return Replace_Text(Color1, Color2, Message, MsgOutput);
      sendUnaltered = false;
    }
  }
  if(sendUnaltered)
  {
    return Message;
  }
}

EDIT: replaced the bool variable with a more understandable variable: sendUnaltered
RE: [Request] Script to make sent messages gradient by timbothegreat on 06-26-2006 at 09:31 AM

Here's a snippet from a script I wrote to randomize the gradient upon sending.  Note that, depending on your background picture, this can be difficult to see.

//Global variable
var c_max = 99;

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    var c1 = Math.floor(Math.random() * c_max);
    var c2 = Math.floor(Math.random() * c_max);
    return('[c=' + c1 + ']' + Message + '[/c=' + c2 + ']');
}


RE: [Request] Script to make sent messages gradient by ThunderStorm on 06-26-2006 at 09:40 AM

I want a counter by the messages.
Example:

My name is robin (1233)
Is that possible?


RE: [Request] Script to make sent messages gradient by Ezra on 06-26-2006 at 09:45 AM

quote:
Originally posted by ThunderStorm
I want a counter by the messages.
Example:

My name is robin (1233)
Is that possible?

Sure, but please make your own thread requesting this, don't hijack someone elses thread please :)
RE: [Request] Script to make sent messages gradient by t_pass6 on 06-26-2006 at 09:56 AM

Well this isn't what i want to do timbothegreat. I just want to have specific gradient for each contact who wants to see it. And I also don't want to use it in chat with multiple contacts. I was thinking about something like this:

code:
var Color1 = null;
var Color2 = null;
var MsgOutput = null;

function Replace_Text(Color1, Color2, Message, MsgOutput)
{
     MsgOuput = "[c=" + Color1 + "]" + Message + "[/c=" + Color2 + "]";
}

function OnEvent_ChatWndSendMessage(Chatwnd, Message)
{
     var Contactnum = Enumerator(ChatWnd.Contacts);
     if (Contactnum < 3)
     {
          MsgOutput = Message
          if (Contact.Email == xxx@yyy.zzz)
          {
                Color1 = "#000000";
                Color2 = "#FFFFFF";
                Replace_Text(Color1, Color2, Message, MsgOutput) ;
          }
     }

     return MsgOutput;
}

Seems simpler to me.
RE: [Request] Script to make sent messages gradient by crank on 06-26-2006 at 10:28 AM

be sure to add this in your script else commands like /me won't work.

code:
if (Message.charAt(0) == '/')
        return(Message);
I'm working on a script to do autogradients and colors, with per contact options and such, having a hard time with PlusWnds tho, but nothing i can't handle

RE: [Request] Script to make sent messages gradient by t_pass6 on 06-26-2006 at 10:41 AM

thanks, but i get an error with the line var Contactnum = Enumerate(ChatWnd.Contacts), anyone sees why?


RE: [Request] Script to make sent messages gradient by timbothegreat on 06-26-2006 at 11:00 AM

quote:
Originally posted by t_pass6
thanks, but i get an error with the line var Contactnum = Enumerate(ChatWnd.Contacts), anyone sees why?

If you're only interested in the number of contacts, you don't need to create the enumerator object.  You can use the Contacts.Count property.

Contactnum = ChatWnd.Contacts.Count
RE: [Request] Script to make sent messages gradient by t_pass6 on 06-26-2006 at 11:28 AM

Yes, but i need to have properties about contatcs, so it is good the way it put it. But i have some problem with this code :

code:
var Color1 = null;
var Color2 = null;
var MsgOutput = null;

function Replace_Text(Color1, Color2, Message, MsgOutput)
{
    if (Message.charAt(0) == '/')
    {
        return Message;
    }
    Debug.Trace("Vérification du premier caractère du message terminée");
    MsgOuput = "[c=" + Color1 + "]" + Message + "[/c=" + Color2 + "]";
    Debug.Trace("Remplacement du message éffectué");
}

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    var Contact = ChatWnd.Contacts;
    var Num = new Enumerator(Contact);
    Debug.Trace("Enumération des Contacts Terminée");
    MsgOutput = Message;
    if (Num < 2)
    {
        Debug.Trace("Vérification du nombre de contacts Terminée");
        MsgOutput = Message
        if ( Contact.EMail == 'xxx@yyy.zzz') {
            Debug.Trace("Vérification de l'Email du contact terminée");
            Color1 = "#000000";
            Color2 = "#FFFFFF";
            Debug.Trace("Définition des couleurs Terminée");
            Replace_Text(Color1, Color2, Message, MsgOutput);
        }
    }

    return MsgOutput;
    Debug.Trace("Envoi du Message");
}


It goes no further than : Debug.Trace("Enumération des Contacts Terminée");
Does anyone see why?
P.S. : traces are in french, because i'm french
RE: [Request] Script to make sent messages gradient by Ezra on 06-26-2006 at 11:33 AM

Why don't you just use mine?

I tested it now, and it works perfectly...

EDIT: This on supports more contacts more easily

code:
var MsgOutput = null;
var Color1 = null;
var Color2 = null;
var sendUnaltered = true;

function Replace_Text(Color1, Color2, Message, MsgOutput)
{
  return "[c=" + Color1 + "]" + Message + "[/c=" + Color2 + "]";
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
  var Contacts = ChatWnd.Contacts; 
  var e = new Enumerator(Contacts);
 
  for(; !e.atEnd(); e.moveNext())
  {
    var Contact = e.item();
   
    switch(Contact.Email)
    {
      case "alpha@web2messenger.com":
        Color1 = "#000000";
        Color2 = "#FFFFFF";
     
        return Replace_Text(Color1, Color2, Message, MsgOutput);
        break;
       
      case "beta@web2messenger.com":
        Color1 = "#FFFFFF";
        Color2 = "#000000";
     
        return Replace_Text(Color1, Color2, Message, MsgOutput);
        break;
       
      default:
        return Message;
    }
  } 
}

RE: [Request] Script to make sent messages gradient by t_pass6 on 06-26-2006 at 11:42 AM

because i want to use it only in conversation with one contact not several, and your script works for both of the cases.


RE: [Request] Script to make sent messages gradient by Ezra on 06-26-2006 at 11:46 AM

Oh, allright I see...

This one will only use gradients when there is 1 contact in the conversation else it will gradient based on the specific contact:

code:
var MsgOutput = null;
var Color1 = null;
var Color2 = null;
var sendUnaltered = true;

function Replace_Text(Color1, Color2, Message, MsgOutput)
{
  return "[c=" + Color1 + "]" + Message + "[/c=" + Color2 + "]";
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
  var Contacts = ChatWnd.Contacts; 
  var e = new Enumerator(Contacts);
 
  if(Contacts.Count == 1)
  {
 
    for(; !e.atEnd(); e.moveNext())
    {
      var Contact = e.item();
     
      switch(Contact.Email)
      {
        case "alpha@web2messenger.com":
          Color1 = "#000000";
          Color2 = "#FFFFFF";
       
          return Replace_Text(Color1, Color2, Message, MsgOutput);
          break;
         
        case "beta@web2messenger.com":
          Color1 = "#FFFFFF";
          Color2 = "#000000";
       
          return Replace_Text(Color1, Color2, Message, MsgOutput);
          break;
         
        default:
          return Message;
      }
    }
  }
  else
  {
    return Message;
  }
}

RE: [Request] Script to make sent messages gradient by demajen on 06-26-2006 at 06:18 PM

If your contact doesn't have MSGPLUSLIVE installed, will they see the colour codes in their window, or not? At the moment, without scripts, my contacts who don't have it see [ c=1 ] and [ /c=4] tags and I don't want em too. I figured this was best place to ask. =)


RE: RE: [Request] Script to make sent messages gradient by Dally on 06-26-2006 at 06:47 PM

quote:
Originally posted by demajen
If your contact doesn't have MSGPLUSLIVE installed, will they see the colour codes in their window, or not? At the moment, without scripts, my contacts who don't have it see [ c=1 ] and [ /c=4] tags and I don't want em too. I figured this was best place to ask. =)


I also discovered this, isn't there anyway that non messenger plus users do not see these colour codes infront of every message I send.
RE: [Request] Script to make sent messages gradient by t_pass6 on 06-27-2006 at 01:34 PM

I don't think that there is a way to know if a contact has Messenger Plus or not, you just have to add the contacts who have MsgrPlus to the Switch cases list, and they will see it, but if someone doesn't have his adress in the cases list the message will be sent like a normal message (default case). There is also a small modification of the code ezra made, because you have to check if the message is a command or not. You just have to add a condition to the Replace_Text function like this :

code:
function Replace_Text(Color1, Color2, Message, MsgOutput)
{
      if (Message.charAt(0) == '/')
{
return Message;
}
      else{
  return "[c=" + Color1 + "]" + Message + "[/c=" + Color2 + "]";
}
}

RE: [Request] Script to make sent messages gradient by pags2k7 on 06-27-2006 at 04:28 PM

what about 3 colors?


RE: [Request] Script to make sent messages gradient by mathieumg on 06-27-2006 at 04:30 PM

You'd have to code your own gradient script for that, way more complicated ;)


RE: [Request] Script to make sent messages gradient by hmaster on 06-27-2006 at 05:02 PM

Or you could split the message into 2 parts and do
[c=1]FirstPart[/c=2][c=2]SecondPart[/c=3]
Should be easy to count the number of chars divide by two and substr it *-)


RE: [Request] Script to make sent messages gradient by Eljay on 06-27-2006 at 05:13 PM

quote:
Originally posted by hmaster
Or you could split the message into 2 parts and do
[c=1]FirstPart[/c=2][c=2]SecondPart[/c=3]
Should be easy to count the number of chars divide by two and substr it *-)

var Color1 = 1;
var Color2 = 2;
var Color3 = 3;

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
   var part1 = Message.substr(0, Math.floor(Message.length / 2));
   var part2 = Message.substr(Math.floor(Message.length / 2));
   return "[c=" + Color1 + "]" + part1 + "[/c=" + Color2 + "][c=" + Color2 + "]" + part2 + "[/c=" + Color3 +"]";
}
RE: RE: [Request] Script to make sent messages gradient by Dally on 06-27-2006 at 07:14 PM

quote:
Originally posted by t_pass6
I don't think that there is a way to know if a contact has Messenger Plus or not, you just have to add the contacts who have MsgrPlus to the Switch cases list, and they will see it, but if someone doesn't have his adress in the cases list the message will be sent like a normal message (default case). There is also a small modification of the code ezra made, because you have to check if the message is a command or not. You just have to add a condition to the Replace_Text function like this :
code:
function Replace_Text(Color1, Color2, Message, MsgOutput)
{
      if (Message.charAt(0) == '/')
{
return Message;
}
      else{
  return "[c=" + Color1 + "]" + Message + "[/c=" + Color2 + "]";
}
}


I don't undastnd wha u mean by add the contacts who have
messenger plus live to a cases list.

Which cases list is this???
RE: [Request] Script to make sent messages gradient by t_pass6 on 06-27-2006 at 09:02 PM

Further in the code you have a Switch function, it's like an if then else structure but a lot simpler. As you can see after the Switch you have an enumeration of case "xxx@yyy.zzz" foloowed by a call of the Repkace_Text function. The number of the cases can beeverything you want. If you want that your contact see your messages gradient you just have to add

code:
case "aaa@bbb.ccc":
     Color1 = "#0000FF";
     Color2 = "#FF0000";
     return Replace_Text(Color1, Color2, Message, MsgOutput);
     break;

This must be done for every contact you want to send gradient messages to. If you don't want a contact to receive gradient messages, you just have to do nothing, it his adress isn't in the "case" list, he won't receive gradient messages. That was what I meant by the cases list.
RE: [Request] Script to make sent messages gradient by Dally on 06-28-2006 at 11:58 AM

Oh I see what u mean now.

I tried that but it never worked for me, contacts in my cases list still
couldn't see the gradient text for some reason :S

Thx newys mate :)