ID:159974
 
I have been looking around to find a nice server save system for my game and i found one: server2server i think its called.

My question is can a system like this incoporate slot saving.

///////////SAVE HANDLING CODE SO FAR/////////////////



world/Topic(T, Addr, Master, Key)
if(T == "playerfile")
var/X = world.Import()
if(X)
var/savefile/F = new(X)
if(F && istype(F))
var/name = F["ckey"]
if(!name) return -2
for(var/mob/M in world)
if(M.ckey == name)
F["MOB"] >> M
return 1
return -3
else return -1
return ..()


client
proc
Save()
if(usr.savefile1) // if your character is slot 1
var/savefile/F = new("players/[usr.ckey]/[usr.ckey](1).sav") // creates the save file
usr.savefile1=1 // just makes sure you are still in slot 1
usr.V += usr.verbs
usr.Write(F) // writes your location
switch(world.Export("byond://000.000.000.000:1234?playerupload",F)) //Replace the 000.000.000.000 with the external IP from the computer you will run the Savefile Storage on. Use the port you will host the Savefile storage
if(1)
usr << "The remote server has your file."

if(-1)
usr << "The remote server is refusing connections. Your character could not be saved at this time."
if(-2)
usr << "The remote server reports that it cannot read the savefile. Your character could not be saved at this time."
if(-3)
usr << "The remote server reports that it has received no file or not a valid savefile. Your character could not be saved at this time."
else
usr << "The remote server is unavailable. Your character could not be saved at this time."
else
if(usr.savefile2) // slot 2
var/savefile/F = new("players/[usr.ckey]/[usr.ckey](2).sav") // creates the save file
usr.savefile2=1 // just makes sure you are still in slot 1
usr.V += usr.verbs
usr.Write(F) // writes your location
switch(world.Export("byond://000.000.000.000:1234?playerupload",F)) //Replace the 000.000.000.000 with the external IP from the computer you will run the Savefile Storage on. Use the port you will host the Savefile storage
if(1)
usr << "The remote server has your file."

if(-1)
usr << "The remote server is refusing connections. Your character could not be saved at this time."
if(-2)
usr << "The remote server reports that it cannot read the savefile. Your character could not be saved at this time."
if(-3)
usr << "The remote server reports that it has received no file or not a valid savefile. Your character could not be saved at this time."
else
usr << "The remote server is unavailable. Your character could not be saved at this time."

else
if(usr.savefile3) // slot 3
var/savefile/F = new("players/[usr.ckey]/[usr.ckey](3).sav") // creates the save file
usr.savefile3=1 // just makes sure you are still in slot 1
usr.V += usr.verbs
usr.Write(F) // writes your location
switch(world.Export("byond://000.000.000.000:1234?playerupload",F)) //Replace the 000.000.000.000 with the external IP from the computer you will run the Savefile Storage on. Use the port you will host the Savefile storage
if(1)
usr << "The remote server has your file."

if(-1)
usr << "The remote server is refusing connections. Your character could not be saved at this time."
if(-2)
usr << "The remote server reports that it cannot read the savefile. Your character could not be saved at this time."
if(-3)
usr << "The remote server reports that it has received no file or not a valid savefile. Your character could not be saved at this time."
else
usr << "The remote server is unavailable. Your character could not be saved at this time."





Load()
if(src.mob)
switch(alert(usr, "Welcome to [world.name]", "Slot Loading","Slot 1","Slot 2","Slot 3")) // asks which slot you want to load
if("Slot 1") // if you chose slot 1.....
switch(world.Export("byond://000.000.000.000:1234?playerdownload",F)) //Replace the 000.000.000.000 with the external IP from the computer you will run the Savefile Storage on. Use the port you will host the Savefile storage
if(1)
usr << "The remote server has your file."
if(fexists("players/[usr.ckey]/[usr.ckey](1).sav")) // checks if there is a file...
var/savefile/F = new("players/[usr.ckey]/[usr.ckey](1).sav") // if there is, it makes up the file var...
usr.Read(F) // reads the old location
for(var/stuff in usr.V)
usr.verbs += stuff
sleep(1)
usr.savefile1=1 // makes your character go to slot one for saves
world<<"<B>World: <font color=yellow>[src] has logged in!!!!!" // tells world you logged in
usr.Auto_Save() // starts the auto save loop

usr.client.show_verb_panel = 1 //Show the verb panel
else
alert("No savefile found in this slot!") // if there is no file...
return
if(-1)
usr << "The remote server is refusing connections. Your character could not be loaded at this time."
if(-2)
usr << "The remote server reports that it cannot read the savefile. Your character could not be loaded at this time."
if(-3)
usr << "The remote server reports that it has received no file or not a valid savefile. Your character could not be loaded at this time."
else
usr << "The remote server is unavailable. Your character could not be loaded at this time."


THE SERVER CODE IS WHAT IM STUCK WITH HOW DO I PROCEDE ON MAKING IT CAPABLE TO HANDLE SLOTS.

world/Topic(T, Addr, Master, Key)
if(T == "playerupload")
var/X = world.Import()
if(X)
var/savefile/F = new(X)
if(F && istype(F))
var/name = F["ckey"]
if(!name) return -2
fcopy(X,"savefiles/[name].sav")
return 1
return -3
else return -1
if(T == "playerdownload")
var/X = world.Import()
if(X)
var/savefile/F = new(X)
if(F && istype(F))
var/name = F["ckey"]
var/Port = F["Port"]
if(!name) return -2
var/savefile/S = new("savefiles/[name].sav")
world.Export("byond://[Addr]:[Port]?playerfile",S)
return 1
return -3
else return -1
return ..()




var/password = "password"//replace this with the pass you want to use.
var/tries = 3
client
verb


DeleteSave()
var/Pass=input("What is the password?","Password") as text
if(!tries)
usr << "3 times wrong, You can not do the file delete."
return
if(Pass == password)
var/delete=input("Who'se savefile to delete?","Delete") as text
if(fexists("savefiles/[delete].sav"))
fdel("savefiles/[delete].sav")
usr << "Deleted [delete].sav"
world.log << "[usr] deleted [delete].sav"
else
usr << "Not found."
else
tries --
usr << "Wrong pass. You have: [tries] tries left"



P_Whipe()
set name = "P-Whipe"
var/Pass=input("What is the password?","Password") as text
if(!tries)
usr << "3 times wrong, You can not do the file delete."
return
if(Pass == password)
if(fexists("savefiles/"))
fdel("savefiles/")
usr << "P-Whiped"
world.log << "[usr] Did a P-Whipe"
else
usr << "Not found."
else
tries --
usr << "Wrong pass. You have: [tries] tries left"
Go to the Creations section and look at the A_FSS thread.
If you're handling slots with a directory for each player's savefiles (ex. you have a players folder, and each player has their own folder of saves) send the directory you wish to place the file in world.Export, then parse it on world.Topic() with copytext().

If you're handling slots with one savefile, you have no problems with what you're doing.