Sign in to follow this  
Followers 0
Andaho

I Need Help with a Basic Pixel Script

11 posts in this topic

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.

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Hi, thanks for the speedy reply and edited code... it works the same with that code... what is the 1 in the "while 1" command? it's weird because sometimes it shoots like a machine gun but other times a big delay or nothing.

Share this post


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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

Share this post


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

Share this post


Link to post
Share on other sites

Ok, I have an update already, I changed the "send ("p")" to a left mouseclick and it works more often now! but still irratically, still want to know if anyone knows why it might be behaving irratically.

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