GTA SA MP

Ask gaming related questions (AHK v1.1 and older)
3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

GTA SA MP

Post by 3cvb5cvb » 03 Oct 2022, 13:21

I wonder if there is a way to make something that moves the charater for like 10-12 minutes inside the house (to make 10-12 played times) and then put the character in /sleep mode , and repeat those process after x period of time. can anyone help me out ?

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 03 Oct 2022, 14:38

i though for something like that(after messing around with keys)
press W/A/S/D for 2 seconds
then wait 30 seconds
repeat all that for x times,
press `T`
write `/sleep`
wait x time then go back to begining.

Prestoro
Posts: 16
Joined: 05 Jun 2021, 17:50

Re: GTA SA MP

Post by Prestoro » 03 Oct 2022, 15:09

Code: Select all

toggle = 0

F5:: ; replace f5 with the key you want to start it with
toggle := !toggle
while(toggle) {
 Loop 10 {
	Send {w DOWN} ; holds down w
	Sleep 2000 ; keep it held down for 2 seconds
	Send {w UP} ; lets go of w
	Sleep 30000 ; waits 30 seconds
	; copy paste and replace w for each
	}
  Send t
  Sleep 100
  Send y ; replace chat-opening keybind here
  Sleep 100
  Send {text}/sleep
  Sleep 100
  Send {Enter}
  Sleep 120000 ; waits 120 seconds
  }
}
return

Esc:: pause; press esc to pause the script

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: GTA SA MP

Post by boiler » 03 Oct 2022, 15:17

Minor thing, but you'll need a space before the ; on the last line for it to be a comment.

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 03 Oct 2022, 16:20

what a comment do ?

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 03 Oct 2022, 16:24

and after that `return` it restart the whole script ?

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 03 Oct 2022, 16:31

and also, how can i make this to do all the things in one window, like in the game only, so i can freely do something else ?

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: GTA SA MP

Post by boiler » 03 Oct 2022, 18:51

3cvb5cvb wrote: what a comment do ?
A comment does nothing. It is a comment to be read -- not an instruction for AHK to do anything.

3cvb5cvb wrote: and after that `return` it restart the whole script ?
No, the while loop is what causes it to repeat as long as the condition is true, which in this case is the variable "toggle" being true (1), not false (0). It won't reach the return until it exits the while loop. Then it will wait until the hotkey is pressed again to start it over.

3cvb5cvb wrote: and also, how can i make this to do all the things in one window, like in the game only, so i can freely do something else ?
You can see if ControlSend will work with this window instead of Send.

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 04 Oct 2022, 04:55

Code: Select all

toggle = 0

F5:: ; replace f5 with the key you want to start it with
toggle := !toggle
while(toggle) {
 Loop 10 {
	Send {w DOWN} ; holds down w
	Sleep 1500 ; keep it held down for 2 seconds
	Send {w UP} ; lets go of w
	Sleep 18000 ; waits 18 seconds
	Send {a DOWN} ; holds down a
	Sleep 1500 ; keep it held down for 2 seconds
	Send {a UP} ; lets go of a
	Sleep 18000 ; waits 18 seconds
	Send {s DOWN} ; holds down s
	Sleep 1500 ; keep it held down for 2 seconds
	Send {s UP} ; lets go of s
	Sleep 18000 ; waits 18 seconds
	Send {d DOWN} ; holds down d
	Sleep 1500 ; keep it held down for 2 seconds
	Send {d UP} ; lets go of d
	Sleep 18000 ; waits 18 seconds
	}
  Sleep 100
  Send t ; replace chat-opening keybind here
  Sleep 100
  Send {text}/sleep
  Sleep 100
  Send {Enter}w
  Sleep 3000000 ; waits 50 minutes
  Sleep 100
  Send t ; replace chat-opening keybind here
  Sleep 100
  Send {text}/sleep
  Sleep 100
  Send {Enter}w
  Sleep 1000
  }

return

Esc:: pause ; press esc to pause the script
This is te modification that i made . i need to remove one `}` at the end bc it says that it was an error or something like that.
How can i change that ControlSend ?

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: GTA SA MP

Post by boiler » 04 Oct 2022, 07:12

3cvb5cvb wrote: This is te modification that i made . i need to remove one `}` at the end bc it says that it was an error or something like that.
Yes, you would need to have matching opening and closing braces. But don't just randomly remove one. Look at how the pair creates a code block and make sure it makes logical sense for that to be part of the same loop or whatever that block is for.

3cvb5cvb wrote: How can i change that ControlSend ?
First use the Window Spy tool that comes with AHK and see what it shows in the top section for your game's window. Then see the documentation for ControlSend and change your Send statements to ControlSend. It should look something like this:

Code: Select all

ControlSend,, Send {w DOWN}, ahk_exe samp.exe

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 04 Oct 2022, 08:43

That

Code: Select all

ControlSend,, Send {w DOWN}, ahk_exe samp.exe
should be where exactly ?
Also, i can't find that window spy tool

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 04 Oct 2022, 08:45

Code: Select all

toggle = 0

