Jump to content

Variable not Declared?


Recommended Posts

I been working on this for a while for a game called Archlord. It works fine a few seconds and then when it trys to call the rebuff function i get this.... if someone can please help me fix it or point the direction. This is my first attempt to make something with autoit.

if timerdiff($timer1) > $bufftimer1 * 1000 then

if timerdiff(^ERROR

ERROR: Variable used without being declared.

Global $UnPaused 
HotKeySet("{PAUSE}", "TogglePause") 
HotKeySet("{END}", "Terminate")
HotKeySet("{HOME}", "Autobuff")

$GameTitle = "Archlord"
Dim $BuffTimer1   = 624 ;===== cooldown of Buff 1 ===========                  
Dim $BuffTimer2   = 528 ;===== cooldown of Buff 2 ===========                    
Dim $BuffTimer3   = 528 ;===== cooldown of Buff 3 ===========


WinWaitActive($GameTitle)



;====BOT STARTS BUT ITS PAUSED!=========
While 1 
    Sleep(10) 
    ToolTip(" start",0,0) 
WEnd 
;=============START PREBUFF============
func Prebuff()
    ToolTip("Buffing ", 2, 0)
        Sleep(2000)
        ControlSend($GameTitle, "", "", "{f5}")
        Sleep(2700)
    $timer1 = timerinit()
    ToolTip("Buffing ", 2, 0)
        ControlSend($GameTitle, "", "", "{f6}")
        Sleep(2700)
    $timer2 = timerinit()
    ToolTip("Buffing ", 2, 0)
        ControlSend($GameTitle, "", "", "{f7}")
        Sleep(2700)
    $timer3 = timerinit()
endfunc
;===============ATTACK=================
Func Attack()

    ToolTip("Bot Runing.",0,0) 
        
        Sleep(100 + Random(1, 300)) 
    
    ControlSend($GameTitle, "", "", "{TAB}")
    sleep(500)
    ControlSend($GameTitle, "", "", "{f1}")
    sleep(13000)

     
EndFunc 
;================REBUFFING===========
Func Rebuff()

if timerdiff($timer1) > $BuffTimer1 * 1000 then
ControlSend($GameTitle, "", "", "{f5}")
$timer1 = timerinit()
sleep(2000)
endif

if timerdiff($timer2) > $BuffTimer2 * 1000 then
ControlSend($GameTitle, "", "", "{f6}")
$timer2 = timerinit()
sleep(2000)
endif

if timerdiff($timer3) > $BuffTimer3 * 1000 then
ControlSend($GameTitle, "", "", "{f7}")
$timer3 = timerinit()
sleep(2000)
endif

endfunc

;================START AUTOBUFF=======
Func Autobuff() 
    $UnBuff = NOT $UnBuff
call Prebuff() 
While $UnBuff
call Rebuff()
wend
endfunc


;===============PAUSE and UNPAUSE=======
Func TogglePause() 
    $UnPaused = NOT $UnPaused 
call ("Prebuff")
    While $UnPaused

call ("Attack")
call ("Rebuff")
wend
endfunc
;=====FUNCTION THAT EXITS BOT===========
Func Terminate() 
    Exit 0 
EndFunc
Link to comment
Share on other sites

  • Developers

Download the full SciTE4AutroIt3 installer and install that.

It will run au3check for you when you press F5(run) and give you this list of warnings:

c:\test.au3(43,22) : WARNING: $timer1: possibly used before declaration.
    If TimerDiff($timer1)
    ~~~~~~~~~~~~~~~~~~~~^
c:\test.au3(48,22) : WARNING: $timer2: possibly used before declaration.
    If TimerDiff($timer2)
    ~~~~~~~~~~~~~~~~~~~~^
c:\test.au3(53,22) : WARNING: $timer3: possibly used before declaration.
    If TimerDiff($timer3)
    ~~~~~~~~~~~~~~~~~~~~^
c:\test.au3(61,23) : WARNING: $UnBuff: possibly used before declaration.
    $UnBuff = Not $UnBuff
    ~~~~~~~~~~~~~~~~~~~~~^
c:\test.au3(62,7) : ERROR: syntax error
    call Prebuff
    ~~~~~^
c:\test.au3(3,35) : ERROR: TogglePause(): undefined function.
HotKeySet("{PAUSE}", "TogglePause")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
c:\test.au3(4,31) : ERROR: Terminate(): undefined function.
HotKeySet("{END}", "Terminate")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
c:\test.au3 - 3 error(s), 4 warning(s)

... and it means that you use a variable that is not declared (known) yet.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

@gui529

Local $timer1, $timer2, $timer3 ;declare variables to avoid the error
;script
Are you sure ? Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

@Jos

About what ? :P

Cheers, FireFox.

Adding this Local Statement.

I would think you need to add it as Glopbal at the beginning of the script or else it IF's won't do much....

:unsure:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@Jos

I always put all my variables as Local and i works great :P

If i want the variable to be a "Global" variable, I put nothing for example : "$var = 1" in the way i dont like to write Global or Dim :unsure:

Cheers, FireFox.

Link to comment
Share on other sites

  • Developers

Im downloding it Jos, hopefully will make writing on notepad less painful. and Firefox predeclaring them like that worked. no more error!! :P

No need to PM me... just post your replies here...

Did you save the scriptfile with an .au3 file extension?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...