ID:147610
 
Any ideas as to why this won't work?
client/Del()
var/savefile/F = new()
F["usr"] << usr
usr.client.Export(F)


client/New()
..()
var/savefile/savefile = new(Import())
if(savefile)
savefile["usr"] >> mob
return ..()
Works just peachy as a verb but doesn't work at all when "automated" under client/Del(). Its' favorite error is "Cannot execute null.Export()".
This is not a place to be using usr.
In response to Garthor (#2)
By using src instead of usr, I get "Bad output".
In response to Enigmaster2002 (#3)
Well duh, src is a client. So client.client makes no sense.
In response to Enigmaster2002 (#3)
Try replaceing '<< usr' with '<< mob' and 'usr.client.Export' with 'src.Export'.
client/Del()
var/savefile/F = new()
F["usr"] << mob
src.Export(F)


client/New()
.=..()
var/savefile/savefile = new(Import())
if(savefile) savefile["usr"] >> mob


In response to Yota (#5)
Doing that generates no errors of any sort, runtime or compile-time, but it fails to export the requested information. After logging out and back in, no changes were saved.
In response to Enigmaster2002 (#1)
Enigmaster2002 wrote:
Works just peachy as a verb but doesn't work at all when "automated" under client/Del(). Its' favorite error is "Cannot execute null.Export()".

By the time BYOND gets to client.Del(), the connected player is long gone and the client doesn't actually exist anymore. If you want to export information to a client, it has to be before the player disconnects from the game.
In response to Shadowdarke (#7)
So...what? Try it on mob/Logout(), or it can't be done without giving them a verb to do it "manually"?
In response to Enigmaster2002 (#8)
mob/logout will give you the same problem. BYOND isn't designed for trapping clients. Whenever they want to leave, they are gone before your code can blink.

If you absolutely must store things client side, your best bet would be a manual verb as you said. If you store them server side, you can go ahead and call the saving procs from client.Del() or mob.Logout(), as long as they don't refer to the mob's client. (mob.key will still be set to the client's keyname in client.Del(), if you want to use it for indexing savefiles server side.)