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.
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.
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.
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 :)
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.
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.