Howdy fellow coders and snippet lovers. Here is some code ive written that will keep track of your total connections to your mud. It will store this data in a file, so that it can be loaded and saved during copyover's, shutdowns, and reboots. in short it will keep a running total of connection to your mud from now on. This is my second snippet released to the mudding community i hope you enjoy it. I ask that you leave the comment credits in place. if you have problems with this code or you have bug/fixes and or improvements, please send me an email to thorick@wizards-realm.com aka David McGowan ----------------------------------------------------------------------------------- First if you dont have a data directory under rom/ then add one. mkdir rom/data. cd to that directory and create a text file called totalcon.txt and simply put a 0 in the file at the top. and save it. MERC.H ------ under the global variables section add this . extern int tcon; in the data files used by the server section add this #define TOTALCON "../data/totalcon.txt" /* total connection file -Thorick*/ DB.C ------- near the top under the globals section. add this int tcon = 1; under Local booting procedures. add this. void load_tcon (void); under the section that says Declare db booting over. add this to the end of the loading section log_string ("Loading Total Connections File"); load_tcon(); ACT_COMM.C ---------- at the bottom of this file add this function. void load_tcon (void) { FILE *fp2; if ( ( fp2 = fopen( TOTALCON,"r" ) ) == NULL ) { log_string("Error reading from totalcon.txt"); return; } tcon = fread_number( fp2 ); fclose(fp2); } COMM.C ------- in nanny right after act( "$n has entered the game.", ch, NULL, NULL, TO_ROOM ); add this tcon++; ***IF YOU USE COPYOVER ADD THIS PART IF NOT SKIP IT.**** ACT_WIZ.C --------- at the top of do_copyover add FILE *fp2; slighly below that but not affter *** AUTOMATIC COPYOVER *** add in /* Saving total connections in who by Thorick of wizards realm. wizards-realm.com 6667 */ if ( ( fp2 = fopen( TOTALCON,"w" ) ) == NULL ) { log_string("Error writing to totalcon.txt"); return; } fprintf( fp2, "%d\n", tcon ); fclose(fp2); in copyover_recover at the top add FILE *fp2; right after act ("$n materializes!", d->character, NULL, NULL, TO_ROOM); add this if ( ( fp2 = fopen( TOTALCON,"r" ) ) == NULL ) { log_string("Error reading from totalcon.txt"); return; } tcon = fread_number( fp2 ); fclose(fp2); tcon++; **** END OF COPYOVER SECTION **** in do_reboot at the top of the function add FILE *fp; then add this before if (ch->invis_level < LEVEL_HERO) if ( ( fp = fopen( TOTALCON,"w" ) ) == NULL ) { log_string("Error writing to totalcon.txt"); return; } fprintf( fp, "%d\n", tcon ); fclose(fp); do the exact same thing for do_shutdown. ACT_INFO.C ---------- and finnaly, in your do_who function , change your line that looks like this sprintf( buf, "{x\n\rPlayers found: {c%2d{x to have this in it Total Connections Since 06/09/04: {G%3d and add the tcon varaible in the sprintf mine for example looks like this. sprintf( buf, "{x\n\rPlayers found: {c%2d{x Most on today: {C%2d{x\n\r{WTotal Connections Since 06/09/04: {G%3d{x\n\r",count, max_on, tcon); obviously youll want to change the date. That should be it do a clean compile i dont think i forgot anything but if i did please send me an email. if you use this snippet id like to hear from you email me at thorick@wizards-realm.com. btw this snippet was inspired by some code found in quickmud advanced version. and finnaly although this will save your connection data through shutdowns reboot and copyovers, it wont save it through a crash. if you have sig handling capabilities on your mud, then throw in on of those write data functions in it when it tries to recover from a crash. David McGowan AKA Thorick of Wizards Realm wizards-realm.com port 6667