FANDOM


Created by Taz.

Using "RC_Core.rcm"
; SROV1 Dec 10 2010
; Date/Time: 4:19:23 PM on 1/8/2011
;NOT ATHURIZED TO BE USED FOR ANYTHING ELSE SCRIPT MUST STAY INTACT.

Using "RC_Core.rcm" 

Dim Item$(100) 
Dim ItemCount%(100) 
Dim ItemData$(100, 10) 
Dim Item_Health%(100) 

Function Main() 

; >> This version of the banker script is Flat File based. << 

MaxItemSlots% = 100 
For i = 0 to MaxItemSlots% 
Item$(i) = "" 
ItemCount%(i) = 0 
Next 
Player = Actor() 
Banker = ContextActor() 
PName$ = Name(Player)

ScriptLog("Banking script running by " + Pname)
NoLoan% = 0 
CurrentLoanOutstanding% = 0 
BankName$ = "Scripted Realm Online V2" 
PreviousPage$ = "Previous Page|" 
NxtPage$ = "Next Page|" 
MinLoanLvl% = 1 
InterestRate# = 2.5 
; >> LOCAL ACCOUNT for each actor in a single player account << 
; Account$ = PlayerAccountName(Player) + Name(Player) + "Bank.dat" 
; -==============================================================- 

; >> GLOBAL ACCOUNT for all actors in a single player account << 
Account$ = PlayerAccountName(Player) + "Bank.dat" 
; -==============================================================- 
Banker = ContextActor() 
D = OpenDialog(Player, Banker, BankName$, 521) 
DialogOutput(Player, D, "Greetings " + PName + " , Welcome to the bank.") 

; >> Standard message prior to reading account datafile. << 
DialogOutput(Player, D, "Please wait while I access your account.") 
; -==============================================================- 

If FileSize(Account$) = 0 Then 
; Locations in Bank account file are: 
 ; First slot is amount of money in BASE units 
; Second slot is Number of Items stored in the bank 
; Third slot is Loan Amount currently owed 
; All additional slots will be item info. 
AccountFileHandle = WriteFile(Account$) 

; >> ALWAYS WRITE THESE VALUES TO ALLOW FOR COMPATABILITY BETWEEN << 
; >> NONE ITEM AND ITEM USE. << 
; -==============================================================- 
WriteInt(AccountFileHandle, 0) ; <-- Money on deposit 
WriteInt(AccountFileHandle, 0) ; <-- Number of Items deposited 
WriteInt(AccountFileHandle, 0) ; <-- Outstanding loan amount. 
; -==============================================================- 

Else 
AccountFileHandle = ReadFile(Account$) 
AccountBalance% = ReadInt(AccountFileHandle) 
TotalStoredItems% = ReadInt(AccountFileHandle) 
CurrentLoanOutstanding% = ReadInt(AccountFileHandle) 
If CurrentLoanOutstanding% > 0 Then 
NoLoan = 1 
EndIf 
If TotalStoredItems% > 0 
For i = 1 to TotalStoredItems% 
Item$(i) = ReadLine(AccountFileHandle) 
ItemCount%(i) = ReadInt(AccountFileHandle) 
Item_Health%(i) = ReadInt(AccountFileHandle) 
ItemData$(i, 0) = ReadLine(AccountFileHandle) 
Next 
EndIf 
EndIf 
CloseFile(AccountFileHandle) 
DialogOutput(Player, D, "Account Information Obtained!") 
DialogInput(Player, D, "Continue.", "|") 
Repeat 
CloseDialog(Player, D) 
D = OpenDialog(Player, Banker, BankName$, 521) 
PlayerCash% = Money(Player) 
DialogOutput(Player, D, "What can I assist you with today?", 255, 255, 255) 
EntryResult% = DialogInput(Player, D, "Money|Items|Loan|Nothing, I changed my mind", "|") 
Select EntryResult% 

Case 1 ; MONEY OPTION 

DialogOutput(Player, D, "Would you like to Deposit or Withdraw money?", 255, 255, 255) 
ResultM%= DialogInput(Player, D, "Deposit|Withdraw|Nothing right now!", "|") 

Select ResultM% 

Case 1 ; Deposit Money 

