;'Pawn Shop' - Seller NPC

SendMessageToUser(#USERID,"The Shop Buyer says, 'Under work.'",#MSG_SAY)
GoTo END

ITEM = GetItemAtXY(354,6,9)

If ITEM = 0
	SendMessageToUser(#USERID,"Pawn Shop Seller, 'I have nothing to sell. Why don't you sell something to my brother?'",#MSG_SAY)
	GoTo CYCLE
EndIf

If Lower(GetUserMessage(#USERID))="buy"
	If GetUserSilver(#USERID) < GetItemValue(ITEM)
		SendMessageToUser(#USERID,"You don't have enough silver.",#MSG_CRITICAL)
		GoTo END
	Else
		If IsInvFull(#USERID) = 1
			SendMessageToUser(#USERID,"Your inventory is full.",#MSG_CRITICAL)
			GoTo END
		Else
			SetUserSilver(#USERID,GetUserSilver(#USERID)-GetItemValue(ITEM))
			GiveItem(#USERID,ITEM)
			RemoveItem(354,ITEM)
			SendMessageToUser(#USERID,"Your purse contains "+GetUserSilver(#USERID)+" silver pieces.",#MSG_TELL)
			GoTo CYCLE
		EndIf
	EndIf
ElseIf Lower(GetUserMessage(#USERID))="no"
	SendMessageToUser(#USERID,"Pawn Shop Seller, 'Sorry that I cannot interest you in it, why not check back later?'",#MSG_SAY)
Else
	SendMessageToUser(#USERID,"Pawn Shop Seller, 'You can [buy] this "+GetItemName(ITEM)+" for "+GetItemValue(ITEM)+" silver.'",#MSG_SAY)
EndIf

GoTo END
Label CYCLE

i = 9

While i < 15
	i=i+1
	ITEM = GetItemAtXY(354,6,i)
	If ITEM > 0
		RemoveItemAtXY(354,6,i)
		SpawnItem(354,ITEM,6,i-1)	
	EndIf
Wend

Label END

Continue = 1