;The New 'Cyber Says' event script
;This is the script where we check the players' answers.

Map=#PARAM1
Tier=#PARAM2
Phrase=#PARAM3

;Eliminate users who got the phrase wrong.
user=GetNextMapUser(0, 548)
While user <> 0
	If GetUserMessage(user)<>Phrase
		SendMessageToUser(user,"Cyber says, 'Wrong. It appears that you lose this time.'",#MSG_SAY)
		SendMessageToUser(user,"Cyber smiles a humorless smile, and warps you out of his presence.",#MSG_EMOTE)
		WarpUser(user, 509, 10, 11)
		SendMessageToMap(548,"*"+GetUserName(user)+" failed, and has been removed.",#MSG_CRITICAL)
	EndIf
	
	user=GetNextMapUser(user, 548)
Wend

;Check if everyone failed.
If GetMapPlayerCount(548) = 0
	SendMessageToAll("Cyber says, 'Everyone has failed. Entirely. It's quite pitiful really.'",#MSG_TELL)
	GoTo END
ElseIf GetMapPlayerCount(548) = 1
	user = GetNextMapUser(0, 548)
	SendMessageToAll("Cyber says, '"+GetUserName(user)+" is the only person left. As such, he wins the event.'",#MSG_TELL)
	SendMessageToUser(user,"25,000 silver has been added to your purse.",#MSG_TELL)
	SetUserSilver(user, GetUserSilver(user)+25000)
	;SendMessageToUser(user,"An Event Token has been added to your inventory.",#MSG_TELL)
	;GiveItem(user,759)
	WarpUser(user, 509, 10, 11)
	GoTo END
EndIf

;Check if it's the final Tier
If Tier = 15
	SendMessageToAll("Cyber says, 'Quite impressive. I applaud you, gentlemen. I'm out of phrases to say.'",#MSG_TELL)
	
	user=GetNextMapUser(0, 548)
	While user <> 0
		SendMessageToAll(GetUserName(user)+" has defeated Cyber Says.",#MSG_SERVER)
		;SendMessageToUser(user,"Two Event Tokens have been added to your inventory.",#MSG_TELL)
		;GiveItem(user,759)
		;GiveItem(user,759)
		SendMessageToUser(user,"50,000 silver has been added to your purse.",#MSG_TELL)
		SetUserSilver(user, GetUserSilver(user)+50000)
		WarpUser(user, 509, 10, 11)
		
		user=GetNextMapUser(user, 548)
	Wend
	
	GoTo END
EndIf

SendMessageToMap(548,"[Players Left: "+GetMapPlayerCount(548)+"] [Tier: "+Tier+"]", #MSG_SERVER)
Timer(739, 2500, Map, Tier, 1)

GoTo SKIP
Label END
SendMessageToAll("The Cyber Says event is now over.",#MSG_SERVER)
Label SKIP

Continue = 1