F5:: ; replace f5 with the key you want to start it with
toggle := !toggle
while(toggle) {
 Loop 10 {
	ControlSend,, Send {w DOWN}, ahk_exe samp.exe
	Sleep 1500 ; keep it held down for 2 seconds
	Send {w UP} ; lets go of w
	Sleep 18000 ; waits 18 seconds
	Send {a DOWN} ; holds down a
	Sleep 1500 ; keep it held down for 2 seconds
	Send {a UP} ; lets go of a
	Sleep 18000 ; waits 18 seconds
	Send {s DOWN} ; holds down s
	Sleep 1500 ; keep it held down for 2 seconds
	Send {s UP} ; lets go of s
	Sleep 18000 ; waits 18 seconds
	Send {d DOWN} ; holds down d
	Sleep 1500 ; keep it held down for 2 seconds
	Send {d UP} ; lets go of d
	Sleep 18000 ; waits 18 seconds
	}
  Sleep 100
  Send t ; replace chat-opening keybind here
  Sleep 100
  Send {text}/sleep
  Sleep 100
  Send {Enter}w
  Sleep 3000000 ; waits 50 minutes
  Sleep 100
  Send t ; replace chat-opening keybind here
  Sleep 100
  Send {text}/sleep
  Sleep 100
  Send {Enter}w
  Sleep 1000
  }

return

Esc:: pause ; press esc to pause the script
Something like this ?

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: GTA SA MP

Post by boiler » 04 Oct 2022, 08:48

3cvb5cvb wrote: That

Code: Select all

ControlSend,, Send {w DOWN}, ahk_exe samp.exe
should be where exactly ?
In place of each Send command. By the way, I made a copy/paste error. It should have been this:

Code: Select all

ControlSend,, {w DOWN}, ahk_exe samp.exe
3cvb5cvb wrote: Also, i can't find that window spy tool
In your AutoHotkey installation folder, which could be C:\Program Files\AutoHotkey.

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 04 Oct 2022, 08:50

GTA:SA:MP
ahk_class Grand theft auto San Andreas
ahk_exe gta_sa.exe
ahk_pid 1412
this is what it says and i think `ahk_exe gta_sa.exe` this one is the right

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: GTA SA MP

Post by boiler » 04 Oct 2022, 08:50

3cvb5cvb wrote: Something like this ?
Yes, but note that I accidentally included the word Send that shouldn't have been there. And you would put a ControlSend in each place you have a Send. And you need to replace samp.exe with whatever your WindowSpy tool shows after ahk_exe for your game window.

Also, not all windows respond to ControlSend, so this may or may not work, subject to testing.

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: GTA SA MP

Post by boiler » 04 Oct 2022, 08:51

3cvb5cvb wrote: this is what it says and i think `ahk_exe gta_sa.exe` this one is the right
Yes, so replace samp.exe in my example with gta_sa.exe.

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 04 Oct 2022, 08:55

Final code i think

Code: Select all

toggle = 0

F5:: ; replace f5 with the key you want to start it with
toggle := !toggle
while(toggle) {
 Loop 10 {
	ControlSend,, {w DOWN},ahk_exe gta_sa.exe ; holds down w
	Sleep 1500 ; keep it held down for 2 seconds
	ControlSend,, {w UP},ahk_exe gta_sa.exe ; lets go of w
	Sleep 18000 ; waits 18 seconds
	ControlSend,, {a DOWN},ahk_exe gta_sa.exe ; holds down a
	Sleep 1500 ; keep it held down for 2 seconds
	ControlSend,, {a UP},ahk_exe gta_sa.exe ; lets go of a
	Sleep 18000 ; waits 18 seconds
	ControlSend,, {s DOWN},ahk_exe gta_sa.exe ; holds down s
	Sleep 1500 ; keep it held down for 2 seconds
	ControlSend,, {s UP},ahk_exe gta_sa.exe ; lets go of s
	Sleep 18000 ; waits 18 seconds
	ControlSend,, {d DOWN},ahk_exe gta_sa.exe ; holds down d
	Sleep 1500 ; keep it held down for 2 seconds
	ControlSend,, {d UP},ahk_exe gta_sa.exe ; lets go of d
	Sleep 18000 ; waits 18 seconds
	}
  Sleep 100
  ControlSend,, t,ahk_exe gta_sa.exe ; replace chat-opening keybind here
  Sleep 100
  ControlSend,, {text}/sleep,ahk_exe gta_sa.exe
  Sleep 100
  ControlSend,, {Enter},ahk_exe gta_sa.exe
  Sleep 3000000 ; waits 50 minutes
  Sleep 100
  ControlSend,, t,ahk_exe gta_sa.exe ; replace chat-opening keybind here
  Sleep 100
  ControlSend,, {text}/sleep,ahk_exe gta_sa.exe
  Sleep 100
  ControlSend,, {Enter},ahk_exe gta_sa.exe
  Sleep 1000
  }

return

Esc:: pause ; press esc to pause the script
Also i had

Code: Select all

ControlSend,, {Enter}w,ahk_exe gta_sa.exe
  Sleep 1000
  }
Removed the `w` there , i think it was a mistake..

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: GTA SA MP

Post by boiler » 04 Oct 2022, 11:33

Does it do what you expect? You might also need to put the following line at the top of your script:

Code: Select all

#MaxThreadsPerHotkey 2

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 04 Oct 2022, 14:45

no , can't free up the PC like do something else.

3cvb5cvb
Posts: 16
Joined: 03 Oct 2022, 10:25

Re: GTA SA MP

Post by 3cvb5cvb » 04 Oct 2022, 14:57

Code: Select all

#MaxThreadsPerHotkey 2
should be put befor toggle ?

Post Reply

Return to “Gaming Help (v1)”