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

SendMessageToUser(#USERID,"This feature is disabled due to incompleteness - Comrade",#MSG_SERVER)
GoTo END

;SendMessageToUser(#USERID,"This is a work in progress - Comrade",#MSG_SERVER)
;GoTo END

;Let users choose the amount to wager

;If a user is found on a tile, it can't see the player under him

;Let users choose to participate, by typing 'battle' or something



WAGER_AMOUNT = 50000


If #YPOS <> 3
	GoTo END
EndIf

User1 = GetUserAtXY(3,3,3)
User2 = GetUserAtXY(3,5,3)

If GetUserFlag(#USERID,10) > 0
	SendMessageToUser(#USERID,"An event is already running, wait until it's finished.",#MSG_SAY)
	GoTo END
EndIf

If Lower(GetUserMessage(#USERID))="yes"
	If GetUserGuild(#USERID) = 0
		SendMessageToUser(#USERID,"Only guild lords can start a guild battle.",#MSG_SAY)
		GoTo END
	EndIf
		
	If GetUserGuildRank(User1) <> #GUILDRANK_LORD
		GoTo NO_LORDS
	ElseIf GetUserGuildRank(User2) <> #GUILDRANK_LORD
		GoTo NO_LORDS
	EndIf
	
	If User1 = 0
		GoTo NO_LORDS
	ElseIf User2 = 0
		GoTo NO_LORDS
	EndIf
	
	If GetUserGuild(User1) = GetUserGuild(User2)
		GoTo NO_LORDS
	EndIf
	
	GoTo TWO_LORDS
	Label NO_LORDS
	
	SendMessageToUser(#USERID,"You need two guild lords on these squares: one from each guild that is to battle.",#MSG_SAY)
	
	GoTo END
	Label TWO_LORDS
	
	COST = Floor(WAGER_AMOUNT/1000)
	
	SendMessageToUser(User1,"Do you wish to battle "+GetGuildName(GetUserGuild(User2))+"? The cost to your guild is "+COST+"k silver.",#MSG_SAY)
	SendMessageToUser(User2,"Do you wish to battle "+GetGuildName(GetUserGuild(User1))+"? The cost to your guild is "+COST+"k silver.",#MSG_SAY)
	Timer(338,10000,User1,User2,WAGER_AMOUNT)
	GoTo END
Else
	COST = Floor(WAGER_AMOUNT/1000)
	SendMessageToUser(#USERID,"Do you wish to start a guild battle? It will cost both guilds "+COST+"k silver.",#MSG_SAY)
EndIf

Label END

Continue = 1