What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Delay a function

Pages: (2): « First [ 1 ] 2 » Last »
Delay a function
Author: Message:
Inuyasha
New Member
*


Posts: 6
35 / Male / –
Joined: Aug 2006
O.P. Delay a function
Hello everybody :D

I've a question, which is:

Can someone make a function that delays another function for about 3 seconds?

And how do you make custom functions, so not the prefab functions, described in the Script Documentation, but a custom function like one does in Javascript.

I really need it, but i can't think of anything that really works.

Thx in advance.
Mike 8-|
08-09-2006 06:01 PM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Delay a function
Try using the AddTimer function and OnTimer() event for the delay.

Custom functions? Do you mean like this?
code:
function myFunctionName(Param1,Param2){
...
...
...
}

To call the function:
code:
myFunctionName("Param1 Value","Param2 Value");


Hope this is what you wanted *-)
<Eljay> "Problems encountered: shit blew up" :zippy:
08-09-2006 08:49 PM
Profile PM Find Quote Report
Inuyasha
New Member
*


Posts: 6
35 / Male / –
Joined: Aug 2006
O.P. RE: Delay a function
Thx alot, i needed this :)
08-10-2006 06:38 AM
Profile PM Find Quote Report
leachy08
Junior Member
**


Posts: 35
Joined: Jul 2006
RE: Delay a function
To add a timer you can use this code to start the timer:

code:
MsgPlus.AddTimer("atimername", 1000)

And then this code to find when the timer's time interval is reached.

code:
function OnEvent_Timer(TimerId) {
     if (TimerId == "atimername") {
          //Timer interval has been met.
     }
}


If you want to make the timer run just once then you can use:
MsgPlus.CancelTimer("atimerid") after you code in the OnEvent_Timer function above (Just after comment).

Alternatively if you want to make your program goto sleep using a Sleep() Sleep Function
But it will not let you use WLM whilst it is sleeping.
08-10-2006 07:29 AM
Profile E-Mail PM Find Quote Report
Inuyasha
New Member
*


Posts: 6
35 / Male / –
Joined: Aug 2006
O.P. RE: Delay a function
Thx, but now i have this script:
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
    MsgPlus.AddTimer("yoyo", 1000)
   
   
   
   
    if (Message == "=D")
    {
       
        ChatWnd.SendMessage(":')");
       
        function OnEvent_Timer(TimerId)
                {
                         if (TimerId == "yoyo")
                          {
                          ChatWnd.SendMessage("jeej");
                        //Timer interval has been met.
                         }
                }
       
    }
}   


But the timer won't work. I don't get it. :S
(Srry for tree, but the code tags filters tabs :P)

This post was edited on 08-10-2006 at 09:20 AM by Inuyasha.
08-10-2006 09:19 AM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Delay a function
Why have you put OnEvent_Timer() inside the other function? Put it outside.
[Image: spartaafk.png]
08-10-2006 09:23 AM
Profile PM Web Find Quote Report
Inuyasha
New Member
*


Posts: 6
35 / Male / –
Joined: Aug 2006
O.P. RE: RE: Delay a function
quote:
Originally posted by RaceProUK
Why have you put OnEvent_Timer() inside the other function? Put it outside.

You mean like this? :
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
    MsgPlus.AddTimer("yoyo", 1000)
   
    function OnEvent_Timer(TimerId)
        {
                 if (TimerId == "yoyo")
                 {
                  ChatWnd.SendMessage("jeej");
                //Timer interval has been met.
                 }
        }
   
   
    if (Message == "=D")
    {
       
        ChatWnd.SendMessage(":')");
    }
}   


(Srry, but im yet a noob with this stuff :P)

This script won't work either.

This post was edited on 08-10-2006 at 09:30 AM by Inuyasha.
08-10-2006 09:29 AM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Delay a function
:|

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
    MsgPlus.AddTimer("yoyo", 1000)
    if (Message == "=D") {
        ChatWnd.SendMessage(":')");
    }
}


function OnEvent_Timer(TimerId)
        {
    if (TimerId == "yoyo") {
        ChatWnd.SendMessage("jeej");
    }
        }

[Image: spartaafk.png]
08-10-2006 09:32 AM
Profile PM Web Find Quote Report
Inuyasha
New Member
*


Posts: 6
35 / Male / –
Joined: Aug 2006
O.P. RE: RE: Delay a function
quote:
Originally posted by RaceProUK
:|

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
    MsgPlus.AddTimer("yoyo", 1000)
    if (Message == "=D") {
        ChatWnd.SendMessage(":')");
    }
}


function OnEvent_Timer(TimerId)
        {
    if (TimerId == "yoyo") {
        ChatWnd.SendMessage("jeej");
    }
        }


Im getting an error which says "ChatWnd.SendMessage" is not defined....
08-10-2006 09:39 AM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Delay a function
That's because there's no way at the moment for OnEvent_Timer() to know which chat window it's using.

All I did was move code around so functions were written properly.
[Image: spartaafk.png]
08-10-2006 09:43 AM
Profile PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On