;'God - Command' - timed script

UserID=#PARAM1
Command=#PARAM2
RawParam1=#PARAM3
RawParam2=#PARAM4
RawParam3=#PARAM5

Command=Lower(Command)
Param1=Lower(RawParam1)
Param2=Lower(RawParam2)
Param3=Lower(RawParam3)

;SendMessageToUser(UserID,"Command: "+Command+" -"+Param1+" -"+Param2+" -"+Param3,#MSG_SAY)
;GoTo END

AccessLevel = GetUserAccess(UserID)

;If GetUserName(UserID)="Mystix"
;	AccessLevel = 2
;EndIf

MAX_SKILLS = 200

If AccessLevel < 1
	SendMessageToAll(GetUserName(UserID)+" has unauthorized access to the 'God - Command' skill.",#MSG_CRITICAL)
	GoTo END
EndIf

If Command="help"
	SendMessageToUser(UserID,"Command list:",#MSG_SAY)
	SendMessageToUser(UserID,"- ServerMessage message #msgtype",#MSG_SAY)
	SendMessageToUser(UserID,"- SendMessage username message #msgtype",#MSG_SAY)
	SendMessageToUser(UserID,"- Talk message #msgtype",#MSG_SAY)
	SendMessageToUser(UserID,"- Kick username",#MSG_SAY)
	SendMessageToUser(UserID,"- Mute username minutes",#MSG_SAY)
	SendMessageToUser(UserID,"- Unmute username",#MSG_SAY)
	SendMessageToUser(UserID,"- Ban username hours",#MSG_SAY)
	SendMessageToUser(UserID,"- IPban username hours",#MSG_SAY)
	SendMessageToUser(UserID,"- Unban username",#MSG_SAY)
	SendMessageToUser(UserID,"- UnequipItems username",#MSG_SAY)
	SendMessageToUser(UserID,"- ChangeName oldname newname",#MSG_SAY)
	SendMessageToUser(UserID,"- ResetBonuses username",#MSG_SAY)
	SendMessageToUser(UserID,"- ViewSkills username",#MSG_SAY)
ElseIf Command="servermessage"
	If AccessLevel < 10
		GoTo LOWACCESS
	EndIf
	
	If Param2="0"
		Param2=#MSG_SERVER
	EndIf
	SendMessageToAll("Server Message: "+Param1, Param2)
ElseIf Command="sendmessage"
	If AccessLevel < 10
		GoTo LOWACCESS
	EndIf
	
	If Param1="all"
		If Param3="0"
			Param3=#MSG_BROADCAST
		EndIf
		SendMessageToAll(Param2,Param3)
	ElseIf Param1="map"
		If Param3="0"
			Param3=#MSG_SAY
		EndIf
		SendMessageToMap(GetUserMap(UserID),Param2,Param3)
	Else
		If Param3="0"
			Param3=#MSG_TELL
		EndIf
		TargetID = GetUserID(Param1)
		If TargetID > 0
			If IsOnline(TargetID) = 1
				SendMessageToUser(TargetID,GetUserName(UserID)+": "+Param2,Param3)
				SendMessageToUser(UserID,"Message sent to "+GetUserName(TargetID)+": "+Param2,#MSG_SERVER)
			Else
				SendMessageToUser(UserID,GetUserName(TargetID)+" is not online.",#MSG_SERVER)
			EndIf
		Else
			SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
		EndIf
	EndIf
ElseIf Command="talk"
	If Param2="0"
		Param2=#MSG_SERVER
	EndIf
	SendMessageToAll(GetUserName(UserID)+": "+Param1,Param2)
ElseIf Command="kick"
	TargetID = GetUserID(Param1)
	If TargetID > 0
		If IsOnline(TargetID) = 1
			KickUser(TargetID,"Kicked by "+GetUserName(UserID))
		Else
			SendMessageToUser(UserID,GetUserName(TargetID)+" is not online.",#MSG_SERVER)
		EndIf
	Else
		SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
	EndIf
ElseIf Command="mute"
	If Param1="all"
		If Param2="0"
			Param2 = 15
		EndIf
		
		SendMessageToAll("A global mute has been imposed. It will last for "+Param2+" minutes.",#MSG_SERVER)
		
		id=GetNextOnlineUser(0)
		While id <> 0
			If GetUserAccess(id) < 1
				If UserID<>id
					SetUserMuteTime(id,Param2)
				EndIf
			EndIf
			id=GetNextOnlineUser(id)
		Wend
	Else
		TargetID = GetUserID(Param1)
		If TargetID > 0
			If Param2="0"
				Param2 = 5
			EndIf
			
			SetUserMuteTime(TargetID,Param2)
			
			If IsOnline(TargetID) = 1
				SendMessageToAll(GetUserName(TargetID)+" has been muted for "+Param2+" minute(s).",#MSG_SERVER)
			EndIf
		Else
			SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
		EndIf
	EndIf
ElseIf Command="unmute"
	If Param1="all"
		SendMessageToAll("The global mute has been repealed. Behave yourselves.",#MSG_SERVER)
		
		id=GetNextOnlineUser(0)
		While id <> 0
			If GetUserAccess(id) < 1
				SetUserMuteTime(id,0)
			EndIf
			id=GetNextOnlineUser(id)
		Wend
	Else
		TargetID = GetUserID(Param1)
		If TargetID > 0
			SendMessageToUser(TargetID,"You have been unmuted",#MSG_SERVER)
			SendMessageToUser(UserID,GetUserName(TargetID)+" has been unmuted.",#MSG_SERVER)
			SetUserMuteTime(TargetID,0)
		Else
			SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
		EndIf
	EndIf
ElseIf Command="ban"
	If AccessLevel < 10
		GoTo LOWACCESS
	EndIf
	
	TargetID = GetUserID(Param1)
	If TargetID > 0
		If Param2="0"
			Param2 = 24
		EndIf
		SendMessageToAll(GetUserName(TargetID)+" has been banned for "+Param2+" hour(s).",#MSG_SERVER)
		BanUser(GetUserName(TargetID),Param2)
		If IsOnline(TargetID) = 1
			Timer5(523,100,UserID,"kick",GetUserName(TargetID),0,0)
		EndIf
	Else
		SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
	EndIf
ElseIf Command="ipban"
	If AccessLevel < 10
		GoTo LOWACCESS
	EndIf
	
	TargetID = GetUserID(Param1)
	If TargetID > 0
		If Param2="0"
			Param2 = 24
		EndIf
		SendMessageToAll(GetUserName(TargetID)+" has been banned for "+Param2+" hour(s).",#MSG_SERVER)
		BanUser(GetUserIP(TargetID),Param2)
		BanUser(GetUserName(TargetID),Param2)
		If IsOnline(TargetID) = 1
			Timer5(523,100,UserID,"kick",GetUserName(TargetID),0,0)
		EndIf
	Else
		SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
	EndIf
ElseIf Command="unban"
	If AccessLevel < 10
		GoTo LOWACCESS
	EndIf
	
	TargetID = GetUserID(Param1)
	If TargetID > 0
		SendMessageToUser(UserID,GetUserName(TargetID)+" has been unbanned.",#MSG_SERVER)
		UnBanUser(GetUserName(TargetID))
		UnBanUser(GetUserIP(TargetID))
	Else
		SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
	EndIf
ElseIf Command="unequipitems"
	If AccessLevel < 10
		GoTo LOWACCESS
	EndIf
	
	TargetID = GetUserID(Param1)
	If TargetID > 0
		UnequipWeapon(TargetID)
		UnequipArmor(TargetID)
		UnequipBoots(TargetID)
		UnequipHelmet(TargetID)
		UnequipAccessory(TargetID)
		SendMessageToUser(UserID,GetUserName(TargetID)+"'s items have been unequipped.",#MSG_SERVER)
	Else
		SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
	EndIf
ElseIf Command="changename"
	If AccessLevel < 10
		GoTo LOWACCESS
	EndIf
	
	TargetID = GetUserID(Param1)
	If TargetID > 0
		FoundID=GetUserID(Param2)
		FoundName="no name found"
		If FoundID > 0
			FoundName=Lower(GetUserName(FoundID))
		EndIf
		
		If Param2<>FoundName
			SendMessageToUser(TargetID,"Your name has been changed. Log out and then log in with your new name (using your old password).",#MSG_SERVER)
			SendMessageToUser(UserID,GetUserName(TargetID)+"'s name has been changed.",#MSG_SERVER)
			SetUserName(TargetID,RawParam2)
			SetUserDisplayName(TargetID,RawParam2)
		Else
			SendMessageToUser(UserID,"There is already a player with the name '"+FoundName+"'",#MSG_SERVER)
		EndIf
	Else
		SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
	EndIf
ElseIf Command="resetbonuses"
	If AccessLevel < 10
		GoTo LOWACCESS
	EndIf
	
	TargetID = GetUserID(Param1)
	If TargetID > 0
		Timer5(523,100,UserID,"unequipitems",Param1,0,0)
		SetUserStrengthBonus(TargetID, 0)
		SetUserEnduranceBonus(TargetID, 0)
		SetUserWisdomBonus(TargetID, 0)
		SetUserAgilityBonus(TargetID, 0)
		SendMessageToUser(TargetID,"Your bonus stats have been reset.",#MSG_SERVER)
		SendMessageToUser(UserID,GetUserName(TargetID)+"'s bonus stats have been reset.",#MSG_SERVER)
	Else
		SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
	EndIf
ElseIf Command="viewskills"
	If AccessLevel < 10
		GoTo LOWACCESS
	EndIf
	
	TargetID = GetUserID(Param1)
	If TargetID > 0
		SendMessageToUser(UserID,GetUserName(TargetID)+" has these skills:",#MSG_TELL)
		
		skillID = 1
		While skillID < MAX_SKILLS
			If GetUserSkill(TargetID, skillID) > 0
				SendMessageToUser(UserID, skillID+") "+GetSkillName(skillID),#MSG_TELL)
			EndIf
			skillID = skillID + 1
		Wend
	Else
		SendMessageToUser(UserID,"'"+Param1+"' is not a valid player name.",#MSG_SERVER)
	EndIf
Else
	Timer5(523,100,UserID,"help",0,0,0)
EndIf

GoTo END
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Label LOWACCESS

SendMessageToUser(UserID,"You do not have authorized access to that command.",#MSG_CRITICAL)

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Label END

Continue = 1