Sign in to follow this  
Followers 0
XchokeholdX

Adlibenable() and Disable()

11 posts in this topic

#1 ·  Posted (edited)

I only started coding in autit a few days ago, so please bear with me!

I made a tradebot for an online game, and so far its working great, but i do want to build in some fail saves, for example, if a player exits a trade screen suddenly (reboot, alt f4, mice chewing on cables etc..) I want the bot to recognise this, and stop a loop from running.

I discovered Adlibenable(), and I tried it, without success.

just a few questions about adlibenable()

1. can you have more than one adlibenable running? or is it simehow limited to 1 per script?

2. what does exactly the function adlibDISABLE() does? do you have to specify which adlib it has to disable? if so, how?

I try to give my example here:

CODE

$botcounter = 0; begin counter of the bot

call("login");; bot login ;; opens the program, and goes into the trade lobby to trade with other players

Do

$tradefail = 1

while $tradefail = 1

AdlibEnable("checktradelobby", 5000)

call("waitfortradeinvite")

MouseClick ("left", 730, 550 , 1); accept trade

sleep(10000) ; at this point, the program opens up another screen, which is the "in" trade room with the other player.

; rest of the in trade code

, rest of the in trade code

; etc..

WEnd

$botcounter = +1

until $botcounter = 1000

Func checktradelobby()

if pixelsearch (1175, 632, 1176, 633, 0x43517E) = @error Then

$tradefail=0 ;

call("reboot")

EndIf

EndFunc

Func reboot()

MouseClick("left", 1258, 114, 1);click home

sleep(1000)

MouseClick ("left" , 355, 616 , 1); go to trade lobby

EndFunc

Func waitfortradeinvite()

MouseClick ( "left" , 149, 485 , 1); make active window

; Wait for trade request

$checksum = PixelChecksum(745,458, 750,460)

While $checksum = PixelChecksum(745,458, 750,460)

sleep(500)

Wen

EndFunc

the problem is that after it detects an error while in trade, it will call Reboot, and bring it back to the trade lobby. so far so good, but somehow it gets stuck in the reboot function, and continues to do the reboot, probably because the adlibenable is still running right?

any helpful advice apreciated.

Edited by XchokeholdX

Share this post


Link to post
Share on other sites



1. can you have more than one adlibenable running? or is it simehow limited to 1 per script?

2. what does exactly the function adlibDISABLE() does? do you have to specify which adlib it has to disable? if so, how?

1. Yes, AdlibEnable is limited to one at a time per script.

2. AdlibDisable() stops the calling of the function by AdlibEnable()

Pretty obvious in my opinion, and I can bet it was somewhere in the help file too. Anyway, this is easier and I can't blame you for being a lazy ass programmer. :whistle:

Also, there is no need to Call("login") just login() will suffice.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

ok, so I´ll delete all the "call" lines in my script then, but by your explination, I need to add the adlibdisable somewhere?

where? just in front of the func reboot? so that it stops the adlib check?

and to respond to a yes to this question, how do I correctly set $Tradefail back to 1 then? so the loop starts clean again?

yes I know, still a long way to learn..

Edited by XchokeholdX

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ok, so I´ll delete all the "call" lines in my script then, but by your explination, I need to add the adlibdisable somewhere?

where? just in front of the func reboot? so that it stops the adlib check?

and to respond to a yes to this question, how do I correctly set $Tradefail back to 1 then? so the loop starts clean again?

yes I know, still a long way to learn..

Well, I'm sure you're not going to like my solution.. I've just only taken a look at your script and it's full of flaws and glitches. :whistle: I may rewrite the whole thing being over ambitious.. Just a minute.

Edit: After all, it wasn't so bad.. :)

CODE
$botcounter = 0; begin counter of the bot

login() ;; bot login ;; opens the program, and goes into the trade lobby to trade with other players

Do
    While checktradelobby()
        waitfortradeinvite()
        MouseClick("left", 730, 550, 1); accept trade
        Sleep(10000) ; at this point, the program opens up another screen, which is the "in" trade room with the other player.
        ;rest of the code
    WEnd
    $botcounter += 1
Until $botcounter = 1000

Func checktradelobby()
    PixelSearch(1175, 632, 1176, 633, 0x43517E)
    If Not @error Then Return 1
EndFunc

Func reboot()
    MouseClick("left", 1258, 114, 1);click home
    Sleep(1000)
    MouseClick("left", 355, 616, 1); go to trade lobby
EndFunc

Func waitfortradeinvite()
    MouseClick("left", 149, 485, 1); make active window
    ; Wait for trade request
    $checksum = PixelChecksum(745, 458, 750, 460)
    While $checksum = PixelChecksum(745, 458, 750, 460)
        Sleep(500)
    Wend
