|
You last visited: Today at 08:57
Advertisement
Problem with timers,array for buff script
Discussion on Problem with timers,array for buff script within the AutoIt forum part of the Coders Den category.
01/07/2015, 13:16
|
#1
|
elite*gold: 0
Join Date: Jan 2014
Posts: 43
Received Thanks: 1
|
Problem with timers,array for buff script
Hi i have problem with this script for buffing. I want it when i press F2 to fire buffs ( send keys ) and then put timers "on" for next buffing. So to do like this :
- run script
- script do nothing untill i press F2
- when i press F2 send keys ( cast time is Sleep() )
- put timers "on" and when buff cooldown time ends send only that key where timer is reached cooldown time and put timer "on" again
F2 pause/start script
EDIT :
i correct some of code and now it works, so when i press F2 it send keys but wont send again when cooldown time reach time given in array
Code:
Opt("SendKeyDelay", 5) ;5 milliseconds
HotKeySet("{F2}", "_Start")
Global $Run
Global $keys[7] = [3, 4, 5, 6, 7, 8, 9] ; keys
Global $cast[7] = [2000, 2000, 2000, 2000, 2000, 2000, 2000] ; cast
Global $cooldown[7] = [140000, 100000, 440000, 495000, 480000, 360000, 360000] ; cooldown
While 1
Sleep(100)
WEnd
Func _Start()
$Run = NOT $Run
While $Run
For $i=0 To UBound($keys)-1
If TimerDiff($cast[$i]) > $cooldown[$i] Then
Send($keys[$i])
$cooldown[$i]=TimerInit()
Sleep($cast[$i])
EndIf
Next
WEnd
EndFunc
Thanks in advance
|
|
|
01/07/2015, 15:31
|
#2
|
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
|
First of all, if all your cast times are 2000 (ms), you don't need an array of it.
TimerDiff() expects a TimerInit() handle but you give it a plain number. I don't really get the line
Code:
If TimerDiff($cast[$i]) > $cooldown[$i] Then
Maybe you could comment a bit on it?
|
|
|
01/07/2015, 20:15
|
#3
|
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
|
You might try something like this:
Code:
HotKeySet("{F2}", "GO")
Dim $run, $action, $castTimer, $array[7][3] = [[3,140],[4,100],[5,440],[6,495],[7,480],[8,360],[9,360]] ; key, cd, cd-timer
While Sleep(1)
If $run And TimerDiff($castTimer)>=2000 And TimerDiff($array[$action][2])>=$array[$action][1]*1000 Then
ConsoleWrite("Send("&$array[$action][0]&")"&@CRLF)
$array[$action][2] = TimerInit()
$castTimer=TimerInit()
$action+=1
EndIf
If $action>=2UBound($array) Then $action=0
WEnd
Func GO()
$run = Not $run
EndFunc
|
|
|
01/07/2015, 20:38
|
#4
|
elite*gold: 0
Join Date: Jan 2014
Posts: 43
Received Thanks: 1
|
Quote:
Originally Posted by lolkop
You might try something like this:
Code:
HotKeySet("{F2}", "GO")
Dim $run, $action, $castTimer, $array[7][3] = [[3,140],[4,100],[5,440],[6,495],[7,480],[8,360],[9,360]] ; key, cd, cd-timer
While Sleep(1)
If $run And TimerDiff($castTimer)>=2000 And TimerDiff($array[$action][2])>=$array[$action][1]*1000 Then
ConsoleWrite("Send("&$array[$action][0]&")"&@CRLF)
$array[$action][2] = TimerInit()
$castTimer=TimerInit()
$action+=1
EndIf
If $action>=2UBound($array) Then $action=0
WEnd
Func GO()
$run = Not $run
EndFunc
|
This works fine but not good as it shoul be look on this pic
He cast 3456789 then when timer run out compare it it should cast then like 4389576 because of cooldown time.
And this is not all the same its just for test because i will make gui for it so it will read from it
Global $cast[7] = [2000, 2100, 1800, 2000, 2000, 2000, 2000]
look exaple how will it look like on pic
|
|
|
01/07/2015, 22:40
|
#5
|
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
|
Quote:
Originally Posted by LiveLong23
This works fine but not good as it shoul be look on this pic
He cast 3456789 then when timer run out compare it it should cast then like 4389576 because of cooldown time.
And this is not all the same its just for test because i will make gui for it so it will read from it
Global $cast[7] = [2000, 2100, 1800, 2000, 2000, 2000, 2000]
look exaple how will it look like on pic 
|
That's even more easy... I thought you wanted it to use the numbers in exactly the same order all the time...
Replacing the ordered actions by a simple for loop should do the trick =)
Code:
HotKeySet("{F2}", "GO")
Dim $run, $castTimer, $array[7][3] = [[3,140],[4,100],[5,440],[6,495],[7,480],[8,360],[9,360]] ; key, cd, cd-timer
While Sleep(1)
For $i=0 To UBound($array)-1
If $run And TimerDiff($castTimer)>=2000 And TimerDiff($array[$i][2])>=$array[$i][1]*1000 Then
ConsoleWrite("Send("&$array[$i][0]&")"&@CRLF)
$array[$i][2] = TimerInit()
$castTimer=TimerInit()
EndIf
Next
WEnd
Func GO()
$run = Not $run
EndFunc
Edit:
To add variable delays betweens each cast, you could simply add 2 more dimensions to the array :P (delay and timer)
|
|
|
01/07/2015, 22:53
|
#6
|
elite*gold: 0
Join Date: Jan 2014
Posts: 43
Received Thanks: 1
|
Im quite new to Autoit and i got confused with timers and arrays im doing this all day long
But now it works like a charm, thanks a lot.
|
|
|
 |
Similar Threads
|
Problem mit Array und for Schleife
11/25/2012 - C/C++ - 0 Replies
Hallo, das folgende programm sollte eigentlich ein 11x11 feld aus zufälligen zahlen ausgeben, macht es allerdings nicht :confused:.
#include <iostream>
using namespace std;
int irand( int min, int max)
{
double r = max - min + 1;
return min + (int)(r * rand()/(RAND_MAX+1.0));
}
int main(){
|
[?]Array Problem (VB.NET 2012)
10/24/2012 - .NET Languages - 6 Replies
Hallohallöchen,
Da ich gerade mega auf dem Schlauch stehe wollte ich mal fragen, ob mir einer von euch weiterhelfen kann.
Folgendes Problem:
Ich lese eine eine verschlüsselte .csv Datei ein, entschlüssel sie das folgender Syntax entsteht.
|
Array-Problem
05/13/2010 - AutoIt - 0 Replies
Also ich habe die System-Zeit und das System-Datum in einen Array geladen:
#include <Date.au3>
Global $dat, $tim
$dat = _NowCalcDate()
If @error Then Return
$tim = _NowTime(5)
|
Skill Timers (Buff Period FAQ)
07/15/2009 - 12Sky2 - 7 Replies
It helps you if you grinding arround and don't want to rebuff yourself with all your Skills (it is working on but i think it can be also done on Aeria)
You can use CE 5.5 (Cheat Engine)
1-After you logged on in the game you now go to CE by pressing Alt+Tab or Windows key
2-Select the Twelve Sky 2 process with CE
3-Now wirte for Value "0" Scan Type "Exact Value" and press "New Scan"
|
All times are GMT +1. The time now is 09:01.
|
|