;'God - Mute Player'

TargetID = GetUserFlag(#USERID, 45)

If GetUserAccess(#USERID) < 5
	SetUserSkill(#USERID,162,0)
	GoTo END
EndIf

MSG=GetUserMessage(#USERID)

If GetUserAccess(TargetID) > GetUserAccess(#USERID)
	SendMessageToUser(#USERID,"Cannot mute "+GetUserName(TargetID)+".",#MSG_EMOTE)
	SendMessageToUser(TargetID,GetUserName(#USERID)+" has tried to mute you.",#MSG_EMOTE)
	GoTo END
EndIf

If Lower(MSG)="unmute"
	SetUserMuteTime(TargetID,0)
	SendMessageToUser(#USERID,GetUserName(TargetID)+" has been unmuted.",#MSG_EMOTE)
ElseIf Lower(MSG)="time"
	If GetUserMuteTimeLeft(TargetID) > 0
		SendMessageToUser(#USERID,GetUserName(TargetID)+" has "+GetUserMuteTimeLeft(TargetID)+" minutes of muted text left.",#MSG_EMOTE)
	Else
		SendMessageToUser(#USERID,GetUserName(TargetID)+" is not muted.",#MSG_EMOTE)
	Endif
ElseIf Lower(MSG)="all"
	If GetUserAccess(#USERID) = 10
		SendMessageToUser(#USERID,"Every player online, who is below Access Level 4, has been muted.",#MSG_EMOTE)
		;Mute all players for #PARAM2 minutes
		SendMessageToAll(GetUserName(#USERID)+": A global mute has been imposed for 5 minutes",#MSG_SERVER)
		Timer(506,100,0,5,0)
		Timer(642,5*60000,#USERID,TargetID,0)
	Else
		SendMessageToUser(#USERID,"You cannot mute everyone",#MSG_EMOTE)
	EndIf
ElseIf Lower(MSG)="all 15"
	If GetUserAccess(#USERID) = 10
		SendMessageToUser(#USERID,"Every player online, who is below Access Level 4, has been muted.",#MSG_EMOTE)
		;Mute all players for #PARAM2 minutes
		SendMessageToAll(GetUserName(#USERID)+": A global mute has been imposed for 15 minutes",#MSG_SERVER)
		Timer(506,100,0,15,0)
		Timer(642,15*60000,#USERID,TargetID,0)
	Else
		SendMessageToUser(#USERID,"You cannot mute everyone",#MSG_EMOTE)
	EndIf
ElseIf Lower(MSG)="unmute all"
	If GetUserAccess(#USERID) = 10
		SendMessageToUser(#USERID,"Every player has been unmuted.",#MSG_EMOTE)
		;Unmute all players
		SendMessageToAll(GetUserName(#USERID)+": Global muting has been lifted",#MSG_SERVER)
		Timer(506,100,0,0,0)
	Else
		SendMessageToUser(#USERID,"You cannot unmute everyone",#MSG_EMOTE)
	EndIf
Else
	Timer(642,MSG*60000,#USERID,TargetID,0)
	SetUserMuteTime(TargetID,MSG)
	If GetUserMuteTimeLeft(TargetID) > 0
		;SendMessageToUser(#USERID,GetUserName(TargetID)+" has been muted for "+MSG+" minutes.",#MSG_EMOTE)
		SendMessageToAll("*"+GetUserName(#USERID)+": "+GetUserName(TargetID)+" has been muted for "+MSG+" minutes.",#MSG_SERVER)
	Else
		SendMessageToUser(#USERID,GetUserName(TargetID)+" is no longer muted.",#MSG_EMOTE)
	Endif
EndIf

Label END

Continue = 1