CloseDialog(Player, D) 
D = OpenDialog(Player, Banker, BankName$, 521) 
DialogOutput(Player, D, "You have " + Money(Player) + " available for deposit?", 255, 255, 255) 
DepositAmount% = Replace(Input(Player, "Deposit Amount", "$", 2), CHR(34), "") 
myCash% = DepositAmount% 
If myCash% > PlayerCash% Then 
DialogOutput(Player, D, "I'm sorry " + PName + " but you don't have that much.", 255, 255, 255) 
EndIf 
If myCash% <= PlayerCash% Then 
SetMoney(Player, (PlayerCash% - myCash%)) 
AccountBalance% = AccountBalance% + myCash% 
DialogOutput(Player, D, "[DEPOSITAMOUNT] deposited. Your account balance is [BALANCE].", 255, 255, 255) 
SaveAcct(Account$, AccountBalance%, TotalStoredItems%, CurrentLoanOutstanding%, MaxItemSlots%) 
EndIf 
DialogInput(Player, D, "Continue.", "|") 

Case 2 ; Withdraw Money 

CloseDialog(Player, D) 
D = OpenDialog(Player, Banker, BankName$, 521) 
DialogOutput(Player, D, "How much would you like to withdraw?", 255, 255, 255) 
DialogOutput(Player, D, "Available balance = " + AccountBalance%, 255, 255, 255) 
WithdrawAmount% = Replace(Input(Player, "Withdraw Amount", "$", 2), CHR(34), "") 
myWithdraw% = WithdrawAmount% 
If myWithdraw% > AccountBalance% Then 
DialogOutput(Player, D, "I'm sorry " + PName + " but you don't have that much.", 255, 255, 255) 
EndIf 
If myWithdraw% <= AccountBalance% Then 
SetMoney(Player, (PlayerCash% + myWithdraw%)) 
AccountBalance% = AccountBalance% - myWithdraw% 
DialogOutput(Player, D, "Here is your [WITHDRAWAMOUNT], don't spend it all in one place.", 255, 255, 255) 
SaveAcct(Account$, AccountBalance%, TotalStoredItems%, CurrentLoanOutstanding%, MaxItemSlots%) 
EndIf 
DialogInput(Player, D, "Continue.", "|") 

Case 3 ; Nothing, Leave banker. 

End Select 

Case 2 ; ITEMS OPTION 

DialogOutput(Player, D, "Would you like to Deposit or Take an Item?", 255, 255, 255) 
ResultI% = DialogInput(Player, D, "Deposit|Take|Nothing right now!", "|") 

Select ResultI% 

Case 1 ; Deposit Item 

If TotalStoredItems% = MaxItemSlots% Then 
DialogOutput(Player, D, "Your Item Storage is FULL!", 255, 255, 255) 
DialogInput(Player, D, "Continue.", "|") 
Else 
Repeat 
CloseDialog(Player, D) 
D = OpenDialog(Player, Banker, BankName$, 521) 
DialogOutput(Player, D, "Type 'NONE' when finished depositing items", 255, 255, 255) 
ItemDeposit$ = Input(Player, "Deposit which item", ">", 0) 

;If player inputs portable trainer, do not allow them to store the item

If (ItemDeposit = "portable trainer")
CloseDialog(Player, D)
D = OpenDialog(Player, Banker, BankName$, 521) 
DialogOutput(Player, D,  "You can not store your portable trainer, in the bank.", 145, 234, 34)
DialogInput(Player, D, "Close")
ItemDeposit$ = ""
CloseDialog(Player, D)
Return
Endif





