Sign in to follow this  
Followers 0
acez

lag

19 posts in this topic

Hey, Im new to this forums and scripting, my friend gave me a script that searches for a specific color in a game, and when the program is running it laggs the game, anyway to prevent the lag?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

We can help more if you show us the script.

EDIT: Volly, you're too fast.

Edit Edit:

Lol, this is cool

Edited by D-Generation X

Share this post


Link to post
Share on other sites

#Include <Misc.au3>

HotKeySet("!{ESC}", "Terminate")

$Color = "0xEB00A7"; pink this is just for testing....it will only target cts with the mdls i made

$Colo1 = "0xB1007E";

$Colo2 = "0xAD007B"

$Colo3 = "0x65004A"

$left = 460

$top = 380

$right = 540

$bottem = 430

$dll = DllOpen("user32.dll")

While 1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;hotkeys________________________

_________________

if _IsPressed("39",$dll) Then ; 9

$Color = "0xD60000";

SoundPlay(@MyDocumentsDir & "\t.wav",0)

sleep(500)

Else

if _IsPressed("30",$dll) Then; 0

$Color = "0xD60000"

SoundPlay(@MyDocumentsDir & "\ct.wav",0)

sleep(500)

Else

If _IsPressed("26",$dll) Then;up

$left = 460

$top = 380

$right = 540

$bottem = 430

Else

If _IsPressed("28",$dll) Then;down

$left = 490

$top = 380

$right = 510

$bottem = 430

Else

if WinActive("Counter-Strike") Then

If _IsPressed("01", $dll) Then

$Pos = PixelSearch($left,$top,$right,$bottem, $Color, 10,2)

If IsArray($Pos) Then

MouseMove($Pos[0],$Pos[1],0)

Else

$Pos = PixelSearch($left,$top,$right,$bottem, $Colo1, 10,2)

if IsArray($Pos) Then

MouseMove($Pos[0],$Pos[1],0)

Else

$Pos = PixelSearch($left,$top,$right,$bottem, $Colo2, 10,2)

if IsArray($Pos) Then

MouseMove($Pos[0],$Pos[1],0)

Else

$Pos = PixelSearch($left,$top,$right,$bottem, $Colo3, 10,2)

if IsArray($Pos) Then

MouseMove($Pos[0],$Pos[1],0)

Else

EndIf

EndIf

EndIf

EndIf

EndIf

EndIf

EndIf

EndIf

EndIf

EndIf

WEnd

Func Terminate()

Exit 0

EndFunc

DllClose($dll)

Share this post


Link to post
Share on other sites

