ID:149243
 
mob/Player/Login()
var/savefile/F = new("Saves/[ckey].sav")
F["Exp"] << usr.client.Exp
F["Gems"]<< usr.client.Gems
Read(F)

Ok i tried something like this to save some client vars with the uses mob.. now my coding didnt seem to work, so im wondering is it possible to save the extra vars like above? or is there another way?


Also i just made this following code, to see what would happen, i havent gotten it to work yet, but in theroy could it?

mob/Player/Write(savefile/F)
for(var/X in vars)
F["[X]"] << vars[X]
F["Exp"] << usr.client.Exp
F["ExpN"] << usr.client.ExpN
F["Energy"] << usr.client.Energy
F["Rations"] << usr.client.Rations
F["Gems"] << usr.client.Gems

mob/Player/Read(savefile/F)
for(var/X in vars)
F["[X]"] >> vars[X]
F["Exp"] >> usr.client.Exp
F["ExpN"] >> usr.client.ExpN
F["Energy"] >> usr.client.Energy
F["Rations"] >> usr.client.Rations
F["Gems"] >> usr.client.Gems</<></<></<></& lt;></<></<></<></<>
Check out Deadrons Character Handling!
WildBlood wrote:
mob/Player/Login()
var/savefile/F = new("Saves/[ckey].sav")
F["Exp"] << usr.client.Exp
F["Gems"]<< usr.client.Gems
Read(F)

Ok i tried something like this to save some client vars with the uses mob.. now my coding didnt seem to work, so im wondering is it possible to save the extra vars like above? or is there another way?

Seems like it should work. I'm afraid I don't know how to answer that one.


Also i just made this following code, to see what would happen, i havent gotten it to work yet, but in theroy could it?

mob/Player/Write(savefile/F)
for(var/X in vars)
F["[X]"] << vars[X]
F["Exp"] << usr.client.Exp
F["ExpN"] << usr.client.ExpN
F["Energy"] << usr.client.Energy
F["Rations"] << usr.client.Rations
F["Gems"] << usr.client.Gems

mob/Player/Read(savefile/F)
for(var/X in vars)
F["[X]"] >> vars[X]
F["Exp"] >> usr.client.Exp
F["ExpN"] >> usr.client.ExpN
F["Energy"] >> usr.client.Energy
F["Rations"] >> usr.client.Rations
F["Gems"] >> usr.client.Gems

That'd work just fine, but you'll probably want to do something extra in Write():

for(var/X in vars)
<font color=yellow>if(issaved(X))</font>
F["[X]"] << vars[X]

Ditto for the Read(). Otherwise, you'll get errors when it tries to overwrite constant variables.