ID:172156
 
I want to make it so that old savefiles are deleted at the beginning of every month if they haven't been used in 30 days. I came across a thread at http://developer.byond.com/forum/ index.cgi?action=message_read&id=182261&forum=8&view=1&displ ay=1#182560
Would this work? Will that flist() end up picking files like the .rsc, etc. and delete them?
flist() gets all the files in the directory. If you want it to just recorgnize saves, just use findtext() on the results and look for your savefile's type, such as:

<code>if(findtext("[file]", ".sav")) world.log << "Yes, its a savefile."</code>
In response to Foomer
K i was thinking a while on this one seriously.
You need a date system in your game first of all.
You need a atom/movable var called date=0
and one called ton=0
Everytime you save you need to save the day(in a sepearate save called day.sav or something)
You also need to save a persons well um... days on in a row
in a save called "[usr]D-on.sav" and everytime they log in have a proc that checks this save for the person whos using it, make it so it deletes the save if there amount is 1-5.
Than reset the persons times on var to 0 and that should work.
Although I'm not sure but it might work......
Please tell me if this works.
In response to Chrisman767
How do I get files from only a certain folder? The files are saved to a folder called "players".
In response to EGUY
Its all covered in the DM Reference under flist(). Look it up.
In response to Chrisman767
Why not just create seperate directories within the savefile?

for example...
proc/Save()
var/savefile/F = new("[src.ckey].sav") //the name of the savefile is the players ckey.sav
F.cd = "player data" //the directory for player stats
F["Name"] << src.name //store your name...
F["Health"] << src.health //store your health...
F["Whatever..."] << src.whatever //store whatever variables you want stored for there stats
F.cd = "days online" //store the day stuff here
F["Last Login"] << src.last_login //date of last login

Anyway, I really dont see how its possible for the player directory to be cleaned every 30 days, the player has to login for the game to do anything to there save, it might be able to if the savefile is on the hosts computer or something (which is where savefiles are normally stored anyway) but how to actually do it is over my head, sorry if this makes it more confusing, just hit me over the head with a metal bat or something
In response to War_master66
War_master66 wrote:
it might be able to if the savefile is on the hosts computer or something (which is where savefiles are normally stored anyway) but how to actually do it is over my head, sorry if this makes it more confusing, just hit me over the head with a metal bat or something

*clonk* ...well, you asked for it. ;-)

The savefiles are on the host's computer. flist() and all similar functions work on the host's computer. So no problem there. =)