Mail autoreception [by Ryan Linn]
Snippet Posted Wednesday, August 12th @ 11:30:37 PM, by George Greer in the Utils dept.
Added Jan 26, 1997. Click the link below to read it or download it.

From: Ryan Linn <rlinn@hubcap.clemson.edu>
Subject: Autoreceiving Mudmail

well while I was playing with the mail code ... I was bored enough to
write code so that you will automatically receive mudmail when you are in
the mud.  I have tested this, and ON MY MUDS, it had no problems.  I give
it no garantees and can only say it worked with my stuff.  So here it is,
mail me if there are any problems with it:

To mail.c
---------
to voids at top:
 void pmail_check (void);

to externs at top:
extern struct descriptor_data *descriptor_list;

to bottom of file:
void pmail_check (void) {

sh_int obj_vnum = NOTHING;
struct descriptor_data *d;
struct obj_data *obj, *mail_obj;
struct char_data *ch;

for (d = descriptor_list; d; d = d->next) {

if (STATE(d) == CON_PLAYING)
  if(d->character)
   if (has_mail(GET_IDNUM(d->character))){
    ch = d->character;
    if ( GET_POS(ch) > POS_SLEEPING && GET_POS(ch) != POS_FIGHTING)
    while (has_mail(GET_IDNUM(ch))) {

obj = create_obj();

obj->item_number = NOTHING;

obj->name = str_dup("postcard card mail letter");

obj->short_description = str_dup("A Postcard");

obj->description = str_dup("A postcard gathers dust here.");


GET_OBJ_TYPE(obj) = ITEM_NOTE;

GET_OBJ_WEAR(obj) = ITEM_WEAR_TAKE | ITEM_WEAR_HOLD;

GET_OBJ_WEIGHT(obj) = 1;

GET_OBJ_COST(obj) = 30;

GET_OBJ_RENT(obj) = 10;

obj->action_description = read_delete(GET_IDNUM(ch), &obj_vnum);


if (obj->action_description == NULL)
      obj->action_description =

str_dup("Mail system error - please report.  Error #11.\r\n");

    obj_to_char(obj, ch);

/* If you do not have the object mailing patch installed DON'T ADD THIS!*/
    if (obj_vnum != NOTHING && real_object(obj_vnum) != NOTHING) {
      mail_obj = read_object(real_object(obj_vnum), REAL);
      obj_to_char(mail_obj, ch);
        send_to_char("Wow... your mail has an attachment!\r\n",ch);
    }
/* Ok finish with the rest of it now */

    act("A fairy pops in and hands you a Postcard.",FALSE,ch,0 , 0, TO_CHAR);
    act("A fairy drops in and gives $n a Postcard.", FALSE, ch, 0, 0, TO_ROOM);
   }
  }
 }
}



to comm.c
---------
to external voids:
void pmail_check(void);

somewhere in heartbeat:
  if (!(pulse % (15 * PASSES_PER_SEC)))         /* 15 seconds */
    pmail_check();

This should be it... like I said ... if you have problems with it... it
should only be something small but please don't flame me if you have
problems with it.  Also ... I know it is sorta sloppy... and I
appologize, but if someone wants to clean it up and make it prettier, go
ahead.

Ryan Linn
Apollo - Imp Ruins cyberplayce.com 8000

 Imp ROR login.greatbasin.com 4000

 Imp ShadowMud cyberplayce.com 4567


<< Magic 8-Ball! [by Mike] | Reply | View as text | Flattened | Mazes [by Desmond Daignault] >>

 


Related Links
  download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.