Shoutbox

Graident message - 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: Graident message (/showthread.php?tid=62413)

Graident message by Silva on 07-03-2006 at 12:20 PM

I took the Capital Letter script and tried editting it to always do graidents when I write, after my edits the code looks like this :

code:
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage){
sMessage = sMessage.substr(0,1) + '[c=12]' + sMessage.substr(1) + '[/c=4]'
     return sMessage;
}

The problem with that is that the first letter is always 100% black, I tried playing with it alot but most of the time ethier the first letter just disapeared or the script just stopped working. All help will be a apreticated :).


Edit: It's not black , it uses my text color.
RE: Graident message by Ezra on 07-03-2006 at 12:42 PM

function OnEvent_ChatWndSendMessage(pChatWnd, sMessage)
{
  return '[c=12]' + sMessage + '[/c=4]';
}

That will create a gradient, starting at blue and ending at red


RE: Graident message by Silva on 07-03-2006 at 12:45 PM

Thanks for your help :). It works fully now.


RE: Graident message by craig2k5 on 07-03-2006 at 01:19 PM

thanks that works gr8

do you think its possible to have 3 colours?

like going Red>Black>Red ??


RE: Graident message by Ezra on 07-03-2006 at 01:40 PM

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
  return "[c=4]" + Message.substr(0,(Message.length/2)) + "[/c=1][c=1]" + Message.substr((Message.length/2)) + "[/c=4]";
}

That will work
RE: Graident message by craig2k5 on 07-03-2006 at 01:57 PM

thanks that does work... but if you try and do any emoticons it dont.. for instance if u try and do ":@" it will give u :[ @ lol


RE: Graident message by Ezra on 07-03-2006 at 02:01 PM

hmm, yeah, that's because it splits the message in 2 parts, if the emoticon is in the exact middel it will split it up :P

I also noticed that I disabled all commands with this script so I fixed that:

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
  if (Message.substr(0,1) == "/")
  {
    return Message;
  }
  else
  {
    return "[c=4]" + Message.substr(0,(Message.length/2)) + "[/c=1][c=1]" + Message.substr((Message.length/2)) + "[/c=4]";
  }
}

RE: Graident message by Silva on 07-03-2006 at 03:33 PM

You read my mind, I was just about to ask  how to do an if command so that if my message starts with / it wont apply the color :).

Edit: How would I go about making this script work only for certain emails? If you  could just give me a hint in the right direction I could probably write it my self.


RE: Graident message by Voldemort on 07-03-2006 at 04:10 PM

With ezra's latest code, some emos like :O dont work when sent alone :(


RE: Graident message by Silva on 07-03-2006 at 04:20 PM

Actualy all emo's don't work alone because they get split up, for example :P gets split up to : and P. If I knew how to script beter I'd do that if it starts with a " : " the script woulden't effect the first two characters. But now I'm still busy playing with it so that it only runs on the emails I choose so that people in my list that don't have plus won't  mad at me for using colors :P.

Edit: I played around with Ezera's email verification code found here : " http://shoutbox.menthix.net/showthread.php?tid=61888 "

And got this at the end:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
  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 "email1@hotmail.com":
          run(ChatWnd, Message);
          break;
        case "email2@hotmail.com":
          run(ChatWnd, Message);
          break;
      }
    }
  }
}

function run(ChatWnd, Message)
{
 
  if (Message.substr(0,1) == "/")
  {
    return Message;
  }
  else
  {
    return "[c=4]" + Message.substr(0,(Message.length/2)) + "[/c=1][c=1]" + Message.substr((Message.length/2)) + "[/c=4]";
  {

}

If someone could please help me debug it, I just cant understand why it's not working :S .
RE: Graident message by The Brain on 07-03-2006 at 11:37 PM

It's not working, for two reasons (that I can see). Firstly, you are using the event Message Recieved. I am pretty sure that you wantto do this when a Message is Sent, not Recieved.

Secondly, you aren't returning anything. The run function returns the Message with gradient to the event function, but the event function doesn't return it. You have to either assign it to a vriable and return it, or just return it directly.

eg

code:
      var Contact = e.item();
      switch (Contact.Email)
      {
        case "email1@hotmail.com":
          return run(ChatWnd, Message);
        case "email2@hotmail.com":
          return run(ChatWnd, Message);
      }

alternatively
code:
      var Contact = e.item();
      var toReturn = Message;//return the original if email isn't in list
      switch (Contact.Email)
      {
        case "email1@hotmail.com":
          toReturn = run(ChatWnd, Message);
          break;
        case "email2@hotmail.com":
          toReturn = run(ChatWnd, Message);
          break;
      }
      return toReturn;


I would use the first one, but whichever you understand and like better.