;Anti-afktrainer script, because players complain. Only temp, until
;mod hiatus is done, and moderators are more common ingame.

User=#PARAM1
UserLocation=#PARAM2
Experience=#PARAM3
AFKing=#PARAM4
StayCount=#PARAM5

If IsOnline(User) = 0
	;SendMessageToUser(GetUserID("comrade"),"User logout: "+GetUserName(user),#MSG_SERVER)
	Goto END
EndIf

;SendMessageToUser(GetUserID("comrade"),GetUserName(User)+": "+AFKing+"-"+StayCount+"-["+UserLocation+"]",#MSG_SAY)
;SendMessageToUser(GetUserID("comrade"),"Tick",#MSG_EMOTE)

StandingStill = 0

;PLAYER LOCATION

If GetUserHP(User) > Floor(GetUserMaxHP(User) * 2)
	If GetUserAccess(User) < 5
		SendMessageToUser(GetUserID("comrade"),"*"+GetUserName(User)+": "+GetUserHP(User)+"/"+GetUserMaxHP(User),#MSG_CRITICAL)
	EndIf
EndIf

If GetUserStrengthBonus(User) > 10
	If GetUserAccess(User) < 5
		SendMessageToUser(GetUserID("comrade"),"*"+GetUserName(User)+"'s strength bonus: "+GetUserStrengthBonus(User),#MSG_CRITICAL)
	EndIf
EndIf
If GetUserEnduranceBonus(User) > 10
	If GetUserAccess(User) < 5
		SendMessageToUser(GetUserID("comrade"),"*"+GetUserName(User)+"'s endurance bonus: "+GetUserEnduranceBonus(User),#MSG_CRITICAL)
	EndIf
EndIf
If GetUserWisdomBonus(User) > 10
	If GetUserAccess(User) < 5
		SendMessageToUser(GetUserID("comrade"),"*"+GetUserName(User)+"'s wisdom bonus: "+GetUserWisdomBonus(User),#MSG_CRITICAL)
	EndIf
EndIf
If GetUserAgilityBonus(User) > 10
	If GetUserAccess(User) < 5
		SendMessageToUser(GetUserID("comrade"),"*"+GetUserName(User)+"'s agility bonus: "+GetUserAgilityBonus(User),#MSG_CRITICAL)
	EndIf
EndIf

StopIndex = FindString(UserLocation,"_",0)
Length = StopIndex-1

UserMap=SubString(UserLocation,0,Length)

StartIndex = StopIndex+1
StopIndex = FindString(UserLocation,"_",StartIndex)
Length = StopIndex-StartIndex

UserX=SubString(UserLocation,StartIndex,Length)

StartIndex = StopIndex+1
StopIndex = Len(UserLocation)+1
Length = StopIndex-StartIndex

UserY=SubString(UserLocation,StartIndex,Length)

If UserMap = GetUserMap(User)
	If UserX = GetUserX(User)
		If UserY = GetUserY(User)
			StandingStill = 1
		EndIf
	EndIf
EndIf

;PLAYER EXP

StopIndex = FindString(Experience,"_",0)
StrengthExp=SubString(Experience,0,StopIndex-1)

StartIndex = FindString(Experience,"_",StopIndex)
StopIndex = FindString(Experience,"_",StartIndex+1)
StartIndex = StartIndex+1
Length = StopIndex-StartIndex

EnduranceExp=SubString(Experience,StartIndex,Length)

StartIndex = FindString(Experience,"_",StopIndex)
StopIndex = FindString(Experience,"_",StartIndex+1)
StartIndex = StartIndex+1
Length = StopIndex-StartIndex

WisdomExp=SubString(Experience,StartIndex,Length)

StartIndex = FindString(Experience,"_",StopIndex)
StopIndex = Len(Experience)
StartIndex = StartIndex+1
Length = StopIndex-StartIndex

AgilityExp=SubString(Experience,StartIndex,Length+1)

If StrengthExp <> GetUserStrengthExp(User)
	If StandingStill = 1
		AFKing=AFKing+1
		;SendMessageToUser(GetUserID("comrade"),"Exp Increase",#MSG_EMOTE)
	EndIf
ElseIf EnduranceExp <> GetUserEnduranceExp(User)
	If StandingStill = 1
		AFKing=AFKing+1
		;SendMessageToUser(GetUserID("comrade"),"Exp Increase",#MSG_EMOTE)
	EndIf
ElseIf WisdomExp <> GetUserWisdomExp(User)
	If StandingStill = 1
		AFKing=AFKing+1
		;SendMessageToUser(GetUserID("comrade"),"Exp Increase",#MSG_EMOTE)
	EndIf
ElseIf AgilityExp <> GetUserAgilityExp(User)
	If StandingStill = 1
		AFKing=AFKing+1
		;SendMessageToUser(GetUserID("comrade"),"Exp Increase",#MSG_EMOTE)
	EndIf
EndIf

;Check stand-still count.
If StandingStill = 1
	;SendMessageToUser(GetUserID("comrade"),"Standing Still",#MSG_EMOTE)
Else
	StayCount=0
	AFKing=0
EndIf
If AFKing > 0
	StayCount=StayCount+1
	If StayCount > 3
		;If AFKing = 3
		If AFKing = 2
			SendMessageToUser(User,"If you can read this, please change your location.",#MSG_SERVER)
		ElseIf AFKing > 3
			;SendMessageToUser(GetUserID("comrade"),"AFK Training",#MSG_EMOTE)
			;UserDamageUser(GetUserID("regulus"),Random(1111,5555),User)
			WarpUser(User,9,10,10)
			StayCount=0
			AFKing=0
		EndIf
	EndIf
EndIf

;GoTo END

UserLocation=""+GetUserMap(User)+"_"+GetUserX(User)+"_"+GetUserY(User)
Experience=""+GetUserStrengthExp(User)+"_"+GetUserEnduranceExp(User)+"_"+GetUserWisdomExp(User)+"_"+GetUserAgilityExp(User)

Timer5(670,60000,User,UserLocation,Experience,AFKing,StayCount)

Label END

Continue = 1