Auto AFK Kick Script - Minecraft

Ask gaming related questions (AHK v1.1 and older)
Superman785
Posts: 2
Joined: 20 Jun 2018, 05:50

Auto AFK Kick Script - Minecraft

20 Jun 2018, 05:58

Hello,
I was just wondering how I'd make a Minecraft Script that will run the command "/tempban [My username] 1s Reason: AFK" if my Minecraft Character hasn't moved in 10 minutes.

Kind regards,
Connor.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Auto AFK Kick Script - Minecraft

20 Jun 2018, 08:01

Added missing close paren

Code: Select all

#NoEnv
#SingleInstance Force
#Persistent
#InstallKeybdHook
#InstallMouseHook
SetBatchLines -1
SendMode Input

minecraft := "ahk_exe notepad.exe"
message := "/tempban [My username] 1s Reason: AFK"
MAX_MINUTES_AFK := 10
TIMER_PERIOD_MS := 2000

SetTimer, MonitorMinecraft, % TIMER_PERIOD_MS
Return

MonitorMinecraft:
	timeIdle := (A_TimeIdlePhysical // 1000) / 60 ;in mins
	if (timeIdle > MAX_MINUTES_AFK && (WinActive(minecraft) || WinExist(minecraft)))
	{
		WinActivate
		WinWaitActive
		Send {Enter}
		Send % "{Text}" message
		Send {Enter}
		SetTimer, , Off
		SetTimer, MonitorForActivity, % TIMER_PERIOD_MS / 10
	}
Return


MonitorForActivity:
	if (A_TimeIdlePhysical < 200)
	{
		SetTimer, , Off
		SetTimer, MonitorMinecraft, % TIMER_PERIOD_MS
	}
Return
Superman785
Posts: 2
Joined: 20 Jun 2018, 05:50

Re: Auto AFK Kick Script - Minecraft

21 Jun 2018, 02:40

Hello, I was just wondering how I fix this issue.

http://i67.tinypic.com/6omuk6.png

Kind regards,
Connor.
Tdawgdestroyer
Posts: 1
Joined: 27 Jan 2021, 08:34

Re: Auto AFK Kick Script - Minecraft

27 Jan 2021, 08:44

I don’t know what your problem is but when someone runs /afk to afk it should set a variable to true then:
Every 10 minutes:
If {%player%.afk} is true:
Execute console command “tempban %player% 1s AFK

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], hiahkforum, phalanxdarken and 116 guests