Shoutbox

New to Plus! scripting :). - 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: New to Plus! scripting :). (/showthread.php?tid=65632)

New to Plus! scripting :). by Buzz44 on 08-31-2006 at 04:58 AM

Ahoy there!

I only just found out that Messenger Plus! existed 3 days ago and I am looking to create my own script already because its uber good ^^.

The script is already in progress but I am not happy with the startup procedure. Currently I am using OnEvent_Initialize() testing whether the return value is True or False. If False, I initiate my variables and everybody is happy, but if True, I start a timer, using OnEvent_Timer to wait for the timer to trigger, and then initiate my variables.

The problem is the variables involve Messenger.MyName and Messenger.MyPersonalMessage and if the timer doesn't fuction as correctly I get errors because Messenger.MyName etc are not recognised. I may or may not got errors depending on whether; The CPU has just booted up and WML is s et for auto-login, WML is already running (but signed out) and you are signing in, or, you have just started WML and it is signing in automatically.

Depending on which of the above it is, WML takes longer to sign in the and timer trigger event may fire early then expected thus yielding errors. Ofcourse the obvious solution would be to increase the timer interval but I found the whole idea of using a timer worrying, because it is a very unreliable method of testing whether WML is ready or not.

I have 2 questions...

1) In JScript is there a key/reserved word to exit an Event function? For instance, OnGetScriptMenu, if I used a keyword (much like Return or Exit Sub in VB.Net), it will exit the function immediately and..

2) Is there a universal template someone has to accommodate the different situations that the script may start in, ie. CPU booting up, WML starting and WML signing in.

Sorry I can't post any code atm as I'm not at home but give me a few hours and I will ;).

Any help would be appreciated :).


RE: New to Plus! scripting :). by cloudhunter on 08-31-2006 at 05:02 AM

I believe there is an "OnEvent_Signin" Which might suit your needs...

Cloudy


RE: New to Plus! scripting :). by Buzz44 on 08-31-2006 at 05:04 AM

Yes, but that won't work if the user is already signed in and they import the script. Thanks anyway ;).

Edit:

Thats why I wanted to know if there was a universal method, or an End Function keyword ;).


RE: New to Plus! scripting :). by matty on 08-31-2006 at 06:12 AM

OnEvent_SigninReady ?

There isn't really a way to do what you want, unless I am just too tired/drunk and not understanding what you want.


RE: New to Plus! scripting :). by Buzz44 on 08-31-2006 at 07:34 AM

Yes I seen that, and though it is one better then OnEvent_Signin(), it will still only trigger when the user is signing in, not when the user imports the script. I know ways to get around the problem but that means I will have redundant code which I really don't want.

P.S Maybe you are too drunk ^o)?


RE: New to Plus! scripting :). by foaly on 08-31-2006 at 08:03 AM

quote:
Originally posted by Buzz44
Ahoy there!
1) In JScript is there a key/reserved word to exit an Event function? For instance, OnGetScriptMenu, if I used a keyword (much like Return or Exit Sub in VB.Net), it will exit the function immediately and..


yes that is return;

and why not use the OnEvent_Signin() and just check if it is the first time the script is used (so imported..) with a reg code or something... and activate it manually only that time?
not the most beautiful solution... but it will work...
RE: New to Plus! scripting :). by Eljay on 08-31-2006 at 08:10 AM

quote:
Originally posted by foaly
why not use the OnEvent_Signin() and just check if it is the first time the script is used (so imported..) with a reg code or something... and activate it manually only that time?
not the most beautiful solution... but it will work...

because OnEvent_Signin is not triggered if you activate it when you are already signed in.

you need to use both events and make them both call a startup event to avoid duplicating code
code:
function Startup(){
  //do startup stuff here
}
function OnEvent_Initialize(MessengerStart){
  //Check if user is signed in when script is started
  if((MessengerStart == false) && (Messenger.MyStatus > 1)){
    Startup();
  }
}
function OnEvent_SigninReady(){
  Startup();
}

RE: New to Plus! scripting :). by Buzz44 on 08-31-2006 at 08:51 AM

Thanks Eljay. No sooner then you had posted that I figured the solution out for myself ;).

Thanks everyone :).


RE: New to Plus! scripting :). by Buzz44 on 08-31-2006 at 08:56 AM

One last thing. Do I really need to check if Messenger.MyStatus is > 1? If MessengerStart = False doesn't that mean that WML is already running and the user is logged in? Or do scripts run even when WML is running no user signed in?

code:
if((MessengerStart == false) && (Messenger.MyStatus > 1)){
    Startup();
  }

RE: New to Plus! scripting :). by Eljay on 08-31-2006 at 08:57 AM

quote:
Originally posted by Buzz44
do scripts run even when WML is running no user signed in?

yes :P
RE: New to Plus! scripting :). by Buzz44 on 08-31-2006 at 08:58 AM

Ty ^^.


RE: New to Plus! scripting :). by Anton on 08-31-2006 at 02:18 PM

I think that Messenger.MyStatus is 0 when the user is not signed in...


RE: New to Plus! scripting :). by matty on 08-31-2006 at 03:50 PM

quote:
Originally posted by Matty
Patchou explained what bMessengerStart is on Initalize.

(9:58 PM) Patchou: Initialize is called with bMessengerStart to true when the scrips is loaded while Messenger is being started (the process, so its called only once that way). The variable is falose if the script is being started or restarted after that

RE: New to Plus! scripting :). by Buzz44 on 08-31-2006 at 11:39 PM

Thanks for the help but its in the helpfile ^^.