EndFunc
Edited by Manadar

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

ok, I can see it, but I think you forgot to tell it to reboot when it does not return 1, right?

and second, does this script not check if we are in the in tradescreen just only once, at the start?

lastly, it has to check that we are and stay in the "in" trade screen, not the trade lobby itself. (mistake on my part)

so heres my revision:

$botcounter = 0; begin counter of the botlogin() ;; 
bot login ;; opens the program, and goes into the trade lobby to trade with other players
Do    
    While  waitfortradeinvite()        
        MouseClick("left", 730, 550, 1); accept trade        
        Sleep(10000) ; at this point, the program opens up another screen, which is the "in" trade room with the other player.        
          
    WEnd
    While checkintrade(); it has to keep checking if we stay in the In trade screen, not the lobby.
            ;;rest of the in trade code, click cards, click accept, etc..
    WEnd
    



$botcounter += 1
Until $botcounter = 1000


Func checkintrade()    ; will it not just check this once at the start when we enter the "in" trade screen? or will it loop?
    PixelSearch(1175, 632, 1176, 633, 0x43517E)    If Not @error Then Return 1
        if @error then reboot(); I added this, I guess its not correct, but if this func does not return a 1, what happens?  
            ;I cant seem to read what it will do, how will it do the reboot func?
    EndFunc
    
Func reboot()    
    MouseClick("left", 1258, 114, 1);click home    
    Sleep(1000)    
    MouseClick("left", 355, 616, 1); go to trade lobby
    EndFunc
    
Func waitfortradeinvite()    
    MouseClick("left", 149, 485, 1); make active window    ; Wait for trade request    
    $checksum = PixelChecksum(745, 458, 750, 460)    
    While $checksum = PixelChecksum(745, 458, 750, 460)        
        Sleep(500)    
        Wend
    EndFunc
Edited by XchokeholdX

Share this post


Link to post
Share on other sites

I may have forgotten a few things because I lack understanding of the initial problem, it is up to you to finalize this script.

Do you have any other questions or does this finish it?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

ok, let me try it again from the start, I might not have been clear enough, sorry for that:

the bot will sit in a program lobby (where players meet) and waits until he gets a "trade request" from another player, which is a simple accept yes/no button.

the bot will then go together with that other player to a new screen, which is the "in" trade screen, where cards can be traded with eachother.

the problem my bot has, is that if that player suddenly goes out of that "in" trade screen, be it by connection loss, or simply exits, my bot still thinks he is in that trade screen, and continues to wait, although he is then back in the trade lobby, and thus stops working, since a new trade requests cannot be detected.

here´s the rundown:

1. bot login

2. goes to trade lobby

in loop:

3. waits for trade request

4. goes to trade room

5. waits for other player trades cards <--- here i need it to check every few seconds or so if it is still in this trade room.

6. exits the trade room

until counter is 1000.

I will test it tonight with the example you gave me. I´ll let you know how it went, and will post the complete script if it still fails.

Edited by XchokeholdX

Share this post


Link to post
Share on other sites

