What am I doing wrong on this script?

Ask gaming related questions (AHK v1.1 and older)
xxKeixx
Posts: 4
Joined: 15 Mar 2018, 14:12

What am I doing wrong on this script?

15 Mar 2018, 14:16

Numpad1 & Numpad.::
if(Please==0)
{
SetTimer, Time, On, 5000
Please=0;
}
else
{
SetTimer, Time, Off, 0
Please=1;
}
return

Time:
if(Dialog== 0)
{
SendInput t/me Test 1. {enter}
Dialog=1;
}
if else(Dialog== 1)
{
SendInput t/me Test 2. {enter}
Dialog=2;
}
if else(Dialog== 3)
{
SendInput t/me Test 3. {enter}
Dialog=4;
}
else
{
SendInput t/me Test 1. {enter}
Dialog=0;
}
return
gregster
Posts: 9003
Joined: 30 Sep 2013, 06:48

Re: What am I doing wrong on this script?

15 Mar 2018, 14:48

First of all, the ;s don't belong there. That is not AHK syntax. Remove them.

Also, I assume you want a toggle - the problem is that if the variable 'please' is already 0 (or empty), it will always be set to 0 - if it is not zero, it will stay not zero (or 1 in this case). That is obviously not a toggle.
gregster
Posts: 9003
Joined: 30 Sep 2013, 06:48

Re: What am I doing wrong on this script?

15 Mar 2018, 14:54

Instead of Numpad. , you probably meant NumpadDot

See https://autohotkey.com/docs/KeyList.htm#Numpad_keys
gregster
Posts: 9003
Joined: 30 Sep 2013, 06:48

Re: What am I doing wrong on this script?

15 Mar 2018, 14:58

The SetTimer syntax is also different than you assume, is my guess: You probably want SetTimer, Time, 5000 (calls the label Time every 5 seconds) and SetTimer, Time, Off. See https://autohotkey.com/docs/commands/SetTimer.htm

I recommend the tutorial (https://autohotkey.com/docs/Tutorial.htm) and a closer look at the docs in general.
xxKeixx
Posts: 4
Joined: 15 Mar 2018, 14:12

Re: What am I doing wrong on this script?

15 Mar 2018, 15:47

Do you have discord or teamspeak good sir, You might want to help me. I'm really new but I'm capable of learning quickly.
xxKeixx
Posts: 4
Joined: 15 Mar 2018, 14:12

Re: What am I doing wrong on this script?

15 Mar 2018, 15:51

Code: Select all

Numpad1 & NumpadDot::
if(Please==0)
{
SetTimer, Time, 5000
Please=0
}
else
{
SetTimer, Time, Off
Please=1
}
return

Time:
if(Dialog== 0)
{
SendInput t/me Test 1. {enter}
Dialog=1
}
if else(Dialog== 1)
{
SendInput t/me Test 2. {enter}
Dialog=2
}
if else(Dialog== 3)
{
SendInput t/me Test 3. {enter}
Dialog=4
}
else
{
SendInput t/me Test 1. {enter}
Dialog=0
}
return
Is this okey now?
User avatar
Renz
Posts: 20
Joined: 05 Sep 2015, 21:56
Location: Dortmund (NRW|GER)
Contact:

Re: What am I doing wrong on this script?

15 Mar 2018, 16:53

You have to Switch the Please Values then it will work :)

Code: Select all

Numpad1 & NumpadDot::
if(Please==0) ; Please is equal 0, See Down!!
{
	SetTimer, Time, 5000
	Please=1 ; You have to set Please then on 1, cause you turn it "On"
}
else ; Please is equal 1 
{
	SetTimer, Time, Off
	Please=0 ; You have to set Please then on 0, cause you turn it "OFF"
}
return
Now you can toggle it...

or try this...

i written this a few years ago for SAMP... it should help you, i tested it not, should it fail anything will i fix it if u want it...
With the SC_FormatString() Function u can split Long strings in small Max. 122 Signs Parts to providing Crashes cause "too Long string Output"...

Code: Select all

Numpad1 & NumpadDot::
if Please := !Please
	SetTimer, Time, 5000
else
	SetTimer, Time, Off
return

Time:
SC_FormatString("me",FS_STRING)
return

