deposit
musicmud-2.1.6/data/verbs/deposit · 1.0 KB
From the archive musicmud2.1.6.tar.gz
Download the archive « Back to the archive contents
--lua PFL_NONE 0 3
local bank = owner(pl)
if not getflag(bank, flag.Bank) then
send(pl, "You can only deposit in a bank.")
return
end
local mob = getobj(bank, "bankmob")
if not mob or owner(mob) != bank then
send(pl, "The cashier appears to be missing.")
return
end
if getn(arg)==0 then
send(pl, "Deposit what?")
return
end
local cur = currency(mob)
local wantcur = nil
local all = nil
local amt
if txt=="all" then
all = 1
else
wantcur, amt = curmatch(arg, cur)
if not wantcur then
if amt then
send(pl, amt)
end
return
end
end
if wantcur and cur != wantcur then
tell(mob, pl, format("We only use %s currency here.", getstr(cur, "name")))
return
end
local cas = cash(pl, cur)
if all then
amt = cas
end
if amt>cas then
tell(mob, pl, lang("You don't have that much cash.", mob))
return
end
if amt==0 then
send(pl, "You don't deposit anything.")
return
end
send(pl, "You deposit "..formatcash(amt, cur, 1)..".")
setbalance(pl, cur, balance(pl, cur)+amt)
setcash(pl, cur, cas - amt)
return