IPB

Welcome Guest ( Log In | Register )

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 
Reply to this topicStart new topic
> delay script execution
dyolf
post Aug 29 2009, 07:53 AM
Post #1


Jr. Member
**

Group: Beta Testers
Posts: 27
Joined: 20-May 08
Member No.: 37,176



I would like to delay script execution for 3000 milliseconds. For that i'm looking for a Sleep function. I have tried to access the corresponding kernel32.dll function, but this did not work.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AbsoluteMSTR
post Aug 29 2009, 08:57 AM
Post #2


Full Member
***

Group: Beta Testers
Posts: 125
Joined: 5-August 07
Member No.: 27,229



This can be done with a while loop to, but what do you need a delay for as it may slow your bot down if were to handle multiple events. Suggest you use timers for delaying your code so it doesn't hinder proformance of the bot


--------------------
I offer hosting for ghost hosting on a dedicated server. PM for info
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
dyolf
post Aug 29 2009, 10:17 AM
Post #3


Jr. Member
**

Group: Beta Testers
Posts: 27
Joined: 20-May 08
Member No.: 37,176



QUOTE(AbsoluteMSTR @ Aug 29 2009, 04:57 PM) *

This can be done with a while loop to, but what do you need a delay for as it may slow your bot down if were to handle multiple events. Suggest you use timers for delaying your code so it doesn't hinder proformance of the bot


What i want to do in the is is delaying the game creation message for about 3 seconds to help preventing join bugs.

On a more general level, i would like better control over the output queue of the bot. In the channel i run (op gauss), there are often full game party coming into the channel and leaving again soon. If the bot tries to whisper to all these members (because a new news message has been entered), the bot will lag or even get restricted.

Best thing would be a priority queue, where less important messages (like news or info) would be held back till the load on the message queue goes down. See my other question about the botvars documentation, if the bots queue info is there, it will be quite easy to implement an adaptive message queueing system which reacts to almost empty - almost full.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AbsoluteMSTR
post Aug 29 2009, 03:29 PM
Post #4


Full Member
***

Group: Beta Testers
Posts: 125
Joined: 5-August 07
Member No.: 27,229



I'll write a fuction on this when I get off from work in an hour

Done, Tested, Working on 2.7

Note: DelayAccuracy has to be divisible by 1000

Setup:
Implement this into your script or plugin, Slight modification might need to be done to the Event_Load to work for plugin system or script system

Usage:
In your Code, Instead of using DSP, use AddDelay
AddDelay Duration, Origin, Message, Username, Color
Duration = Time in Seconds
Orign = Number from 1 to 4
Message = Message
Username = Username, needed for Whispering
Color = a color code for AddChat


CODE

Public DelayQList
Const DelayAccuracy = 100

Sub Event_Load()
  DelayQList = Array()
  Set DelayQTime = CreateObj("Timer", "DelayQ")
    DelayQTime.Enabled = True
  DelayQTime.Interval = DelayAccuracy
End Sub

Sub AddDelay( iDuration, iOrigin, sMessage, sUsername, lColor)
  DelayQList = Array_Push( DelayQList, Array(iDuration*1000,iOrigin,sMessage,sUsername,lColor) )
End Sub

Sub DelayQ_Timer()
  If Ubound(DelayQList) >= 0 Then
    Temp = Array()
    For Each DelayQueue In DelayQList
      If DelayQueue(0) <= 0 Then
        DSP DelayQueue(1), DelayQueue(2), DelayQueue(3), DelayQueue(4)
      Else
        Temp = Array_Push(Temp,Array(DelayQueue(0)-DelayAccuracy,DelayQueue(1),DelayQueue(2),DelayQueue(3),DelayQueue(4)))
      End If
    Next
    DelayQList = Temp
  End If
End Sub

'Array_Push
Function Array_Push(Arr, Var)
  ReDim Preserve Arr(UBound(Arr) + 1)
  If VarType(Var) = vbObject Then
    Set Arr(UBound(Arr)) = Var
  Else
    Arr(UBound(Arr)) = Var
  End If
  Array_Push = Arr
End Function


Also a side note

if you want to delay it like 1.5 seconds

then make it sure DelayAccuracy is 100

This post has been edited by AbsoluteMSTR: Aug 29 2009, 03:18 PM


--------------------
I offer hosting for ghost hosting on a dedicated server. PM for info
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Ribose
post Aug 29 2009, 07:08 PM
Post #5


So, it's all about fame, huh?
*****

Group: Global Moderators
Posts: 2,950
Joined: 13-February 06
From: Connecticut, USA. (GMT -5:00)
Member No.: 74



The above is for 2.7 only... The OP is not a beta tester.


--------------------
~Ribose
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AbsoluteMSTR
post Aug 29 2009, 09:03 PM
Post #6


Full Member
***

Group: Beta Testers
Posts: 125
Joined: 5-August 07
Member No.: 27,229



This should work for plugin system

Plua this isn't a script or a plugin. It's a snippit


--------------------
I offer hosting for ghost hosting on a dedicated server. PM for info
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AwaKening
post Aug 29 2009, 09:34 PM
Post #7


Don't u know who I am
***

Group: Sr. Members
Posts: 764
Joined: 19-February 06
From: Utah
Member No.: 275



CreateObj is a 2.7 function. It's not going to work for him.

You're going to have to use pluginsystem timers. WScript.Sleep is out of the question, it's a known bug in stealth.


--------------------
Rival Nations Reborn Map Creator

Clan RnR.com
If you're looking for a "REAL" dota league script, aim or pm me.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
dyolf
post Aug 29 2009, 11:31 PM
Post #8


Jr. Member
**

Group: Beta Testers
Posts: 27
Joined: 20-May 08
Member No.: 37,176



QUOTE(AwaKening @ Aug 30 2009, 05:34 AM) *

CreateObj is a 2.7 function. It's not going to work for him.

You're going to have to use pluginsystem timers. WScript.Sleep is out of the question, it's a known bug in stealth.


Thanks to you all for the code, i will adapt it to the normal 2.6 timers and add it to the news system i use. By the way, that news system would be useful to many. How should i make this available to other? As far as i know its' not possible to add to the repository at the moment.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AbsoluteMSTR
post Aug 29 2009, 11:41 PM
Post #9


Full Member
***

Group: Beta Testers
Posts: 125
Joined: 5-August 07
Member No.: 27,229



52 runs a svn or can post it here


--------------------
I offer hosting for ghost hosting on a dedicated server. PM for info
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 20th April 2014 - 12:23 PM
Skin by Andrea
Website Legal Information | Hosted by LunarPages