SC_FormatString(_ChatType,FS_STRING)
{
	static MaxChatSize := 122
	if(Strlen(FS_STRING) > MaxChatSize)
	{
		While(Strlen(FS_STRING)>0)
		{
			FS_COUNT := 0
			FS_COUNTBACK := 0
			Loop
			{
				FS_COUNT ?	FS_COUNTBACK := "-" FS_COUNT : ""
				if(SubStr(FS_STRING,FS_COUNTBACK,1) == " " || SubStr(FS_STRING,FS_COUNTBACK,1) == "," || SubStr(FS_STRING,FS_COUNTBACK,1) == "."){
					break 1
				}
				FS_COUNT++
			}
			SendChat(_ChatType,SubStr(FS_STRING, 1 , MaxChatSize-(FS_COUNT)) "...")
			StringTrimLeft, FS_STRING, FS_STRING, MaxChatSize-(FS_COUNT)
			sleep 1100
		}
	}else{
		SendChat(_ChatType,FS_STRING) 
	}
	return
}
SendChat(_Type:="",_Text:="")
{
	if(!_Text){
		Sendinput % "          {Enter}" 
		return 
	}
	Sendinput % "t" strlen(_Type) ? "/" _Type " " _Text "{Enter}" : _Text "{Enter}"
	return		
}
xxKeixx
Posts: 4
Joined: 15 Mar 2018, 14:12

Re: What am I doing wrong on this script?

16 Mar 2018, 04:25

Code: Select all

Numpad1 & NumpadDot::
if Please := !Please
	SetTimer, Time, 5000
else
	SetTimer, Time, Off
return

Time:
SC_FormatString("me",FS_STRING)
return

SC_FormatString(_ChatType,FS_STRING)
{
	static MaxChatSize := 122
	if(Strlen(FS_STRING) > MaxChatSize)
	{
		While(Strlen(FS_STRING)>0)
		{
			FS_COUNT := 0
			FS_COUNTBACK := 0
			Loop
			{
				FS_COUNT ?	FS_COUNTBACK := "-" FS_COUNT : ""
				if(SubStr(FS_STRING,FS_COUNTBACK,1) == " " || SubStr(FS_STRING,FS_COUNTBACK,1) == "," || SubStr(FS_STRING,FS_COUNTBACK,1) == "."){
					break 1
				}
				FS_COUNT++
			}
			SendChat(_ChatType,SubStr(FS_STRING, 1 , MaxChatSize-(FS_COUNT)) "...")
			StringTrimLeft, FS_STRING, FS_STRING, MaxChatSize-(FS_COUNT)
			sleep 1100
		}
	}else{
		SendChat(_ChatType,FS_STRING) 
	}
	return
}
SendChat(_Type:="",_Text:="")
{
	if(!_Text){
		Sendinput % "          {Enter}" 
		return 
	}
	Sendinput % "t" strlen(_Type) ? "/" _Type " " _Text "{Enter}" : _Text "{Enter}"
	return		
}
This is just spamming empty space =/ like pressing enter
Guest

Re: What am I doing wrong on this script?

16 Mar 2018, 05:12

I got it working, someone please tell me how to get this side working with 4 different choices.

Code: Select all

Time:
if(Dialog== 0)
{
SendInput t/me Test 1. {enter}
Dialog=1;
}
if else(Dialog== 1)
{
SendInput t/me Test 2. {enter}
Dialog=2;
}
if else(Dialog== 3)
{
SendInput t/me Test 3. {enter}
Dialog=4;
}
else
{
SendInput t/me Test 1. {enter}
Dialog=0;
}
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: What am I doing wrong on this script?

16 Mar 2018, 11:52

Guest wrote:I got it working, someone please tell me how to get this side working with 4 different choices.

Code: Select all

Time:
if(Dialog== 0)
{
SendInput t/me Test 1. {enter}
Dialog=1;
}
if else(Dialog== 1)
{
SendInput t/me Test 2. {enter}
Dialog=2;
}
if else(Dialog== 3)
{
SendInput t/me Test 3. {enter}
Dialog=4;
}
else
{
SendInput t/me Test 1. {enter}
Dialog=0;
}
The mistake you did was that you wrote 'if else' instead of else if. I also suggest you use SendMode Input if you are going to use sendinput throughout anyway.
Also complimentary question to y'all. What is the difference between Dialog == 0 andDialog = 0? They're the same? Also you don't need to end lines with a colon.

The script below will ty

Code: Select all

SendMode Input
Time:
if (Dialog = 0) {
Send, t/me Test 1. {enter}
Dialog := 1
}
else if (Dialog = 1) {
Send, t/me Test 2. {enter}
Dialog=2
}
else if (Dialog = 3) {
Send, t/me Test 3. {enter}
Dialog=4
}
else
{
Send, t/me Test 4. {enter}
Dialog=0
}
return
I am your average ahk newbie. Just.. a tat more cute. ;)

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: jameswrightesq and 18 guests