Re: code

From: Cj Stremick (
Date: 01/29/99

I've done such a system and it works very well.  I don't have it pulled out
or patchified or anything but I'll do that for you and anyone else that
wants it.  When I'm finished, I'll post it under the coding section of
Dibrova's web-page:

If you'd rather do your own, this is how I did it...  Maybe it'll give you
some ideas...

Declare a global pointer to int called "tip_list" or something of the like.

Create a text file that is read at boot-time.  It has the format of:
The first line shows the number of lines in the file.  The rest of the lines
are the tips (one per line.)  Make sure the "n" lines up with the number of
tips you will read in.  You could pretty easilly do this without the "n"
part but this was just a shortcut so it's easier to allocate memory later.

A fuction is called at boot to index the tip file.  The function reads the
first line and mallocs that many int pointers to tip_list.  Set a global int
("tip_count" or whatever) to this number.

Read in your file line by line and get the byte offset for the beginning of
each line.  You will not save the tips in memory - that's a waste if you
did.  The tips are fast and you will be able to do a very fast scan and read
with the offsets you are saving.

Create a PRF_ for your TIP channel.  I call mine PRF_NOTIPS.  Add a command
to toggle it with in the command list and put in the do_gen_toggle code to
toggle its state.

When a char is created, automatically set this PRF_ off (off to SHOW the

Update the do_toggle function.

Create a function ("broadcast_tips()" or whatever) that you will call from
heartbeat().  (Just copy an existing timed call and edit the interval and
add a call to your function).  The new function will pick a random number
between 0 and "tip_count-1"

Use this number as an index to your array of pointers (tip_list) and get the
file offset for your random tip (tip_list[n]).  fopen your file (or, I
suppose you could leave it open for the entire run and store a FILE * for
it) and seek to the file offset and read in your tip line.

Iterate through the "descriptor_list" (checking for appropriate conn states
and the absence of the pref PRF_NOTIPS) and send the string to the players.

 Be sure to put a tip in that tells them how to disable the things. :)

That's it, I think.


----- Original Message -----
From: Brad Scroggins <bscroggins@MEV.NET>
To: <>
Sent: Friday, January 29, 1999 1:23 PM
Subject:  code

>  Hello, I am attempting to impliment a system to where every x number of
>seconds a message (like a global notice or message) would come up giving
>those new to our mud a little help.  The notice needs to just split out
>random messages every so often.  But also impliment a way for those who
>been around the mud a few times to be able to turn it off.
>Any help / suggestions / LOL's are welcome

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

This archive was generated by hypermail 2b30 : 12/15/00 PST