/* ************************************************************** ATM was recoded for futuristic type MUDs by Muerte muerte22@hotmail.com I did some major changes but will take NO credit away from the original coder. Thanks for help from Chil (B. Bailey) chil@gate.net and atm.c is done. Original Code was: January 25th, 1998 Gothar's Bank Code Version 1.2 1997 Copyright <* FREEWARE *> If you use this code: 1.Keep all the credits in the code. 2.Use the help entry for bank 3.Send a bug report,any comments or ideas Ian McCormick (aka Gothar) mcco0055@algonquinc.on.ca ************************************************************** */ /* N.B: READ this code before you ADD anything!! * This is atm.c */ #if defined(macintosh) #include <types.h> #else #include <sys/types.h> #include <sys/time.h> #endif #include <ctype.h> #include <stdio.h> #include <time.h> #include <string.h> #include <stdlib.h> #include "merc.h" #include "recycle.h" /* * Define Obj vnum for ATM. * --Chil */ #define OBJ_VNUM_ATM 3001 /* command procedures needed */ DECLARE_DO_FUN( do_help ); void do_account (CHAR_DATA *ch, char *argument) { long gold = 0, silver = 0; char buf[MAX_STRING_LENGTH]; gold = ch->pcdata->gold_bank; silver = ch->pcdata->silver_bank; /* No NPC's, No pets, No imms, * No chainmail, No service! */ if( (IS_NPC(ch) || IS_SET(ch->act,ACT_PET)) || (IS_IMMORTAL(ch)) ) { send_to_char("Only players need money!\n\r", ch); return; } { sprintf( buf,"Your Account records show:\n\rYou have in your pocket:\n\r" " Gold: %10ld\n\r Silver: %10ld\n\r" "In your Account:\n\r" " Gold: %10ld\n\r Silver: %10ld\n\r",ch->gold, ch->silver,gold, silver); } send_to_char(buf, ch); return; } void do_deposit (CHAR_DATA *ch, char *argument) { OBJ_DATA *pObj; bool atm; long amount = 0; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; /* No NPC's, No pets, No imms, * No chainmail, No service! */ if( (IS_NPC(ch) || IS_SET(ch->act,ACT_PET)) || (IS_IMMORTAL(ch)) ) { send_to_char("Only players need money!\n\r", ch); return; } for( pObj = ch->in_room->contents; pObj; pObj = pObj->next ) { if( atm->vnum == OBJ_VNUM_ATM ) atm = TRUE; } if( !atm ) { send_to_char("You must be near an ATM to deposit.\n\r",ch); return; } else /* In the Bank */ { argument = one_argument(argument,arg1); argument = one_argument(argument,arg2); if (arg1[0] == '\0'|| arg2[0] == '\0') { send_to_char("What would you like to deposit?\n\r", ch ); send_to_char("GBS: Deposit <value> gold\n\r",ch); send_to_char(" Deposit <value> silver\n\r",ch); send_to_char("For more information Type 'help bank'.\n\r",ch); return; } BLAHBLAH if( is_number( arg1 ) ) { amount = atoi(arg1); if ( amount <= 0 ) { send_to_char( "GBS: To deposit you must give money!\n\r", ch ); send_to_char( " For more information Type 'help bank'.\n\r",ch); return; } if(!str_cmp( arg2, "gold")) { if (ch->gold < amount) { send_to_char("GBS: You don't have that much gold.\n\r",ch); return; } else { ch->pcdata->gold_bank += amount; ch->gold -= amount; act("$n deposits gold into $s account.", ch,NULL,NULL,TO_ROOM); sprintf( buf, "GBS: You have deposited %ld Gold.\n\r Account: %10ld.\n\r Pocket: %8ld.\n\r", amount, ch->pcdata->gold_bank, ch->gold); send_to_char( buf, ch); return; } } if(!str_cmp( arg2, "silver")) { if (ch->silver < amount) { send_to_char("GBS: You don't have that much silver.\n\r",ch); return; } else { ch->pcdata->silver_bank += amount; ch->silver -= amount; act("$n deposits silver into $s account.", ch,NULL,NULL, TO_ROOM); sprintf( buf, "GBS: You have deposited %ld Silver.\n\r Account: %10ld.\n\r Pocket: %8ld.\n\r", amount, ch->pcdata->silver_bank, ch->silver); send_to_char( buf, ch); return; } } } send_to_char("The type of currency must be stated before the amount.\n\r",ch); } send_to_char( "ATM doesn't exist.\n\r", ch ); return; } void do_withdraw (CHAR_DATA *ch, char *argument) { OBJ_DATA pObj; bool atm; long amount = 0; char arg[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; /* No NPC's, No pets, No imms, * No chainmail, No service! */ if( (IS_NPC(ch) || IS_SET(ch->act,ACT_PET)) || (IS_IMMORTAL(ch)) ) { send_to_char("Only players need money!\n\r", ch); return; } for( pObj = ch->in_room->contents; pObj; pObj = pObj->next ) { if( atm->vnum == OBJ_VNUM_ATM ) atm = TRUE; } if( !atm ) { send_to_char("You must be near an ATM to withdraw.\n\r",ch); return; } else /* In the Bank */ { argument = one_argument( argument, arg ); argument = one_argument( argument, arg2 ); if (arg[0] == '\0'|| arg2[0] == '\0') { send_to_char("How much to withdraw away?\n\r", ch ); { send_to_char("GBS: Withdraw <value> gold\n\r",ch); send_to_char(" Withdraw <value> silver\n\r",ch); } send_to_char("For more information Type 'help bank'.\n\r",ch); return; } if( is_number( arg ) ) { amount = atoi(arg); if ( amount <= 0 ) { send_to_char( "GBS: To withdraw you must give an amount!\n\r", ch ); send_to_char( " For information Type 'help bank'.\n\r",ch); return; } if(!str_cmp( arg2, "gold")) { if (ch->pcdata->gold_bank < amount) { send_to_char("GBS: You don't have that much gold in your account.\n\r",ch); return; } else { ch->pcdata->gold_bank -= amount; ch->gold += amount; act("$n withdraws gold from $s account.", ch,NULL,NULL, TO_ROOM); sprintf( buf, "GBS: You have withdrawn %ld Gold.\n\r Account: %10ld.\n\r Pocket: %8ld.\n\r", amount, ch->pcdata->gold_bank, ch->gold); send_to_char( buf, ch); return; } } if(!str_cmp( arg2, "silver")) { if (ch->pcdata->silver_bank < amount) { send_to_char("GBS: You don't have that much silver in your account.\n\r",ch); return; } else { ch->pcdata->silver_bank -= amount; ch->silver += amount; act("$n withdraws silver from $s account.", ch,NULL,NULL, TO_ROOM); sprintf( buf, "GBS: You have withdrawn %ld Silver.\n\r Account: %10ld.\n\r Pocket: %8ld.\n\r", amount, ch->pcdata->silver_bank, ch->silver); send_to_char( buf, ch); return; } } } else { send_to_char("The type of currency must be stated before the amount.\n\r",ch); } } return; } void do_change (CHAR_DATA *ch, char *argument) { OBJ_DATA *pObj; bool atm; int amount = 0,change = 0; char buf [MAX_STRING_LENGTH]; char arg [MAX_INPUT_LENGTH]; for( pObj = ch->in_room->contents; pObj; pObj = pObj->next ) { if( atm->vnum == OBJ_VNUM_ATM ) atm = TRUE; } if(!atm) { send_to_char("You must be near an ATM to change currency.\n\r",ch); return; } else /* In the Bank */ { /* No NPC's, No pets, No imms, * No chainmail, No service! */ if( (IS_NPC(ch) || IS_SET(ch->act,ACT_PET)) || (IS_IMMORTAL(ch)) ) { send_to_char("Only players need to change currency!\n\r", ch); return; } { argument = one_argument( argument, arg ); if ( is_number( arg ) ) { amount = atoi(arg); if ( amount <= 0 ) { send_to_char("GBS: How much silver do you wish to exchange?\n\r",ch); return; } else { if(ch->silver < amount ) { sprintf(buf, "GBS: You can only change %ld silver.\n\r",ch->silver); send_to_char( buf, ch); return; } else { change = ((int)ch->silver - amount)/100; ch->gold += change; ch->silver -= amount; sprintf( buf, "GBS: You have changed %d Silver.\n\rYou have recieved %d Gold.\n\r", amount, change); send_to_char( buf, ch); return; } } } else { send_to_char("GBS: Exchange syntax:\n\r",ch); send_to_char(" Exhange <value> i.e. change 120\n\r",ch); send_to_char(" So 1200 silver exchanges into 12 gold.\n\r",ch); send_to_char("GBS: Doesn't profit from currency exchange!\n\r",ch); return; } } } return; } /* **************** This is the End of atm.c *************** */