ID:179622
 
How would i make a bank code to keep items and money
and not just money
Need a rough code to start with.
Thanx.




~Richter
Richter wrote:
Need a rough code to start with.
Thanx.

Okidoke... here's something to beef up. It shall be a bare "obj-into-safe" code.
mob/var/list/bankeditems = list()
obj/vault
verb
deposit_item(obj/O as obj in usr.contents)
if(O in usr.contents) //check for loopholes :p
O.Move(src)
usr.bankeditems += O
else
return

withdraw_item()
var/list/items = usr.bankeditems
items += "Cancel" //make a cancel option
var/obj/whatitem = input("Withdraw","Withdraw") in usr.bankeditems
if(whatitem == "Cancel")
return
else
whatitem.Move(usr)
usr.bankeditems -= whatitem

Hee. I went overboard :). That should do what you want. Please try to learn from it, though. :p
In response to Vortezz
What about one item at a time and not all of them
what could i do
In response to Richter
Richter wrote:
What about one item at a time and not all of them
what could i do

What? Explain more thoroughly. If I get what you're asking, this snippet lets you deposit and withdraw one item at a time.
In response to Vortezz
Oh ok thanx man
i am trying to make it work with alk bank's demo as well
In response to Richter
How could i fit that code into alkaiser's bank code
i dont know how i could do that with a switch(input(Thing
i was trying since and i still cant get it in so if you could please help me again i would be very grate full
here is what i have
mob/BankKeeper
icon = 'VaultGuy.dmi'
var/list/bankeditems = list()
Click()
switch(alert("What do you want to deposit",,"Gold","Items"))
if("Gold")
var/A = input("Hey [usr.name]! What can I do for you?","Bank")in list("Deposit Gold","Withdraw Gold","Cancel")//choose to Deposit or Withdraw
if(A == "Deposit Gold")//if you choose Deposit Gold
var/D = input("How much gold you want to deposit?","Deposit Gold") as num//type in the amount as a number
D = round(D)//round the number off to prevent decimals
if(D > usr.gold || isnull(D))//if the amount is more than you have or is nothing
usr << "You dont have that much to deposit."
else if(D <= 0)//if the amount typed in is less than or equal to zero (this prevents people from using negative numbers to gain gold)
usr << "Can't deposit less than 1."
return
else
usr.BankGold += D //puts the amount in your account
usr.gold -= D // minuses the amount from the gold on you
if(A == "Withdraw Gold")//if you choose Withdraw Gold
alert("You have [usr.BankGold] gold in your account")//Tells you how much gold you have in the bank.
var/W = input("How much gold you want to Withdraw?","Withdraw Gold") as num//type in the amount as a number.
W = round(W)//round the number off to prevent decimals.
if(W > usr.BankGold || isnull(W))//if the amount is more than you have in the bank or is nothing.
usr << "You dont have that much to withdraw."
else if(W <= 0)//if the amount typed in is less than or equal to zero (this prevents people from using negative numbers to gain gold)
usr << "Can't withdraw less than 1."
return
else
usr.BankGold -= W //minuses the amount in your account
usr.gold += W // adds the amount to the gold on you
if(A == "Cancel")
usr << "Thank you. Come again!"
return
if("Items")
i left out the code you gave
In response to Richter
So far this is what i have and i cant get any further becuase if i do any thing else i get errors in different dm files
if("Items")
var/n = alert("what do you want to do.",,"Deposit Item","Withdraw Item","Cancel")
if(n == "Deposit Item")
var/m = input("What item do you want to deposit")in list(usr.contents)
if(m= <FONT COLOR=RED> Dont know what else to put here. So could someone please help me out here thanx </FONT>
In response to Richter
Try gtting rid of if(m == whatever) and just use m.Move(usr.vault_list) since m will equal something in usr.contents anyway.

-James
In response to Jmurph
Well i tried alot of things plus what you did and i still cant come up with the right one
So an some one please help again. Thanx.



~Richter