Shoutbox

Need help with a 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: Need help with a script (/showthread.php?tid=74244)

Need help with a script by kantom on 05-08-2007 at 06:26 AM

I cant work out why the following scrip doesnt work:

code:
var on = '0'

function OnEvent_ContactSignin(sEmail)
{
Messenger.OpenChat(sEmail);
on = '1'
}

function OnEvent_ChatWndCreated(ChatWnd)
{
if (on == '1')
{
on = '0'
ChatWnd.SendMessage("Hello (!N) !");
}
}


Its meant to open a chat box with someone as soon as they login and then say Hello.
RE: Need help with a script by Spunky on 05-08-2007 at 02:42 PM

This should work (untested though):

code:
function OnEvent_ContactSignin(sEmail){
   var ChatWnd = Messenger.OpenChat(sEmail);
   ChatWnd.SendMessage("Hello (!N) !");
}


Lines of code should end with a semicolon (I think it's needed)
You were using a string as a boolean, which is possible, but not a good way of doing things.
Also, it shouldn't need to events... A ChatWnd object should be created and returned by the OpenChat function

Look in the scripting documentation for more help

RE: Need help with a script by matty on 05-08-2007 at 05:10 PM

Made even smaller:

code:
function OnEvent_ContactSignin(_email){
   Messenger.OpenChat(_email).SendMessage("Hello (!N) !");
}

RE: Need help with a script by pray2win on 05-12-2008 at 06:19 PM

This i want. but then on a certain e-mail adress. :|
Like only for a certain friend ;)

Because i use Answering machine plus and i did
that if they type a code my name changes into
[Jef] Current Online admin: (they're name here)

but i wantthat on sign in of the admins
so when Arrie (one of my admins sign in)
it should say /name [Jef] Current Online admin: Arrie


RE: Need help with a script by roflmao456 on 05-12-2008 at 07:27 PM

quote:
Originally posted by pray2win
This i want. but then on a certain e-mail adress. :|
Like only for a certain friend ;)

Because i use Answering machine plus and i did
that if they type a code my name changes into
[Jef] Current Online admin: (they're name here)

but i wantthat on sign in of the admins
so when Arrie (one of my admins sign in)
it should say /name [Jef] Current Online admin: Arrie

try this then:

code:
function OnEvent_ContactSignin(Email){
if(Email == "someone@somewhere.com") Messenger.OpenChat(Email).SendMessage("/nick [Jef] Current Online admin: (!N)");
}


but if you want to do it without opening a conversation window,
code:
function OnEvent_ContactSignin(Email){
if(Email == "someone@somewhere.com") Messenger.MyName = "[Jef] Current Online admin: " + Messenger.MyContacts.GetContact(Email).Name;
}

RE: Need help with a script by CookieRevised on 05-12-2008 at 07:39 PM

Some important remarks about stuff like:

code:
Messenger.OpenChat(Email).SendMessage("something");
Better never use that.

Before sending a message you should always check if you actually can send a message (and if that conversation window can actually be opened). It is quite possible that you can't even send something because you've blocked the contact, or because the window can't be opened, or the contact has a mobile phone and you need to sign up first for credits, or whatever...

So:
code:
var oChatWnd = Messenger.OpenChat(Email);
if (oChatWnd.EditChangeAllowed) {
     oChatWnd.SendMessage("something")
}

This important check is way too often forgotten in extremely many scripts.

See Plus! Scripting Documentation. This is also explained in the help of the SendMessage() function...

;)
RE: RE: Need help with a script by pray2win on 05-12-2008 at 07:43 PM

quote:
Originally posted by roflmao456
quote:
Originally posted by pray2win
This i want. but then on a certain e-mail adress. :|
Like only for a certain friend ;)

Because i use Answering machine plus and i did
that if they type a code my name changes into
[Jef] Current Online admin: (they're name here)

but i wantthat on sign in of the admins
so when Arrie (one of my admins sign in)
it should say /name [Jef] Current Online admin: Arrie

try this then:

code:
function OnEvent_ContactSignin(Email){
if(Email == "someone@somewhere.com") Messenger.OpenChat(Email).SendMessage("/nick [Jef] Current Online admin: (!N)");
}


but if you want to do it without opening a conversation window,
code:
function OnEvent_ContactSignin(Email){
if(Email == "someone@somewhere.com") Messenger.MyName = "[Jef] Current Online admin: " + Messenger.MyContacts.GetContact(Email).Name;
}


Yes i've seen this while search
but i can't have this worked.
Add new i can ;)
But strange it doesnt work :|
(tested with signing my other e-mail in)