ID:268219
 
Hello I am making a saving code and I wanted to have stuff save before the world is destroyed on world/Del().

world/Del()

... In here is my saving code which Im sure will work. If you want the code in the middle just ask for it. How ever i dont feel like giving it away on the forums kinda a secret.

sleep(100)
. = ..()

What I figure is the world del is being returned before my saving code is run and thus ending all procedures like says it should do in the reference. But how do u stop it from returning so my save code can be run?
I think by the time world/Del() is called, the world is gone, so nothing in world/Del() happens.
In response to Airjoe
Airjoe wrote:
I think by the time world/Del() is called, the world is gone, so nothing in world/Del() happens.

Hmmmm so how do I fix that? and I thought world/Del() was the main function in closing out the world?

[edit] When the world is destroyed, only the Del() proc of the world object is called automatically.

That was taken from the Ref doesnt that mean what Im saying up above?
In response to Green Lime
Lets say the host just closes DS or DD by clicking the X. It totally shuts down the world, and since DS is closed, it can't call world/Del()
In response to Green Lime
Green Lime wrote:
Airjoe wrote:
I think by the time world/Del() is called, the world is gone, so nothing in world/Del() happens.

Hmmmm so how do I fix that? and I thought world/Del() was the main function in closing out the world?

I've managed to get around it in several projects by using client/Del(). If the client being deleted is the host or the last on in the game world, do all your world saving. It works well in BTG with save files of several megabytes in size.
In response to Airjoe
Airjoe wrote:
Lets say the host just closes DS or DD by clicking the X. It totally shuts down the world, and since DS is closed, it can't call world/Del()

But wouldnt world/Del() run if Im just logging it out. Since im the one running it wouldnt me logging out just close the world?
In response to Shadowdarke
Shadowdarke wrote:
Green Lime wrote:
Airjoe wrote:
I think by the time world/Del() is called, the world is gone, so nothing in world/Del() happens.

Hmmmm so how do I fix that? and I thought world/Del() was the main function in closing out the world?

I've managed to get around it in several projects by using client/Del(). If the client being deleted is the host or the last on in the game world, do all your world saving. It works well in BTG with save files of several megabytes in size.

... I tried the code bellow but it seems to not be working any ideas? and I tried the same code in client/Del() but it doesnt work.

mob/Logout()
var/inc=0
var/client/C
for(C in world)
inc++
world << "[inc]"
if(inc==1)
SAVE()
spawn(0) ..()
In response to Green Lime
Green Lime wrote:
mob/Logout()
var/inc=0
var/client/C
for(C in world)
inc++
world << "[inc]"
if(inc==1)
SAVE()
spawn(0) ..()

If the host just logged out, there are probably no clients left so inc will be 0.

var/clientcount = 0
client
New()
..()
clientcount++
Del()
if(!(--clientcount))
SAVE()
..()
In response to Airjoe
Airjoe wrote:
I think by the time world/Del() is called, the world is gone, so nothing in world/Del() happens.

I've never had problems calling saving procs in world/Del(). You just have to call ..() after you do your saving stuff, and don't spawn() or sleep() anything.