If HasItem(Player, ItemDeposit$, 1) = 0 And Lower(ItemDeposit$) <> "none" Then 
DialogOutput(Player, D, "You do not have a " + ItemDeposit$, 255, 255, 255) 
DoEvents(2000) 
ElseIf HasItem(Player, ItemDeposit$, 1) Then 
AvailableQty = 1 
TooDeposit = 0 
SetHealth = 0 
For i = 1 To MaxItemSlots% 
Qty = (MaxItemSlots% + 1) - i 
If HasItem(Player, ItemDeposit$, Qty) Then 
For j = 1 to 36 
If Lower(ItemName(ActorBackpack(Player, j))) = Lower(ItemDeposit$) 
; If SetHealth = 0 Or ItemHealth(ActorBackPack(Player, j)) = SetHealth 
; SetHealth = ItemHealth(ActorBackPack(Player, j)) 
AvailableQty = Qty 
i = MaxItemSlots% 
Exit 
; EndIf 
 EndIf 
 Next 
 EndIf 
 Next 
 If AvailableQty > 1 
 Repeat 
 DialogOutput(Player, D, "How many " + ItemDeposit$ + "'s do you want to deposit?", 255, 255, 255) 
 DialogOutput(Player, D, "You have [" + AvailableQty + "]", 255, 255, 255) 
 TooDeposit = Input(Player, "How many", ">", 2) 
 Until TooDeposit <= AvailableQty 
 EndIf 
 If (TooDeposit > 0 And AvailableQty > 0) Or (AvailableQty = 1 And TooDeposit = 0) 
 If TooDeposit = 0 And AvailableQty = 1 Then 
 TooDeposit = 1 
 EndIf 
 Counter = 1 
 Duplicate = 0 
 For i = 1 to MaxItemSlots% 
 If Lower(ItemDeposit$) = Lower(Item$(i)) Then 
 ; If ItemHealth(ItemDeposit$) = Item_Health%(i) 
Duplicate = i 
Exit 
; EndIf 
 EndIf 
 Next 
 If Duplicate = 0 Then 
 SortItems(TotalStoredItems%, MaxItemSlots%) 
 TotalStoredItems% = 1 
 
 While FullTrim(Item$(Counter)) <> "" 
 Counter = Counter + 1 
 TotalStoredItems% = TotalStoredItems% + 1 
 Wend 
 Item$(Counter) = ItemDeposit$ 
 ItemCount%(Counter) = TooDeposit 
 Item_Health%(Counter) = ItemHealth(ItemDeposit$) 
 Else 
 ItemCount%(Duplicate) = ItemCount%(Duplicate) + TooDeposit 
 EndIf 
 If TotalStoredItems% = 0 Then 
 TotalStoredItems% = 1 
 EndIf 
 DialogOutput(Player, D, TooDeposit + " " + ItemDeposit$ + "'s have been added to your bank!", 255, 255, 255) 
 ItemCount%(0) = ItemCount%(0) + TooDeposit 
 GiveItem(Player, ItemDeposit$, -TooDeposit) 
 SaveAcct(Account$, AccountBalance%, TotalStoredItems%, CurrentLoanOutstanding%, MaxItemSlots%) 
 EndIf 
 EndIf 
 Until Lower(ItemDeposit$) = "none" Or ItemDeposit$ = "" 
 EndIf 
 
 Case 2 ; Take Item 
 
 CurrentPage = 1 : PageSize = 5 
