mob/player/proc
ExportFile()
if(level < CHAR_EXPORT_LEVEL)
src << "<div style='font-size: 0.7; color: #AA0000'><b>You need to be at least level [CHAR_EXPORT_LEVEL] to be able to export.</b></div>"
return
if(alert("This will delete your current savefile so your char can be available on adventurer dating. \
Are you sure you want to do this?",,"No","Yes") == "No")
return
var/filelevel = round(level,5)
var/savefile/F = new("_EXPORT/[filelevel-2]-[filelevel+2]/[ckey]_[name]_[time2text(world.realtime,"DDMMYYYY")]_[time2text(world.timeofday,"hhmmss")].char")
var/clientholder = client
client = null
F.eof = -1
F["player"] << src
Write(F)
if(second_char)
filelevel = round(second_char.level,5)
F = new("_EXPORT/[filelevel-2]-[filelevel+2]/[ckey]_[second_char.name]_[time2text(world.realtime,"DDMMYY")]:[time2text(world.timeofday,"hhmmss")].char")
F.eof = -1
F["player"] << second_char
Write(F)
var/currentfile = "savefiles/[copytext(ckey,1,2)]/[ckey]/[usedslot]"
if(fexists(currentfile))
fdel(currentfile)
nosave = TRUE
del(clientholder)
mob/player/var/tmp/nosave = FALSE
mob/player/proc
SpeedDating()
var/filelevel = round(level,5)
var/filename = "_EXPORT/[filelevel-2]-[filelevel+2]/"
//somehow get a random file out of this and then use it to advertise a new player
var/list/saved_chars = flist(filename)
if(saved_chars.len > 0)
Advertise("[filename][pick(saved_chars)]")
Advertise(var/saved_char)
world << saved_char
var/mob/player/Suitor = new
Suitor.loc = src
Suitor.LoadChar()
world << Suitor.name
world << Suitor.strength
LoadChar(var/savefile)
var/savefile/sf = new(savefile)
Read(sf)
sf["player"] >> src
src = sf["player"]
Problem description:
I've been trying to code a feature that lets people recruit another person to a party. Not any NPC person, mind you, but another char, made from another player (and by luck, yours originally), to later on play as 2 chars. That second player mob will be shortly presented, with its highest stats, class and if it knows many skills, to obfuscate a bit more and mess with those trying to roll their old char.
While I've gotten to the file saving part (though messy), I have some problems with the file loading:
The problem with this now is that it creates a new mob and all, but somehow doesn't put the savefile's data into the new mob. I'm stuck with a player mob that has all the initial variables (name ???, level 0 etc.), instead of the mob it was derived from. The exported files make up to 8Ko, so there must be something in it. How do I prevent this from happening, and forcing the loaded savefile to only load the player datas into the newly created Suitor mob?
If so, this forceloadfile() proc I wrote should easily make that happen.
The raw pastebin link makes it easier to copy and paste, since it preserves the tabs.
For example if I was to use the proc in place of the normal loading under your LoadChar() proc, it should look like this:
I didn't do much testing, so I'm being very paranoid with that exclusions list.
This proc is very powerful. It can turn a mob into a turf, or just about anything into anything. Of course, some of the data will go missing if the variables don't match up.
I hope this helps. Let me know if it works.