SHOW:
|
|
- or go back to the newest paste.
| 1 | os.loadAPI("accounts")
| |
| 2 | pD=peripheral.wrap("playerDetector_0")
| |
| 3 | - | iM=peripheral.wrap("inventoryManager_0")
|
| 3 | + | |
| 4 | outerChest = peripheral.find("minecraft:chest_0")
| |
| 5 | - | |
| 5 | + | bankIn = peripheral.find("minecraft:chest_1")
|
| 6 | ||
| 7 | regDist=5 | |
| 8 | - | |
| 8 | + | |
| 9 | - | |
| 9 | + | evt={}
|
| 10 | - | function getInRange() |
| 10 | + | tick = os.startTimer(1) |
| 11 | - | players = pD.getPlayersInRange(regDist) |
| 11 | + | |
| 12 | - | if(#players>0)then |
| 12 | + | convert={
|
| 13 | - | if(curUser=="")then |
| 13 | + | iro={doll=1},
|
| 14 | - | curUser=players[1] |
| 14 | + | gol={doll=10},
|
| 15 | - | cB.sendMessage("Welcome,§2 "..curUser.."§f!\nAvailable commands:\n§3!deposit <amount> <item> §f(fex: /deposit 64 diamond)\n")
|
| 15 | + | dia={doll=100},
|
| 16 | net={doll=1000},
| |
| 17 | - | --We have user! |
| 17 | + | atm={doll=10000},
|
| 18 | vib={doll=100000},
| |
| 19 | - | else |
| 19 | + | uno={doll=1000000}
|
| 20 | - | if(curUser ~="")then |
| 20 | + | } |
| 21 | - | cB.sendMessage("Bai bai "..curUser)
|
| 21 | + | |
| 22 | - | curUser="" |
| 22 | + | function convertToDollar(list) |
| 23 | local dollr=0 | |
| 24 | for item in list do | |
| 25 | local temp=convert[item.name].doll | |
| 26 | - | |
| 26 | + | dollr=dollr+(temp*item.amt) |
| 27 | end | |
| 28 | - | getInRange() |
| 28 | + | return dollr |
| 29 | - | sleep(1) |
| 29 | + | |
| 30 | - | end |
| 30 | + | |
| 31 | function convertToItem(amt) | |
| 32 | local list={}
| |
| 33 | local txt=amt.."$ converted to:" | |
| 34 | while amt>0 do | |
| 35 | if(amt>=convert.uno.doll)then | |
| 36 | local ni={name="uno",amt=1}
| |
| 37 | amt=amt-1000000 | |
| 38 | if(list~=nil)then | |
| 39 | if(list[#list].name=="uno")then | |
| 40 | list[#list].amt=list[#list]+1 | |
| 41 | else | |
| 42 | table.insert(list,#list+1,ni) | |
| 43 | end | |
| 44 | end | |
| 45 | txt=txt.."\n"..ni.amt.." "..ni.name | |
| 46 | ||
| 47 | elseif(amt>=convert.vib.doll)then | |
| 48 | local ni={name="vib",amt=1}
| |
| 49 | amt=amt-100000 | |
| 50 | if(list~=nil)then | |
| 51 | if(list[#list].name=="vib")then | |
| 52 | list[#list].amt=list[#list]+1 | |
| 53 | else | |
| 54 | table.insert(list,#list+1,ni) | |
| 55 | end | |
| 56 | end | |
| 57 | txt=txt.."\n"..ni.amt.." "..ni.name | |
| 58 | ||
| 59 | elseif(amt>=convert.atm.doll)then | |
| 60 | local ni={name="atm",amt=1}
| |
| 61 | amt=amt-10000 | |
| 62 | if(list~=nil)then | |
| 63 | if(list[#list].name=="atm")then | |
| 64 | list[#list].amt=list[#list]+1 | |
| 65 | else | |
| 66 | table.insert(list,#list+1,ni) | |
| 67 | end | |
| 68 | end | |
| 69 | txt=txt.."\n1 "..ni.name | |
| 70 | ||
| 71 | elseif(amt>=convert.net.doll)then | |
| 72 | local ni={name="net",amt=1}
| |
| 73 | amt=amt-1000 | |
| 74 | if(list~=nil)then | |
| 75 | if(list[#list].name=="net")then | |
| 76 | list[#list].amt=list[#list]+1 | |
| 77 | else | |
| 78 | table.insert(list,#list+1,ni) | |
| 79 | end | |
| 80 | end | |
| 81 | txt=txt.."\n1 "..ni.name | |
| 82 | ||
| 83 | elseif(amt>=convert.dia.doll)then | |
| 84 | local ni={name="dia",amt=1}
| |
| 85 | amt=amt-100 | |
| 86 | if(list[#list].name=="dia")then | |
| 87 | list[#list].amt=list[#list]+1 | |
| 88 | else | |
| 89 | table.insert(list,#list+1,ni) | |
| 90 | end | |
| 91 | end | |
| 92 | txt=txt.."\n1 "..ni.name | |
| 93 | ||
| 94 | elseif(amt>=convert.gol.doll)then | |
| 95 | local ni={name="gol",amt=1}
| |
| 96 | amt=amt-10 | |
| 97 | if(list~=nil)then | |
| 98 | if(list[#list].name=="gol")then | |
| 99 | list[#list].amt=list[#list]+1 | |
| 100 | else | |
| 101 | table.insert(list,#list+1,ni) | |
| 102 | end | |
| 103 | end | |
| 104 | txt=txt.."\n1 "..ni.name | |
| 105 | ||
| 106 | elseif(amt>=convert.iro.doll)then | |
| 107 | local ni={name="iro",amt=1}
| |
| 108 | amt=amt-1 | |
| 109 | if(list~=nil)then | |
| 110 | if(list[#list].name=="iro")then | |
| 111 | list[#list].amt=list[#list]+1 | |
| 112 | else | |
| 113 | table.insert(list,#list+1,ni) | |
| 114 | end | |
| 115 | end | |
| 116 | txt=txt.."\n1 "..ni.name | |
| 117 | ||
| 118 | end | |
| 119 | end | |
| 120 | return list,amt,txt | |
| 121 | end | |
| 122 | function hasItemsInBank() | |
| 123 | return true | |
| 124 | end | |
| 125 | function transferToOutput(list) | |
| 126 | ||
| 127 | end | |
| 128 | function truncList(list) | |
| 129 | local li={}
| |
| 130 | local o=0 | |
| 131 | local prev="" | |
| 132 | for i=1, #list do | |
| 133 | ||
| 134 | end | |
| 135 | end | |
| 136 | function widraw(usr,a) | |
| 137 | local ac = accounts.getAccount(usr) | |
| 138 | local list,rest,txt=convertToItem(a) | |
| 139 | write(txt,1,1) | |
| 140 | if(ac.cash-a>0)then | |
| 141 | ac.cash=ac.cash-a | |
| 142 | if(hasItemsInBank(list))then | |
| 143 | transferToOutput(list) | |
| 144 | accounts.updateAccount(ac) | |
| 145 | cB.sendMessageToPlayer(txt,usr) | |
| 146 | else | |
| 147 | cB.sendMessageToPlayer("Sorry, the bank, doesnt have enough items for you to pull out.\nTalk to Runnetty for help.",usr)
| |
| 148 | end | |
| 149 | else | |
| 150 | cB.sendMessageToPlayer("It seems you are trying to widraw more than you have in your account.",usr)
| |
| 151 | end | |
| 152 | end | |
| 153 | ||
| 154 | ||
| 155 | while true do | |
| 156 | evt={os.pullEvent()}
| |
| 157 | if(evt[1]=="timer")then | |
| 158 | tick=os.startTimer(1) | |
| 159 | else | |
| 160 | players = pD.getPlayersInRange(regDist) | |
| 161 | if(#players>0)then | |
| 162 | if(curUser=="")then | |
| 163 | curUser=players[1] | |
| 164 | cB.sendMessageToPlayer("Welcome,§2 "..curUser.."§f!\nAvailable commands:\n§3!deposit §f(deposits contents in chest, into your account)\n",curUser)
| |
| 165 | else | |
| 166 | --We have user! | |
| 167 | if evt[1] =="chat" and evt[2]==curUser then | |
| 168 | local splt={}
| |
| 169 | for word in string.gmatch(evt[3], "[^ ]+") do | |
| 170 | table.insert(splt,word) | |
| 171 | end | |
| 172 | ||
| 173 | write(splt[1].." "..splt[2].."\n",1,1) | |
| 174 | if splt[1]=="!deposit" then | |
| 175 | cB.sendMessageToPlayer("Deposited: ".." into "..curUser.."'s account.",curUser)
| |
| 176 | elseif splt[1]=="!widraw" then | |
| 177 | if tonumber(splt[2])~=nil then | |
| 178 | --we have a value | |
| 179 | local v = tonumber(splt[2]) | |
| 180 | widraw(curUser,v) | |
| 181 | end | |
| 182 | end | |
| 183 | ||
| 184 | end | |
| 185 | end | |
| 186 | else | |
| 187 | if(curUser ~="")then | |
| 188 | cB.sendMessageToPlayer("Bai bai "..curUser,curUser)
| |
| 189 | curUser="" | |
| 190 | end | |
| 191 | end | |
| 192 | end | |
| 193 | end | |
| 194 | ||
| 195 | ||
| 196 |