I know, so a While pixelsearch(xxxx) (while we are in the "in" trade screen, simply would do the trick?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

ok, let me try it again from the start, I might not have been clear enough, sorry for that:

That's ok. It happens all the time when people ask questions in these forums. :whistle:

Anyway, you should realize that once you have set up this kind of scheme for your script. That you should probably start building functions first. Example:

Scheme:

1. bot login

2. goes to trade lobby

repeat 1000 times:

3. waits for trade request

4. goes to trade room

5. waits for other player trades cards <--- here i need it to check every few seconds or so if it is still in this trade room.

6. exits the trade room

Functions:

Func Login()
    ;stuff here that logs in
EndFunc

Func GotoTradeLobby()
    ; stuff that takes you to the lobby
EndFunc

Func CheckTradeRequest()
    ;pixelsearch or pixelchecksum
EndFunc

Func CheckIfInTradeRoom()
    ;etc
EndFuncoÝ÷ ØÚ0¢wÊ¡j÷º)m¶¬yû§rب̨¹ªÞ÷Ghæ§uƧë-¦ëmé¢Ú2¢êìr¸©µ«­¢+Ù1½¥¸ ¤)½Ñ½QÉ1½ä ¤)½ÈÀÌØíàôÄQ¼ÄÀÀÀ(%
¡­QÉIÅÕÍÐ ¤Q¡¸(½Ñ½QÉI½½´ ¤(%
¡­%%¹QÉI½½´ ¤ÑÑÉÑÑɸ¸¸(¹%(M±À ÈÔÀ¤)9á
Edited by Manadar

Share this post


Link to post
Share on other sites

I have tried several things now, and I don't know what do do anymore, it just wont check for errors when in the "in"trade screen.

I had it once, but then it just continued inside the reboot() func..

what am I doing wrong? how to add a failsave when in trade?

; 
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
$botcounter = 0;

call("login")
Do
waitfortradeinvite() 
spamintrade();;;;;;;
acceptbuttonintradecheck()
sleep(200)
accepttradeintrade()
sleep(200)
acceptbuttonintradefinalcheck()
accepttradeintradefinal()
sleep(5000)
thankyouusing()
reboot()
sleep(100)

$botcounter = +1
Until $botcounter = 1000

While 1 ; pauze menu
    Sleep(100)
WEnd

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func login()
MouseClick ( "left" , 1235, 17 , 1)
WinWaitActive("Star Chamber LaunchPad EULA", "", 30)
Sleep(7000)
MouseClick ( "left" , 600, 650 , 1) ;click accept EULA
MouseClick ( "left" , 635, 486 , 2) ;click login name
send("commonpoolbot")
MouseClick ( "left" , 630, 530 , 1) ;click password
Send("starchamber1")
MouseClick ( "left" , 664, 583 , 1) ;click ok
WinWaitActive("Star Chamber LaunchPad", "", 30)
sleep(200); Wait for patcher to finish
$checksum = PixelChecksum(407,421, 410,423) ;wait for patcher to finish.
While $checksum = PixelChecksum(407,421, 410,423)
  Sleep(500)
WEnd
sleep(1000)
MouseClick ( "left" , 422, 426 , 1); click play!!!
sleep(10000)
MouseClick ( "left" , 923, 743 , 1); click ok incoming cards
MouseClick ( "left" , 355, 616 , 1); go to trade mezz
Sleep(1000)
call("spam")
EndFunc


Func spam()
MouseClick ("left" , 580, 960 , 1)
;Send("the CommonPool bot is now active, please feel free to trade with me") ;  this is the welcome and spam message for the bot
Send("the commonpool bot is now ready for trading. please, DO NOT EXIT the intrade screen before the bot does, you will crash the bot if you do!!!!")
;send("the commonpool bot is now being repaired, please do NOT initiate any trade requests, thank you.")
Send("{ENTER}")
Send("{ENTER}") 
EndFunc

Func waitfortradeinvite()
MouseClick ( "left" , 149, 485 , 1); make active window
$checksum = PixelChecksum(745,458, 750,460)
While $checksum = PixelChecksum(745,458, 750,460)
    sleep(500)
WEnd
sleep(200)
MouseClick ("left", 730, 550 , 1); accept trade
sleep(8000) 
EndFunc

Func spamintrade()
MouseClick ( "left" , 580, 960 , 1)
Send("Welcom. please do not leave this trade screen BEFORE the bot does. Also, you have 5 seconds to press the Accept button in the confirmation window before the bot boots you.")
Send("{ENTER}")

EndFunc

func accepttradeintrade()
MouseClick ( "left" , 406, 942 , 1); accept
EndFunc

func accepttradeintradefinal()
MouseClick ( "left" , 849, 716 , 1)
sleep(500)
EndFunc

func acceptbuttonintradecheck()
    $checksum = PixelChecksum(411,501, 411,501); checks the accept button for color change
; Wait for player to finsih trading
While $checksum = PixelChecksum(411,501, 411,501)
        Sleep(5000)
WEnd
EndFunc

func acceptbuttonintradefinalcheck()
    $checksum = PixelChecksum(570,709, 571,710);wait for accept trade screen
While $checksum = PixelChecksum(570,709, 571,710)
      Sleep(500)
WEnd
EndFunc

func thankyouusing()
MouseClick ("left" , 580, 960 , 1)
Send("Thank you for using the commonspoolbot.") ;  this is the end message
Send("{ENTER}") 
EndFunc
    
Func reboot()
    MouseClick("left", 1258, 114, 1);click home
    MouseClick("left", 733, 548, 1);are you sure? yes
    sleep(3000)
    MouseClick ( "left" , 923, 743 , 1); click ok incoming cards
    sleep(3000)
    MouseClick ( "left" , 923, 743 , 1); click ok incoming cards
    MouseClick ("left" , 355, 616 , 1); go to trade mezz
    sleep(200)
    EndFunc

func checkintrade()
    PixelSearch(96, 720, 96, 720, 16777215)
    if @error then $fail = 0
        EndFunc

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