Repeat 
SortItems(TotalStoredItems%, MaxItemSlots%) 
InventoryString$ = "" : InputString$ = "" 
AddNext = 0 : WithdrawQty = 0 : Removeit = 0 
PageStart = ((PageSize * CurrentPage) - PageSize) + 1 
PageEd = (PageStart + PageSize) - 1 
If PageEd < TotalStoredItems% Then 
AddNxt = 1 
Else 
PageEd = TotalStoredItems% 
AddNxt = 0 
EndIf 
For i = PageStart To PageEd 
If Item$(i) <> "" Then 
InventoryString$ = InventoryString$ + Item$(i) + "|" 
EndIf 
Next 
CloseDialog(Player, D) 
D = OpenDialog(Player, Banker, BankName$, 521) 
DialogOutput(Player, D, "Click Item to Withdraw or Finished when done.", 255, 255, 255) 
testsample$ = "" 
InputString$ = InventoryString$ 
If CurrentPage > 1 Then 
InputString$ = InputString$ + PreviousPage$ 
EndIf 
If PageEd <> TotalStoredItems% Then 
InputString$ = InputString$ + NxtPage$ 
EndIf 
InputString$ = InputString$ + "Finished" 
ItemSlectd% = DialogInput(Player, D, InputString$, "|") 
WithdrawItem$ = "Processing" 
If Split(InputString$, ItemSlectd%, "|") <> "Finished" Then 
If Split(InputString$, ItemSlectd%, "|") <> Left(NxtPage$,Len(NxtPage$) - 1) Then 
If Split(InputString$, ItemSlectd%, "|") <> Left(PreviousPage$,Len(PreviousPage$) - 1) Then 
WithdrawQty = - 1 
WithdrawItem$ = Item$(((PageSize * CurrentPage) - PageSize) + ItemSlectd%) 
For i = 1 to MaxItemSlots% 
If Lower(WithdrawItem$) = Lower(Item$(i)) Then 
If ItemCount%(i) > 1 Then 
DialogOutput(Player, D, "You have [" + ItemCount%(i) + "] in your bank.", 255, 255, 255) 
Repeat 
WithdrawQty = Input(Player, "Taking " + WithdrawItem$, "Qty:",2) 
Until WithdrawQty <= ItemCount%(i) 
If WithdrawQty = ItemCount%(i) Then 
Removeit = 1 
EndIf 
EndIf 
If WithdrawQty = -1 And ItemCount%(i) = 1 Then 
WithDrawQty = ItemCount%(i) 
Removeit = 1 
EndIf 
If Removeit = 1 Then 
Item$(i) = "" 
ItemCount%(i) = 0 
TotalStoredItems% = TotalStoredItems% - 1 
Else 
ItemCount%(i) = ItemCount%(i) - WithDrawQty 
EndIf 
If WithDrawQty > 0 Then 
GiveItem(Player, WithdrawItem$, WithDrawQty) 
SaveAcct(Account$, AccountBalance%, TotalStoredItems%, CurrentLoanOutstanding%, MaxItemSlots%) 
Exit 
EndIf 
EndIf 
Next 
If i > 99 And WithdrawQty = 0 And Lower(WithdrawItem$) <> "none" Then 
DialogOutput(Player, D, "You don't have any [" + WithdrawItem$ + "] in your bank", 255, 255, 255) 
DoEvents(3000) 
EndIf 
Else 
CurrentPage = CurrentPage - 1 
EndIf 
Else 
CurrentPage = CurrentPage + 1 
EndIf 
Else 
WithdrawItem$ = "" 
EndIf 
Until Lower(WithdrawItem$) = "" 

Case 3 ; Nothing (Back to Main Menu) 

End Select 

Case 3 ; LOANS OPTION 

CloseDialog(Player, D) 
D = OpenDialog(Player, Banker, BankName$, 521) 
DialogOutput(Player, D, "Would you like to Get, Make Payment or View a Loan?", 255, 255, 255) 
ResultL% = DialogInput(Player, D, "Get Loan|Check Loan Status|Make Payment|Nothing right now", "|") 

Select ResultL% 

Case 1 ; Get Loan 

;Check to make sure Player is above the minimum level to recieve a loan 

