;Bank storage script (new one)

BANK_MAXIMUM = GetUserFlag(#USERID, 46)

If BANK_MAXIMUM < 25000 
	SetUserFlag(#USERID, 46, 25000)
	BANK_MAXIMUM = 25000
EndIf

NONE = 0
ACTION_DEPOSIT = 1
ACTION_DEPOSIT2 = 2
ACTION_WITHDRAW = 3
ACTION_WITHDRAW2 = 4
ACTION_BALANCE = 5
ACTION_INCREASE = 6

Action = NONE

UserBalance = GetUserFlag(#USERID, 47)
UserSilver = GetUserSilver(#USERID)


UserText=Lower(GetUserMessage(#USERID))

If UserText="withdraw"
	Action = ACTION_WITHDRAW
ElseIf UserText="withdrawmore"
	Action = ACTION_WITHDRAW2
ElseIf UserText="withdraw more"
	Action = ACTION_WITHDRAW2
ElseIf UserText="deposit"
	Action = ACTION_DEPOSIT 
ElseIf UserText="depositmore"
	Action = ACTION_DEPOSIT2
ElseIf UserText="deposit more"
	Action = ACTION_DEPOSIT2
ElseIf UserText="balance"
	Action = ACTION_BALANCE 
ElseIf UserText="check"
	Action = ACTION_BALANCE 
ElseIf UserText="upgrade"
	Action = ACTION_INCREASE 
ElseIf UserText="increase"
	Action = ACTION_INCREASE
Else
	Action = NONE
EndIf

If Action = ACTION_WITHDRAW 
	If UserBalance < 2500
		SendMessageToUser(#USERID,"Account Balance: "+GetUserFlag(#USERID, 47),#MSG_CRITICAL)
	Else 
		UserBalance = UserBalance - 2500
		SetUserFlag(#USERID, 47, UserBalance)
		
		SetUserSilver(#USERID, UserSilver + 2500)
		SendMessageToUser(#USERID,"You have removed a sum of 2,500 silver from your account.",#MSG_TELL)
	EndIf
ElseIf Action = ACTION_WITHDRAW2 
	If UserBalance < 10000
		SendMessageToUser(#USERID,"Account Balance: "+GetUserFlag(#USERID, 47),#MSG_CRITICAL)
	Else 
		UserBalance = UserBalance - 10000
		SetUserFlag(#USERID, 47, UserBalance)
		
		SetUserSilver(#USERID, UserSilver + 10000)
		SendMessageToUser(#USERID,"You have removed a sum of 10,000 silver from your account.",#MSG_TELL)
	EndIf
ElseIf Action = ACTION_DEPOSIT 
	If BANK_MAXIMUM-1 < UserBalance
		SendMessageToUser(#USERID,"You have reached the maximum capacity of your account, upgrades to your account may be purchased by typing 'upgrade' and paying a sum of five thousand silver.",#MSG_EMOTE)
	ElseIf UserSilver < 2500
		SendMessageToUser(#USERID,"You don't have 2500 silver to deposit.",#MSG_CRITICAL)
	Else 
		UserBalance = UserBalance + 2500
		SetUserFlag(#USERID, 47, UserBalance)
		
		SetUserSilver(#USERID, UserSilver - 2500)
		SendMessageToUser(#USERID,"You have deposited a sum of 2,500 silver into your account.",#MSG_TELL)
	EndIf
ElseIf Action = ACTION_DEPOSIT2
	If BANK_MAXIMUM-1 < UserBalance
		SendMessageToUser(#USERID,"You have reached the maximum capacity of your account, upgrades to your account may be purchased by typing 'upgrade' and paying a sum of five thousand silver.",#MSG_EMOTE)
	ElseIf UserSilver < 10000
		SendMessageToUser(#USERID,"You don't have 10000 silver to deposit.",#MSG_CRITICAL)
	Else 
		UserBalance = UserBalance + 10000
		SetUserFlag(#USERID, 47, UserBalance)
		
		SetUserSilver(#USERID, UserSilver - 10000)
		SendMessageToUser(#USERID,"You have deposited a sum of 10,000 silver into your account.",#MSG_TELL)
	EndIf
ElseIf Action = ACTION_BALANCE 
	SendMessageToUser(#USERID,"Your account has a balance of "+GetUserFlag(#USERID, 47)+" silver.",#MSG_TELL)
ElseIf Action = ACTION_INCREASE
	If GetUserFlag(#USERID, 46) > 50000
		If GetUserFlag(#USERID, 46) = 75000
			SendMessageToUser(#USERID,"You cannot upgrade your account any further.",#MSG_CRITICAL)
		ElseIf UserSilver < 10000
			SendMessageToUser(#USERID,"You don't have the money to upgrade your account.",#MSG_CRITICAL)
		Else 
			UserSilver = UserSilver - 10000
			SetUserSilver(#USERID,UserSilver)
			SetUserFlag(#USERID, 46, GetUserFlag(#USERID,46)+5000)
			SendMessageToUser(#USERID,"Your account now has a maximum balance of "+GetUserFlag(#USERID, 46)+" silver.",#MSG_TELL)
		EndIf
	ElseIf UserSilver < 5000
		SendMessageToUser(#USERID,"You don't have the money to upgrade your account.",#MSG_CRITICAL)
	Else 
		UserSilver = UserSilver - 5000
		SetUserSilver(#USERID,UserSilver)
		SetUserFlag(#USERID, 46, GetUserFlag(#USERID,46)+5000)
		SendMessageToUser(#USERID,"Your account now has a maximum balance of "+GetUserFlag(#USERID, 46)+" silver.",#MSG_TELL)
		If GetUserFlag(#USERID, 46) = 50000
			SendMessageToUser(#USERID,"Account increases will now cost 10000 silver per 5000 upgrade.",#MSG_CRITICAL)
		EndIf
	EndIf
Else
	SendMessageToUser(#USERID,"To deposit silver, type 'deposit' or 'deposit more', to withdraw silver, simply type 'withdraw' or 'withdraw more'.",#MSG_EMOTE)
	SendMessageToUser(#USERID,"If you want to see the balance of your account, type 'balance'. Your current capacity is "+BANK_MAXIMUM+" silver.",#MSG_EMOTE)
EndIf

Label END

Continue = 1