Delay a function |
Author: |
Message: |
Inuyasha
New Member
Posts: 6
36 / / –
Joined: Aug 2006
|
O.P. Delay a function
Hello everybody
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
|
|
08-09-2006 06:01 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
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"
|
|
08-09-2006 08:49 PM |
|
|
Inuyasha
New Member
Posts: 6
36 / / –
Joined: Aug 2006
|
O.P. RE: Delay a function
Thx alot, i needed this
|
|
08-10-2006 06:38 AM |
|
|
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 |
|
|
Inuyasha
New Member
Posts: 6
36 / / –
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.
(Srry for tree, but the code tags filters tabs )
This post was edited on 08-10-2006 at 09:20 AM by Inuyasha.
|
|
08-10-2006 09:19 AM |
|
|
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
Joined: Oct 2003
|
RE: Delay a function
Why have you put OnEvent_Timer() inside the other function? Put it outside.
|
|
08-10-2006 09:23 AM |
|
|
Inuyasha
New Member
Posts: 6
36 / / –
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 )
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 |
|
|
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
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");
}
}
|
|
08-10-2006 09:32 AM |
|
|
Inuyasha
New Member
Posts: 6
36 / / –
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 |
|
|
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
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.
|
|
08-10-2006 09:43 AM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|