Shoutbox

Help with script... - 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: Help with script... (/showthread.php?tid=61221)

Help with script... by GrimReapa on 06-25-2006 at 10:11 AM

I'm trying to make a simple script (for my first time) that will show how many times I have recieved a message with "Nick" in it... but at the moment I only know how to get it to check if the whole message is Nick...
How would i change it so that if any part of the message contained "Nick" then it would update the count?

Current Code:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Sender, ChatMsg, ChatType)
{
    if (ChatMsg == "Nick") {
    Nick = Nick + 1;
    Debug.Trace("Added one to count.");
    ChatWnd.SendMessage("The Nick Count is now at: " + Nick);
    }
    if (ChatMsg == "nick") {
    Nick = Nick + 1;
    Debug.Trace("Added one to count.");
    ChatWnd.SendMessage("The Nick Count is now at: " + Nick);
    }
}

RE: Help with script... by absorbation on 06-25-2006 at 10:12 AM

Why the two if statements? Try elseif for the second :P

Edit: Where have you defined your Nick varible?
Edit 2: Woops I am talking some bull. *wakes up*


RE: Help with script... by alexp2_ad on 06-25-2006 at 10:14 AM

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Sender, ChatMsg, ChatType)
{
if (ChatMsg.toLowerCase().indexOf("nick") > -1) {
Nick = Nick + 1;
Debug.Trace("Added one to count.");
ChatWnd.SendMessage("The Nick Count is now at: " + Nick);
}
}



And that checks for any case as well.

BTW, if you just store it as a variable then the "nick count" will be lost whenver the plugin is stopped, I recommend saving to a file or the registry on uninitialize then loading on initialize. ;)
RE: Help with script... by GrimReapa on 06-25-2006 at 10:17 AM

Thanks for your help! works great, just had to take "Nick" out of the message, because it kept repeating :P


RE: Help with script... by Eljay on 06-25-2006 at 10:17 AM

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Sender, ChatMsg, ChatType)
{
   if(ChatMsg.search(/nick/i) > -1){
        Nick = Nick + 1;
        Debug.Trace("Added one to count.");
        ChatWnd.SendMessage("The Nick Count is now at: " + Nick);
    }
}

edit: meh im slow
RE: Help with script... by ThunderStorm on 06-25-2006 at 10:28 AM

how work that script?
Is there a command for in that script?


RE: RE: Help with script... by CookieRevised on 06-25-2006 at 11:56 AM

[OFF TOPIC]

quote:
Originally posted by ThunderStorm
how work that script?
Is there a command for in that script?

The shown source code is part of a script, it is most likely not the complete script.

Also, if you look carefully you see that this function is actually an event:
function OnEvent_ChatWndReceiveMessage(...).

An event is triggered and executed automatically when certain things take place. In this case the event will trigger whenever a message is recieved and thus the function gets executed.

To know how scripts work read the official script documentation.

[/OFF TOPIC]