52 lines (44 with data), 956 Bytes
/*
Standard money server (so we can keep track of money etc)
Also possible usage for multiple currencies if desired.
Dredd 1992 - Shattered World.
*/
int account;
array whom;
#define TIME 3800
reset(arg)
{
if (!arg) {
restore_object(file_name(this_object()));
if (!whom) whom = [ ];
call_out("save_me", TIME);
}
}
save_me()
{
save_object(file_name(this_object()));
call_out("save_me", TIME);
}
#define MAX_COINS 10000000
make(int amt, creator)
{
object mn;
object cl;
int i, x;
if (!amt || amt < 0) return;
if (amt > MAX_COINS) amt = MAX_COINS;
mn = clone_object("closed/money");
mn->set_money(amt);
mn->set_owner(creator);
account -= amt;
if (!cl) cl = previous_object();
if (!cl) cl = caller();
if (cl) cl = query_su_name(cl);
if (cl) {
if ((x = index(whom, cl)) > -1) whom[x+1] = whom[x+1] + amt;
else whom = whom + [ cl, amt ];
}
return mn;
}
query_account() { return account; }
query_whom() { return whom; }