;'Event Token Guy'

TokenItem = 759
Tokens = 0

While HasItem(#USERID,TokenItem) = 1
	TakeItem(#USERID,TokenItem)
	Tokens = Tokens + 1
Wend

MSG=GetUserMessage(#USERID)

If MSG="1"
	TokenCost = 2
	ItemGiven = 320
	Goto TRADE
ElseIf MSG="2"
	TokenCost = 2
	ItemGiven = 479
	Goto TRADE
ElseIf MSG="3"
	TokenCost = 3
	ItemGiven = 530
	Goto TRADE
ElseIf MSG="4"
	TokenCost = 4
	ItemGiven = 301
	Goto TRADE
ElseIf MSG="5"
	TokenCost = 4
	ItemGiven = 14
	Goto TRADE
ElseIf MSG="6"
	TokenCost = 5
	ItemGiven = 534
	Goto TRADE
ElseIf MSG="7"
	TokenCost = 5
	ItemGiven = 454
	Goto TRADE
ElseIf MSG="8"
	TokenCost = 5
	ItemGiven = 398
	Goto TRADE
ElseIf MSG="token"
	SendMessageToUser(#USERID, "Event Token Guy says, 'Hmm, alright. Lets set the price at a mere... 5 million silver! Heh, still want to [buy] one?'",#MSG_SAY)
ElseIf MSG="buy"
	If GetUserSilver(#USERID) > 5000000
		SendMessageToUser(#USERID, "Event Token Guy says, 'What, are you serious?! I was just joking! No way I'm selling you an event token, "+GetUserName(#USERID)+".'",#MSG_SAY)
	Else
		SendMessageToUser(#USERID, "Event Token Guy says, 'You don't have enough silver!",#MSG_SAY)
	EndIf
ElseIf MSG="trade"
	SendMessageToUser(#USERID,"Tokens: "+Tokens,#MSG_TELL)
	SendMessageToUser(#USERID,"1) '"+GetItemName(320)+"'  ("+2+" tokens)",#MSG_EMOTE)
	SendMessageToUser(#USERID,"2) '"+GetItemName(479)+"'  ("+2+" tokens)",#MSG_EMOTE)
	SendMessageToUser(#USERID,"3) '"+GetItemName(530)+"'  ("+3+" tokens)",#MSG_EMOTE)
	SendMessageToUser(#USERID,"4) '"+GetItemName(301)+"'  ("+4+" tokens)",#MSG_EMOTE)
	SendMessageToUser(#USERID,"5) '"+GetItemName(14)+"'  ("+4+" tokens)",#MSG_EMOTE)
	SendMessageToUser(#USERID,"6) '"+GetItemName(534)+"'  ("+5+" tokens)",#MSG_EMOTE)
	SendMessageToUser(#USERID,"7) '"+GetItemName(454)+"'  ("+5+" tokens)",#MSG_EMOTE)
	SendMessageToUser(#USERID,"8) '"+GetItemName(398)+"'  ("+5+" tokens)",#MSG_EMOTE)
	
	SendMessageToUser(#USERID,"To buy a item, say the number of the item.",#MSG_EMOTE)
Else
	SendMessageToUser(#USERID,"Event Token Guy says, 'Why hello there, "+GetUserName(#USERID)+". I trade sweet items for any Event Tokens you might've won. Type 'trade' to see my items for trade, or type 'token' to buy a token.'",#MSG_SAY)
EndIf

Goto DONE
Label TRADE

If Tokens > TokenCost-1
	If IsInvFull(#USERID) = 0
		Tokens = Tokens - TokenCost
		GiveItem(#USERID,ItemGiven)
		SendMessageToUser(#USERID,"You traded "+TokenCost+" tokens for a "+GetItemName(ItemGiven)+".",#MSG_TELL)
	Else
		SendMessageToUser(#USERID,"Your inventory is full! Please get rid of a item before trying again.",#MSG_CRITICAL)
	EndIf
Else
	SendMessageToUser(#USERID,"Event Token Guy says, 'This item requires "+TokenCost+" tokens to be aquired.'",#MSG_SAY)
EndIf

Goto DONE
Label DONE
While Tokens > 0
	GiveItem(#USERID,TokenItem)
	Tokens = Tokens - 1
Wend

Continue = 1