Jake Turner writes, "Ok, this is a small clean mobprog i made that turns a normal mob into a dealer in second hand items. People can leave there eq with the mob at a price then other people can buy it, the money is then donated to the sellers bank account. " Ok, this is a small clean mobprog i made that turns a normal mob into a dealer in second hand items. People can leave there eq with the mob at a price then other people can buy it, the money is then donated to the sellers bank account. IMPORTANT: make a directory in lib called 'tellas' this is where the object information will be saved feel free to change the directory name.. but make sure you edit the code too :P Here is the code, add it to a new file: To use it just assign a mob to the pawn_keeper prog in spec_assigns. ############################################ ############################################ ############################################ /* Code for second hand shops by Jake Turner - aka Culhaven (sword.grailhall.com port2411) */ #include "conf.h" #include "sysdep.h" #include "structs.h" #include "screen.h" #include "utils.h" #include "comm.h" #include "interpreter.h" #include "handler.h" #include "db.h" #include "tellas.h" #include "spells.h" extern struct index_data *mob_index; extern struct index_data *obj_index; extern struct obj_data *obj_proto; extern obj_rnum top_of_objt; extern struct descriptor_data *descriptor_list; obj_rnum find_obj_rnum(obj_vnum vnum); extern FILE *player_fl; ACMD(do_say); SPECIAL(pawn_keeper) { FILE *fl; char file_name[100]; struct char_data *customer; struct obj_data *obj; struct tella_data item, temp, *list = NULL; int number, nr, j, found = FALSE; char arg[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; obj_rnum rnum = NOTHING; struct char_file_u temp_u; struct descriptor_data *d; if(!cmd || ( !CMD_IS("list") && !CMD_IS("sell") && !CMD_IS("buy")) ) return FALSE; customer = ch; ch = (struct char_data *) me; sprintf(file_name, "tellas/%d", GET_MOB_VNUM(ch)); switch(LOWER(*cmd_info[cmd].command)) { case 'l': /* List*/ /* List*/ /* List*/ /* List*/ /* List*/ /* List*/ /* List*/ number = 0; if(!(fl = fopen(file_name, "rb"))) { do_say(ch, "There is currently nothing for sale here.", 0, 0); return (TRUE); } if(!*argument) { send_to_char("&wNo. Item Asking Price Sellers Name&n\r\n", customer); send_to_char("&c-------------------------------------------------------------------------------------&n\r\n", customer); while(!feof(fl)) { fread(&item, sizeof(struct tella_data), 1, fl); if(feof(fl)) break; if((rnum = find_obj_rnum(item.vnum)) == NOTHING) continue; sprintf(buf, "%-4d%-50s%-20d%s\r\n", ++number, obj_proto[rnum].short_description, item.sell_price, item.seller_name); send_to_char(buf, customer); } fclose(fl); } else { one_argument(argument, arg); if((number = atoi(arg)) < 0) { send_to_char("Posotive number please.\r\n", customer); return TRUE; } if(GET_GOLD(customer) < 750) { do_say(ch, "You don't have enough gold to get stats on that item.\r\n", 0, 0); return(TRUE); } nr = 0; while(!feof(fl)) { fread(&item, sizeof(struct tella_data), 1, fl); if(feof(fl)) break; if(++nr == number) break; } if(feof(fl)) { do_say(ch, "I don't have that many items in stock!", 0, 0); fclose(fl); return (TRUE); } obj = read_object(item.vnum, VIRTUAL); obj->obj_flags.value[0] = item.value[0]; obj->obj_flags.value[1] = item.value[1]; obj->obj_flags.value[2] = item.value[2]; obj->obj_flags.value[3] = item.value[3]; obj->obj_flags.extra_flags = item.extra_flags; obj->obj_flags.bitvector = item.bitvector; obj->obj_flags.weight = item.weight; for (j = 0; j < MAX_OBJ_AFFECT; j++) obj->affected[j] = item.affected[j]; obj->obj_flags.timer = item.timer; GET_GOLD(customer) -= 750; act("$n takes your gold and begins to tell you about $p.", FALSE, ch, obj, customer, TO_VICT); act("$n takes $N's gold and begins to tell $M about $p.", FALSE, ch, obj, customer, TO_NOTVICT); call_magic(customer, 0, obj, SPELL_IDENTIFY, 50, CAST_SPELL); fclose(fl); return (TRUE); } return (TRUE); case 's': two_arguments(argument, arg, arg2); if(!*arg || !*arg2) { send_to_char("Syntax: sell << Disarm Skill [by BoxBoy] | Reply | Threaded | Vampires and Slayers [by BoxBoy] >>
|
|
|
Pawn Shops Snippet by Dana Luther (dtluther@mindspring.com) on Monday, August 14th @ 10:08:34 AM http:// |
The snippet #includes a file - tellas.h which has not been posted with the snippet. |
[ Reply to this comment ] |
|
tellas.h? by Ryan Schwan (aderon@aderon.battlegroundz.com) on Saturday, August 19th @ 02:35:10 PM http://aderon.battlegroundz.com |
I was wondering where the tellas.h was. Is this from some other patch or version that I don't have? |
[ Reply to this comment ] |
|
Re: tellas.h? by Jake Turner (jakehturner@hotmail.com) on Saturday, August 18th @ 06:39:53 AM http://mercator.mudhaven.com |
Woops :P Yah, I forgot to include it in the file. So here it is..... ################################################# struct tella_data { int seller_id; /* What is the idnum of the seller */ char seller_name[MAX_NAME_LENGTH]; int value[4]; /* The 4 values of the object */ int timer; /* The timer on the object */ long int sell_price; /* How much the seller wants for the object */ obj_vnum vnum; /* The vnum of the object */ int /*bitvector_t*/ extra_flags; int weight; long /*bitvector_t*/ bitvector; struct obj_affected_type affected[MAX_OBJ_AFFECT]; int spare1; int spare2; int spare3; int spare4; }; ################################################# Thats all that is in there :P which is why i forgot it... |
[ Reply to this comment ] |