ID:140799
 
Code:
mob/var
Exists=0

client
proc
Save()
if(!src)return
if(!src.mob)return
var/savefile/save
src.verbs -= typesof(/mob/Owner/verb)
save = new ("Player Saves/[mob.ckey].sav")
save["mob"] << src.mob
save["verbs"] << src.mob.verbs
save["x"] << src.mob.x
save["y"] << src.mob.y
save["z"] << src.mob.z
Load()
var/savefile/load
load = new ("Player Saves/[mob.ckey].sav")
load["mob"] >> src.mob
var/loaded_verbs
load["verbs"] >> loaded_verbs
src.mob.verbs += loaded_verbs
load["x"] >> src.mob.x
load["y"] >> src.mob.y
load["z"] >> src.mob.z
src.mob.loc = locate(load["x"], load["y"], load["z"])
if(src.mob.Pokemon == "Lugia")
src.mob.client.Pokemon = "Lugia"
if(src.mob.Pokemon == "Salamence")
src.mob.client.Pokemon = "Salamence"
new/obj/hudMeters/hpbar(src.mob.client)
src.mob.updateHealth()
sleep(2)
for(var/obj/Pokeballa/E in src.mob.contents)
for(var/mob/M in E.contents)
M.PVerbgain()
src.mob.PVerbgain()
src.mob.cansave = 1


Problem description:Well sometimes people lose their verbs that are gained at some point like lvl 50 or if they are GM their GM rights,I searched and found that my problem could be ckey....but how do I fix that...i mean what do i put instead?

This probably has to be something like you using ckey in admin verbs, and other things.
Change all ckey's to key then tell me what happens.
In response to Megelic
Well i can't actually replicate the bug since it happens rarely when someone saves(and ckey was only used in saving,loading,and checking if there is a load file). But i have a error with Autosave that might be connected to this

mob
proc
Autosave()
xD
if(src.sended_out == 1)
if(src.cansave == 0)
return
sleep(300)
goto xD
if(src.cansave == 0)
return
src.client.Save()//the errored line
sleep(300)
goto xD


runtime error: Cannot execute null.Save().
proc name: Autosave (/mob/proc/Autosave)
source file: verbs.dm,7304
usr: Guest-3306063176 (/mob/player)
src: Guest-3306063176 (/mob/player)
call stack:
Guest-3306063176 (/mob/player): Autosave()
Guest-3306063176 (/mob/player): Login()
In response to Destrojer
Destrojer wrote:
Well i can't actually replicate the bug since it happens rarely when someone saves(and ckey was only used in saving,loading,and checking if there is a load file). But i have a error with Autosave that might be connected to this

> mob
> proc
> Autosave()
> xD
> if(src.sended_out == 1)
> if(src.cansave == 0)
> return
> sleep(300)
> goto xD
> if(src.cansave == 0)
> return
> src.client.Save()//the errored line, this is because client is null.
> sleep(300)
> goto xD
>

runtime error: Cannot execute null.Save().
proc name: Autosave (/mob/proc/Autosave)
source file: verbs.dm,7304
usr: Guest-3306063176 (/mob/player)
src: Guest-3306063176 (/mob/player)
call stack:
Guest-3306063176 (/mob/player): Autosave()
Guest-3306063176 (/mob/player): Login()

1. You shouldn't be using goto, it's not good to use, according to a lot of people in the byond community.

2. The thing that used this verb doesn't seem to be a client.

3. You should try do something like this:
mob/proc/AutoSave()
if(!(src.client)) return
if(src.sended_out&&!(src.cansave))
src.client.Save()
mob/Logout()
src.AutoSave()
..()

Note: This code isn't meant to be used, because it's probably poorly coded, and if someone see's any errors with my code, go ahead and correct me.
In response to Destrojer
just a bit of advice: don't use goto like that. instead, use while() and boolean instead of ==1...==0. it can help in other ways, too.

mob
Login()
..() //recalls any other Login() proc before coming to this.
Autosave()
proc/Autosave()
while(src)
if(src.sended_out||!src.cansave)
return ..() //recalls the autosave proc again.
src.client.Save()
sleep(300)
//src << "Game saved!"


I didn't want to use && for certain reasons..
and if you wanted to really test something, you can always use outputs to check if the proc or even parts of it is working.
In response to Lord Dragonite
Ummm....i didn't actually ask for autosave but i asked why do people lose verbs(read the first post) xD
In response to Destrojer
Well, first off, we would need to see one of the verbs that are lost probably.

I also would like to know, why you made it so verbs aren't saved with the savefiles.
In response to Destrojer
I know, I was just telling you better ways to code that autosave proc. I pretty much forgot what the first post said, but it seems you need help saving verbs.

first off, we create a var for the verbs.

mob/var/list/verb_list = list()


now, in the save proc, you should delete what you attempted in trying to save verbs and add this instead (if it doesn't work, add it in the beginning of the save proc.):

            mob.verb_list = mob.verbs


that's a way to save the verbs. now for the loading, we create a var called T which is whatever is in the client's VerbList var which is the clients verbs.

            for(var/T in client.mob.verb_list)
client.mob.verbs += T
//client.mob << "[verb_list.len] verbs successfully added!"


it works for me, it might work for you.
Okay, ignore EVERYTHING people were saying in this thread.

goto IS bad to use, according to EVERYONE.
Using while(src) to autosave is retarded, just save when they log out.
And three (correct me on this if I'm wrong), but verbs have to be saved in a different list, then have that list added to the verbs apon loading.
In response to Vic Rattlehead
Vic Rattlehead wrote:
Okay, ignore EVERYTHING people were saying in this thread.

goto IS bad to use, according to EVERYONE.

Goto is bad to use if you abuse it, which is pretty much always in any normal situation. Very very very very rarely would a situation warrant the use of goto.

Using while(src) to autosave is retarded, just save when they log out.

Auto saves are not retarded, nor is while(src) a bad way to do it. Crashes cause your 'when they log out' to not be sufficient in most situations. Personally I would do a centralized auto save system that saved for all players from one proc periodically not one per player, but that is just me and my programming style.

And three (correct me on this if I'm wrong), but verbs have to be saved in a different list, then have that list added to the verbs apon loading.

This is true. You cannot save changes to the verb list directly, and must come up with a system to save/reload manually, though a separate list is not the only option.
In response to Vic Rattlehead
you could call the proc when they log off, but apparently in his, he wanted it to save every 30 seconds, which is why I did while(src)

yeah, I forgot to make it a list, but it seemed to work without it. *edits last post*
In response to AJX
client
proc
Save()
save["verbs"] << src.mob.verbs
Load()
var/loaded_verbs
load["verbs"] >> loaded_verbs
src.mob.verbs += loaded_verbs


So basically my problem is that I saved verbs just like that in a file and not first in a list and then saved the list?
In response to Destrojer
No, that's fine.

What might help is seeing the ExportText() of a savefile that's broken.
In response to Garthor
How Do i do that?
In response to Destrojer
mob/verb/test_savefile(var/filename as text)
var/savefile/F = new(filename)
text2file(F.ExportText(),"[filename].txt")
usr << "Contents of file dumped to [filename].txt"