Sign in to follow this  
Followers 0
gui529

Variable not Declared?

9 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@gui529

Local $timer1, $timer2, $timer3 ;declare variables to avoid the error
;script

Edit : too slow...

Cheers, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@gui529

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Jos

About what ? :P

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

@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:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0