Jump to content

I Need Help with a Basic Pixel Script


Andaho
 Share

Recommended Posts

Hello, I'm really new to all this programming stuff and am trying to make a really basic script for a game...

It waits for the on screen cursor to turn red (target in cursor) and then shoots. It doesn't work very well, can anyone help me with this basic script to make it work properly?

WinWaitActive("Game")

While WinActive("Game")

While PixelGetColor(555, 432) <> 13107200

Sleep(1)

WEnd

Send("p")

WEnd

Thanks, Andaho.

Link to comment
Share on other sites

It only seems to randomly work... sometimes I'll hover over a target and it will shoot right away, sometimes I'll hover a target and it will shoot after a second or 2... sometimes it just doesn't shoot at all. I thought at first that maybe the colour of the pixel changes different shades of red, but when it wasn't firing I took a screenshot and checked the colour and it was the shade I originally found. I just don't understand why it doesn't work properly... is there a better way of doing code for this job?

Link to comment
Share on other sites

Also, I'm a little confused as to how I got the loop working... I was expecting to use some kind of 'goto line' command to make it loop, but when I discovered there is no goto command I read about the While commandand didn't understand it but made the code this way anyway... I don't understand why the script never ends, with the game open, or when you close it, the script keeps running... I was expecting from the code I wrote, that it would end when you minimize the game, from the window not being active anymore.

Link to comment
Share on other sites

WinWaitActive("Game")

While 1
    If WinActive("Game") Then
        While PixelGetColor(555, 432) <> 13107200
            Sleep(1)
        WEnd
        Send("p")
    EndIf
WEnd

For pixel shade use PixelSearch with the same Left/Right Top/Bottom positions (only for your one pixel)

You may also use some Hotkeys for activate/deactivate your script see HotkeySet()

Edited by Zedna
Link to comment
Share on other sites

WinWaitActive("Game")

While 1
    If WinActive("Game") Then
        While PixelGetColor(555, 432) <> 13107200
            Sleep(1);This isnt much of a delay
        WEnd
        Send("p")
    EndIf
WEnd

Sleep(1) may be whats causing the lag on your system when its checking the color. Bump it up to (250) or (500) and you should see some performance improvements.

Link to comment
Share on other sites

Thanks for another reply, I will try increasing the pause after I fix this problem... this keeps coming up with While and Wend errors and I can't work out why!

CODE
WinWaitActive("Game")

While 1

If WinActive("Game") Then

PixelSearch( 555, 432, 555, 432, 0xC80000, 1000 )

If Not @error Then

Sleep(1)

WEnd

Send("p")

EndIf

WEnd

Edited by Andaho
Link to comment
Share on other sites

Sleep(1) may be whats causing the lag on your system when its checking the color. Bump it up to (250) or (500) and you should see some performance improvements.

Yes:

WinWaitActive("Game")

While 1
    If WinActive("Game") Then
        While PixelGetColor(555, 432) <> 13107200
            Sleep(100)
        WEnd
        Send("p")
    EndIf
    Sleep(100)
WEnd
Edited by Zedna
Link to comment
Share on other sites

ok, it still behaves the same apart from it never fires super fast anymore - it still sometimes never fires, or takes ages before it fires. and I gave up on the pixel search command cause I kept comming up with errors with end commands

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...