;'Kings' Arena Guild War Gm Event' - Event running

Guild1Players = 0

Y=6
While Y < 19
	X=2
	While X < 19
		UserID = GetUserAtXY(997,X,Y)
		If UserID > 0
			If GetUserGuild(UserID) = #PARAM2
				Guild1Players = Guild1Players + 1
			EndIf
		EndIf
		X=X+1
	Wend
	Y=Y+1
Wend

Guild2Players = 0

Y=6
While Y < 19
	X=2
	While X < 19
		UserID = GetUserAtXY(997,X,Y)
		If UserID > 0
			If GetUserGuild(UserID) = #PARAM3
				Guild2Players = Guild2Players + 1
			EndIf
		EndIf
		X=X+1
	Wend
	Y=Y+1
Wend

If Guild1Players = 0
	If Guild2Players = 0
		SendMessageToAll("The guilds clashed, but neither emerged the victor.",#MSG_SERVER)
		SetUserFlag(0,10,0)
		SetUserFlag(0,11,0)
		GoTo WARPUSERS
	EndIf
	
	SendMessageToAll(GetGuildName(#PARAM3)+" has slaughtered "+GetGuildName(#PARAM2)+" and emerges the greater of the two.",#MSG_SERVER)
	SetGuildSilver(#PARAM3,GetGuildSilver(#PARAM3)+GetUserFlag(0,11))
	SetUserFlag(0,10,0)
	SetUserFlag(0,11,0)
	GoTo WARPUSERS
EndIf

If Guild2Players = 0
	If Guild1Players = 0
		SendMessageToAll("The guilds clashed, but neither emerged the victor.",#MSG_SERVER)
		SetUserFlag(0,10,0)
		SetUserFlag(0,11,0)
		GoTo WARPUSERS
	EndIf
	
	SendMessageToAll(GetGuildName(#PARAM2)+" has slaughtered "+GetGuildName(#PARAM3)+" and emerges the greater of the two.",#MSG_SERVER)
	SetGuildSilver(#PARAM2,GetGuildSilver(#PARAM2)+GetUserFlag(0,11))
	SetUserFlag(0,10,0)
	SetUserFlag(0,11,0)
	GoTo WARPUSERS
EndIf

Timer(336,15000,#PARAM1,#PARAM2,#PARAM3)

GoTo END
Label WARPUSERS

Y=6
While Y < 19
	X=2
	While X < 19
		UserID = GetUserAtXY(997,X,Y)
		If UserID > 0
			WarpUser(UserID,9,10,10)
		EndIf
		X=X+1
	Wend
	Y=Y+1
Wend

Label END

Continue = 1