bankupdate.txt
snippets · 3.2 KB · 2010-03-30
Bank Interest v1.0 for SWR-based MUDs: pays interest on bank balances.
Download « Back to the snippets list
Bank Interest v1.0
**NOTE: This is not my code, I noticed you cannot find this code anywhere anymore and its a
nice piece of code for anything based from SWR. I do not take any credit for this code, I just
simply made it available again. Who knows? I may even make this snippet a little easier to
read(I don't remember how the last one was written). I also do not remember the original writer
of this code, but whoever you are, the credit goes to you.
What this does:
This will allow a player to gain a certain percentage of interest every hour, on the hour,
based on their balance in the bank. The percent they gain is based off of a number that looks
like this, .001, which is basically 1% interest. I have also included a commented part that
would allow a character to gain their interest once every MUD week.
What you will need to change:
update.c
*Always remember to backup the files you will change incase of an error with installation, or
an error with the code.
cp <filename> <newfilename>.bak
What you will need to add:
Nothing at the moment, you can always add your own twists to things.
-------------------------------------------------------------------------------------------------
update.c
Find,
void char_update args( ( void ) );
Below it add,
void bank_update args( ( void ) );
Find,
if ( --pulse_taxes <= 0 )
Somewhere in there add,
bank_update ( );
At the bottom of the file, add this function
void bank_update()
{
CHAR_DATA *ch;
int value1, value2;
char buf[MAX_INPUT_LENGTH];
/* day = time_info.day + 1;
if ( day % 7 != 6 ) /* Uncomment to have once a MUD week updates */
return;*/
for ( ch = last_char; ch; ch = gch_prev )
{
if ( ch == first_char && ch->prev )
{
bug( "char_update: first_char->prev != NULL... fixed", 0 );
ch->prev = NULL;
}
gch_prev = ch->prev;
set_cur_char( ch );
if ( gch_prev && gch_prev->next != ch )
{
bug( "char_update: ch->prev->next != ch", 0 );
return;
}
if ( !IS_NPC( ch ) ){
value1 = ch->pcdata->bank;
value2 = (value1 * .001); /* 1% interest */
ch->pcdata->bank += value2;
sprintf(buf, "&C[Monthly Bank Update] %s you made: %d credits this month.&W\n\r", ch->name, value2);
send_to_char(buf, ch);
}
}
}
-------------------------------------------------------------------------------------------------
make clean
make
copyover/reboot mud
*You should notice it working immediately after a copyover, after a reboot it will take some
time to work(an hour).
**Basically so you know how this works, with 1% interest, they will gain 1% of whatever they
have in the bank, so if they have 100 credits, they will gain 1 credit. If they have 100,000
credits, they would gain 1,000 credit. etc.
Any problems please contact me at the provided email address,
-,,,.,,,,-
_'Diablo'_ Star Wars Development
''''''
[*]------------------------------------------------[*]
||| If you have any problems please contact me at: |||
||| crazy_mike_316@hotmail.com |||
[*]------------------------------------------------[*]