Hmm, I experienced something similar when creating a bot for Diablo 2. The lag remains constant as the While-WEnd loop is looping (that's what i believe anyway). Not sure how to fix it, perhaps slowing down the loop (add sleep(x)) so it does not lag as much since it wouldn't need to do as much work.

Hopefully that helped,

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Its for Counter Strike, and can you tell me where do i put the sleep(x) at or what ever you said that may fix it

Edited by acez

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I cleaned it up a bit. You will need to test to see if the CPU hunger problem is fixed. I suspect it isn't. The winactive may be the cause. You may need to setup a sub loop to fix it.

#Include <Misc.au3>
HotKeySet("!{ESC}", "Terminate")

$Color = "0xEB00A7"; pink this is just for testing....it will only target cts with the mdls i made
$Colo1 = "0xB1007E";
$Colo2 = "0xAD007B"
$Colo3 = "0x65004A"


$left = 460
$top = 380
$right = 540
$bottem = 430
$dll = DllOpen("user32.dll")

While 1
    Select
        case _IsPressed("39",$dll)
            $Color = "0xD60000";
            SoundPlay(@MyDocumentsDir & "\t.wav",0)
            sleep(500)
        case _IsPressed("30",$dll)
            $Color = "0xD60000"
            SoundPlay(@MyDocumentsDir & "\ct.wav",0)
            sleep(500)
        case _IsPressed("26",$dll)
            $left = 460
            $top = 380
            $right = 540
            $bottem = 430
        case  _IsPressed("28",$dll) 
            $left = 490
            $top = 380
            $right = 510
            $bottem = 430
    EndSelect

    if WinActive("Counter-Strike") Then
        If _IsPressed("01", $dll) Then
            $Pos = PixelSearch($left,$top,$right,$bottem, $Color, 10,2)
        EndIf
    endif   
    If IsArray($Pos) Then
        MouseMove($Pos[0],$Pos[1],0)
    Else
        $Pos = PixelSearch($left,$top,$right,$bottem, $Colo1, 10,2)
    endif   
    if IsArray($Pos) Then
        MouseMove($Pos[0],$Pos[1],0)
    Else
        $Pos = PixelSearch($left,$top,$right,$bottem, $Colo2, 10,2)
    endif   
    if IsArray($Pos) Then
        MouseMove($Pos[0],$Pos[1],0)
    Else
        $Pos = PixelSearch($left,$top,$right,$bottem, $Colo3, 10,2)
    endif   
    if IsArray($Pos) Then
        MouseMove($Pos[0],$Pos[1],0)
    Else
    EndIf
WEnd

Func Terminate()


Exit 0
EndFunc
DllClose($dll)
Edited by Volly

Share this post


Link to post
Share on other sites

I cleaned it up a bit

#Include <Misc.au3>
HotKeySet("!{ESC}", "Terminate")

$Color = "0xEB00A7"; pink this is just for testing....it will only target cts with the mdls i made
$Colo1 = "0xB1007E";
$Colo2 = "0xAD007B"
$Colo3 = "0x65004A"
$left = 460
$top = 380
$right = 540
$bottem = 430
$dll = DllOpen("user32.dll")

While 1
    Select
        case _IsPressed("39",$dll)
            $Color = "0xD60000";
            SoundPlay(@MyDocumentsDir & "\t.wav",0)
            sleep(500)
        case _IsPressed("30",$dll)
            $Color = "0xD60000"
            SoundPlay(@MyDocumentsDir & "\ct.wav",0)
            sleep(500)
        case _IsPressed("26",$dll)
            $left = 460
            $top = 380
            $right = 540
            $bottem = 430
        case  _IsPressed("28",$dll) 
            $left = 490
            $top = 380
            $right = 510
            $bottem = 430
    EndSelect

    if WinActive("Counter-Strike") Then
        If _IsPressed("01", $dll) Then
            $Pos = PixelSearch($left,$top,$right,$bottem, $Color, 10,2)
        EndIf
    endif   
    If IsArray($Pos) Then
        MouseMove($Pos[0],$Pos[1],0)
    Else
        $Pos = PixelSearch($left,$top,$right,$bottem, $Colo1, 10,2)
    endif   
    if IsArray($Pos) Then
        MouseMove($Pos[0],$Pos[1],0)
    Else
        $Pos = PixelSearch($left,$top,$right,$bottem, $Colo2, 10,2)
    endif   
    if IsArray($Pos) Then
        MouseMove($Pos[0],$Pos[1],0)
    Else
        $Pos = PixelSearch($left,$top,$right,$bottem, $Colo3, 10,2)
    endif   
    if IsArray($Pos) Then
        MouseMove($Pos[0],$Pos[1],0)
    Else
    EndIf
WEnd

Func Terminate()
Exit 0
EndFunc
DllClose($dll)
This script gives me this error:

If IsArray($Pos) Then

If IsArray(^ ERROR

Share this post


Link to post
Share on other sites

it mostly laggs me when i press mouse1(left click on the mouse)

any help?

Share this post


Link to post
Share on other sites

Wouldnt using If Not @Error Then... Be faster than having those IsArray()'s?


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

what do you mean declare? im new to scripting

Share this post


Link to post
Share on other sites

i gave him this code...i was going to poist a question but never had time...

this program runs perfict on my labtop but when i run it on my desktop my fps drops to like 10

Lagg like crazzy

#Include <Misc.au3>
HotKeySet("!{ESC}", "Terminate")

$Color = "0xEB00A7"; pink this is just for testing....it will only target cts with the mdls i made
$Colo1 = "0xB1007E";
$Colo2 = "0xAD007B"
$Colo3 = "0x65004A"
$Colo4 = "0x7B0056"
$Colo5 = "0xE300A2"
$colo6 = "0x3C0029"
$colo7 = "0x36002F"
$Colo8 = "0xC300BB"
$colo9 = "0x53006C"
$key = "01"
$left = 460
$top = 375
$right = 540
$bottem = 430
$dll = DllOpen("user32.dll")
While 1
    if _IsPressed("39",$dll) Then ; 9
        $Color = "0xEB00A7"; pink this is just for testing....it will only target cts with the mdls i made
        $Colo1 = "0xB1007E";
        $Colo2 = "0xAD007B"
        $Colo3 = "0x65004A"
        $Colo4 = "0x7B0056"
        $Colo5 = "0xE300A2"
        $colo6 = "0x1B001B"
        $colo7 = "0x36002F"
        $Colo8 = "0xC300BB"
        $colo9 = "0x53006C"
        SoundPlay(@MyDocumentsDir & "\t.wav",0)
        sleep(500)
    Else
        if _IsPressed("30",$dll) Then; 0
            $Color = "0x00CC87";teal this is just for testing....it will only target cts with the mdls i made
            $Colo1 = "0x007D53";
            $Colo2 = "0x001F22"
            $Colo3 = "0x001B1C"
            $Colo4 = "0x00B377"
            $Colo5 = "0x009F69"
            $colo6 = "0x00A6A6"
            $colo7 = "0x006D67"
            $Colo8 = "0x00A6A6"
            $colo9 = "0x009F69"
            SoundPlay(@MyDocumentsDir & "\ct.wav",0)
            sleep(500)
        Else
            If _IsPressed("26",$dll) Then;up
                $left = 460
                $top = 375
                $right = 540
                $bottem = 430
                $key = "01"
            Else
                If _IsPressed("28",$dll) Then;down
                    $left = 490
                    $top = 370
                    $right = 510
                    $bottem = 430
                    $key = "10"
                Else
                    
                    if WinActive("Counter-Strike") Then
                        If _IsPressed($key, $dll) Then

                            $Pos = PixelSearch($left,$top,$right,$bottem, $Color, 10,2)
                            If IsArray($Pos) Then
                                MouseMove($Pos[0],$Pos[1],0)
                                
                                
                            Else
                                $Pos = PixelSearch($left,$top,$right,$bottem, $Colo1, 10,2)
                                if IsArray($Pos) Then
                                    MouseMove($Pos[0],$Pos[1],0)
                                    

                                Else
                                    $Pos = PixelSearch($left,$top,$right,$bottem, $Colo2, 10,2)
                                    if IsArray($Pos) Then
                                        MouseMove($Pos[0],$Pos[1],0)
                                        

                                    Else
                                        $Pos = PixelSearch($left,$top,$right,$bottem, $Colo3, 10,2)
                                        if IsArray($Pos) Then
                                            MouseMove($Pos[0],$Pos[1],0)
                                            

                                        Else
                                            $Pos = PixelSearch($left,$top,$right,$bottem, $Colo4, 10,2)
                                            if IsArray($Pos) Then
                                                MouseMove($Pos[0],$Pos[1],0)
                                                

                                            Else
                                                $Pos = PixelSearch($left,$top,$right,$bottem, $Colo5, 10,2)
                                                if IsArray($Pos) Then
                                                    MouseMove($Pos[0],$Pos[1],0)
                                                    

                                                Else
                                                    $Pos = PixelSearch($left,$top,$right,$bottem, $Colo6, 10,2)
                                                    if IsArray($Pos) Then
                                                        MouseMove($Pos[0],$Pos[1],0)
                                                        

                                                    Else
                                                        $Pos = PixelSearch($left,$top,$right,$bottem, $Colo7, 10,2)
                                                        if IsArray($Pos) Then
                                                            MouseMove($Pos[0],$Pos[1],0)
                                                            
                                                        Else
                                                            $Pos = PixelSearch($left,$top,$right,$bottem, $Colo8, 10,2)
                                                            if IsArray($Pos) Then
                                                                MouseMove($Pos[0],$Pos[1],0)
                                                                
                                                            Else
                                                                $Pos = PixelSearch($left,$top,$right,$bottem, $Colo9, 10,2)
                                                                if IsArray($Pos) Then
                                                                    MouseMove($Pos[0],$Pos[1],0)
                                                                    


                                                                EndIf
                                                            EndIf
                                                        EndIf
                                                    EndIf
                                                EndIf
                                            EndIf
                                        EndIf
                                    EndIf
                                EndIf
                            EndIf
                        EndIf
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf



WEnd

Func Terminate()
    DllClose($dll)
    ;ProcessSetPriority("autoit3.exe",2)
    ;ProcessSetPriority("steam.exe",2)
    ;ProcessSetPriority("hl.exe",2)
    

    Exit 0
EndFunc

Share this post


Link to post
Share on other sites

Just a tidbit, you should learn the language before you go asking about the code. As several have said, we are not your scripting slaves.

Share this post


Link to post
Share on other sites

We are not your scripting slaves.

Well personnally I don't mind fixing problems or doing small tasks. I dislike the requests for large projects.


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

i built this script on my labtop... it runs Like a dream and when i turn around and run it on my desktop...

it laggs like crazy...fps drops like carazzy

this is realy driving me crazzy

Share this post


Link to post
Share on other sites

I really have no idea. Perhaps adding a small sleep inside the While-WEnd loop. So, at the END of your While loop (before Wend) add: Sleep(100) so it sleeps 100 milliseconds so maybe the computer won't need to work so hard.

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

i found that the first time i run the program, it runs perfict...

thin after i press alt-esc (terminate) thin when i run the program agn my fps is at 20...

could this be DllClose($dll) not taking effect or something...?

i tryd adding sleep all threw the script.. doesnt help

i lowerd the FOV (feald of view) it help a little...

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