28 Dec, 2008, seabast wrote in the 1st comment:
Votes: 0
Hello guys i don't post here very often but i got a small problem here. I want to set a field to 0 in all pfiles and be able to do it every so often. Planing on giveing pks a chance to win something every week if they are the top pker of that week but need to reset everyones pkills at the end of each week. Not about to manually do it so i thought about making a command. My pfiles are stored like so….in the player directory then in the first letter of the name directory. For example pfile 'Mud' would be stored in players/m directory. Ok now for my code not sure where i am missing something i know its likely something i am just overlooking. Any help would be great.

void do_clear_pk( CHAR_DATA *ch, char *argument )
char confirm[MAX_INPUT_LENGTH];
char letter;
char name;
struct dirent *ep;
DIR *dp;
FILE *fp;

argument = one_argument( argument, arg );
one_argument( argument, confirm );

if (confirm[0] == '\0' || str_cmp( confirm, "YES"))
send_to_char( "Syntax: delpk YES\n\r", ch );
send_to_char( ACOLOR(ch, C_RED), ch );
for( letter = 'a'; letter <= 'z' ; letter++ )
sprintf( dir , "%s%c/", PLAYER_DIR, letter );
dp = opendir (dir);

if (dp != NULL)
while ( (ep = readdir (dp)) )

fclose( fpReserve );
if ( ( fp = fopen( name, "w" ) ) == NULL )
perror( name );
fp->d_name->pkills = 0;
fclose( fp );
fpReserve = fopen( NULL_FILE, "r" );
closedir (dp);
perror ("Couldn't open the directory");

28 Dec, 2008, wrkq wrote in the 2nd comment:
Votes: 0
Yeah, right.
And what about players who are logged on at this specific moment?
Their next save will overwrite your changes.

Better reset the counter in-memory… in case of already logged on players it's just a matter of changing some field. In case of logged out… either load the plaer object, change it and save, or keep a 'last reset' time and zero the counter if players_last_reset < global_last_reset at login time.
28 Dec, 2008, seabast wrote in the 3rd comment:
Votes: 0
I was trying to set all offline pfiles then set the online pfiles. Onlnie pfiles is easy its just those offline pfiles.
28 Dec, 2008, Scandum wrote in the 4th comment:
Votes: 0
You could have a look at purger.c in the emud codebase.


On the other hand, what you're doing is unnecessary, you'd be better off setting a time stamp on the player. If the time stamp shows the player hasn't logged in yet for the current week, then set the time stamp to the current date, and reset whatever it is you want to reset.
29 Dec, 2008, Omega wrote in the 5th comment:
Votes: 0
Why not just create a simple database to hold onto this pk counter specifics.

And every-week it refreshs, that way, players keep their pk-record in their pfile, so they can see their totals, and yet, everyweek, the ladder-board resets.

Simply put, on pk, it adjusts the character, and the database, which is nothing, things like dlm muds statlist.c do it, they just don't refresh, which is something that could be easily modified, if your not confident with your coding abilities. If you are, simple database, takes 2 minutes to write up. And there, no more worries :)
29 Dec, 2008, Skol wrote in the 6th comment:
Votes: 0
Could even do it with a linked list and a flatfile it saves to if you don't have other options. Remove the file, fresh start.
29 Dec, 2008, Omega wrote in the 7th comment:
Votes: 0
That works too, easily enough, purging the old flatfile (or database).

Another option is, at new week, move previous weeks file to a .old file.
so you can display the previous weeks top candidates, so people can compare the ladder
to the previous weeks :)

Theres plenty of options, editing everyone's pfile is just insane. Extremely bloated, and problematic.

In anycase, yeah :)
29 Dec, 2008, Skol wrote in the 8th comment:
Votes: 0
Good call on the backups of the old for doing previous weeks ones Darien.
I've been thinking about going 'fishing records' for the top sized (whichever fish) caught, biggest, longest, most value etc. It'd be a fun similar thing saving to a records file, keeping a linked list going and loading/saving it to that so that it only has to check the file if that fish/that stat exceeds etc.
Although, if I keep going too much down the fishing route, I might have to rename the game like Citco Ansalon ;p.
Random Picks