Posted Tuesday, August 1st @ 12:29:47 PM, by Brandon Brown in the Specials dept. 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