If ActorLevel(Player) < MinLoanLvl% 
DialogOutput(Player, D, "You are not a high enough Level to recieve a loan from us! Please come see us about a loan when you have reached at least Level" + MinLoanLvl% + ".", 255, 255, 255) 
DialogInput(Player, D, "Continue.", "|") 
Else 
If CurrentLoanOutstanding% > 0 
DialogOutput(Player, D, "You already have an outstanding balance. Please pay off your current loan of " + CurrentLoanOutstanding% + " first. Then you can see us about recieving another loan." , 255, 255, 255) 
DialogInput(Player, D, "Continue.", "|") 
Else 
AmtPerLvl% = 200 
MaxLoanAmt% = ActorLevel(Player) * AmtPerLvl% 
CloseDialog(Player, D) 
D = OpenDialog(Player, Banker, BankName$, 521) 
DialogOutput(Player, D, "How much would you like to take out for a loan?", 255, 255, 255) 
DialogOutput(Player, D, "Maximum Loan = " + MaxLoanAmt%, 255, 255, 255) 
LoanAmt% = Input(Player, "Withdraw Amount", "$", 2) 
RealLoanAmt% = LoanAmt% 
If RealLoanAmt% > MaxLoanAmt% Then 
DialogOutput(Player, D, "I'm sorry, " + Name(Player) + ", but you are not allows to withdraw that much.", 255, 255, 255) 
Else 
SetMoney(Player, (PlayerCash% + RealLoanAmt%)) 
CurrentLoanOutstanding% = RealLoanAmt% + Int((RealLoanAmt% / 100) * InterestRate#) 
DialogOutput(Player, D, "Here is your " + RealLoanAmt% + " loan. Remember you now owe us " + CurrentLoanOutstanding%, 255, 255, 255) 
SaveAcct(Account$, AccountBalance%, TotalStoredItems%, CurrentLoanOutstanding%, MaxItemSlots%) 
EndIf 
DialogInput(Player, D, "Continue.", "|") 
EndIf 
EndIf 

Case 2 ; Check Loan Status 

If CurrentLoanOutstanding% = 0 
DialogOutput(Player, D, "You currently do not have a loan." , 255, 255, 255) 
Else 
DialogOutput(Player, D, "You have an outstanding balance of " + CurrentLoanOutstanding% + "." , 255, 255, 255) 
EndIf 
DialogInput(Player, D, "Continue.", "|") 

Case 3 ; Make Payment 

If CurrentLoanOutstanding% = 0 
DialogOutput(Player, D, "You currently do not have a loan." , 255, 255, 255) 
DialogInput(Player, D, "Continue.", "|") 
Else 
CloseDialog(Player, D) 
D = OpenDialog(Player, Banker, BankName$, 521) 
DialogOutput(Player, D, "How much would you like to pay on your loan?", 255, 255, 255) 
DialogOutput(Player, D, "Loan Amount Left = " + CurrentLoanOutstanding%, 255, 255, 255) 
PaidOff% = Input(Player, "Pay Amount", "$", 2) 
If PaidOff% >= CurrentLoanOutstanding% Then 
PaidOff% = CurrentLoanOutstanding% 
CurrentLoanOutstanding% = 0 
SetMoney(Player, (PlayerCash% - PaidOff%)) 
SaveAccount = 1 
DialogOutput(Player, D, "Paid " + PaidOff% + " on your loan.") 
DialogOutput(Player, D, "Your loan is completely paid off. Thank you!", 255, 255, 255) 
ElseIf PaidOff% < CurrentLoanOutstanding% Then 
SaveAccount = 1 
CurrentLoanOutstanding% = CurrentLoanOutstanding% - PaidOff% 
SetMoney(Player, (PlayerCash% - PaidOff%)) 
DialogOutput(Player, D, "Paid " + PaidOff% + " on your loan.") 
DialogOutput(Player, D, "Thank you. You still owe us " + CurrentLoanOutstanding% + ".", 255, 255, 255) 
EndIf 
If SaveAccount = 1 
SaveAcct(Account$, AccountBalance%, TotalStoredItems%, CurrentLoanOutstanding%, MaxItemSlots%) 
SaveAccount = 0 
EndIf 
DialogInput(Player, D, "Continue.", "|") 
EndIf 

Case 4 ; Nothing (Back to Main Menu) 

End Select 

Case 4 ; EXIT OPTION 

DialogOutput(Player, D, "Thank you for stopping in, Have a great day!", 255, 255, 255) 
DialogInput(Player, D, "GoodBye", "|") 
CloseDialog(Player, D) 
Return 
End Select 

Forever 

End Function 

Function SortItems(TotalStoredItems%, MaxItemSlots%) 

For i = 1 To TotalStoredItems% 
For j = i + 1 To MaxItemSlots% 
If Item$(i) <> "" Then 
Exit 
ElseIf j <> i And Item$(j) <> "" Then 
Item$(i) = Item$(j) 
ItemCount%(i) = ItemCount%(j) 
Item_Health%(i) = Item_Health%(j) 
ItemData$(i, 0) = ItemData$(j, 0) 
Item$(j) = "" 
ItemCount%(j) = 0 
Item_Health%(j) = 0 
ItemData$(j, 0) = "" 
Exit 
EndIf 
Next 
Next 
Return 

End Function 

Function SaveAcct(Account$, AccountBalance%, TotalStoredItems%, CurrentLoanOutstanding%, MaxItemSlots%) 

AccountFileHandle = WriteFile(Account$) 
WriteInt(AccountFileHandle, AccountBalance%) 
WriteInt(AccountFileHandle, TotalStoredItems%) 
WriteInt(AccountFileHandle, CurrentLoanOutstanding%) 
If TotalStoredItems% > 0 
For i = 1 to MaxItemSlots% 
If Item$(i) <> "" Then 
WriteLine(AccountFileHandle, Item$(i)) 
WriteInt(AccountFileHandle, ItemCount%(i)) 
WriteInt(AccountFileHandle, Item_Health%(i)) 
WriteLine(AccountFileHandle, ItemData$(i, 0)) 
EndIf 
Next 
EndIf 
CloseFIle(AccountFileHandle) 

End Function