ID:141797
 
Problem description:
When I run the game with Dream Daemon it shows up
runtime error: bad loc
proc name: New (/world/New)
usr: null
src:
call stack:
: New()
but still works. While quitting game Dream Daemon shows next error:
runtime error: Cannot read null.mob
proc name: SaveChar (/mob/proc/SaveChar)
usr: FiveUSSJ (/mob/Player)
src: FiveUSSJ (/mob/Player)
call stack:
FiveUSSJ (/mob/Player): SaveChar()
FiveUSSJ (/mob/Player): Logout()

My SaveChar() Proc:
SaveChar()  
var/savefile/F = new("players/[src.ckey].sav")
F["name"] << name
F["X"] << src.x
F["Y"] << src.y
F["Z"] << src.z
F["Mob"] << usr.client.mob

While killing mob / getting killed by mob the following error appears:
runtime error: Cannot read null.exp
proc name: Death (/mob/proc/Death)
usr: Tontie (/mob/Enemy/Tontie)
src: FiveUSSJ (/mob/Player)
call stack:
FiveUSSJ (/mob/Player): Death(null)
Tontie (/mob/Enemy/Tontie): Bump(FiveUSSJ (/mob/Player))
Tontie (/mob/Enemy/Tontie): Move(the g027 (325,130,1) (/turf/ground/g027), 2)
Tontie (/mob/Enemy/Tontie): Wander()
Tontie (/mob/Enemy/Tontie): New(the g027 (228,107,1) (/turf/ground/g027))

My Death() proc:
mob
proc
Death(mob/killer)
if(src.HP<=0)
if(src.client)
if(src==killer)
world<<"[src] killed themself."
src.exp-=50
src.loc=locate(126,88,6)
src.HP=src.MHP
else
world<<"[src] has been killed by [killer]."
src.loc=locate(126,88,6)

src.HP=src.MHP
killer.exp+=src.level
killer.Level()
else
src.loc=locate(12,76,5)
killer.exp+=100
else
return
.

When you try to Load previous character game shows " entered the game" but nothing happens, your still on loading screen. Dream Daemon shows:
FiveUSSJ (/mob/Player): LoadCharacter()
LoadChar (33,44,7) (/turf/LoadChar): Click(LoadChar (33,44,7) (/turf/LoadChar), "default.map1", "icon-x=6;icon-y=15;left=1")

My LoadChar() proc:
mob
proc
LoadCharacter()
worldlog+="[src]/[src.key]([src.client.address]) enters game.<br>"
var/savefile/F = new("players/[src.ckey].sav")
var/X
var/Y
var/Z
var/mob/newmob = new()
F["name"] >> name
F["X"] >> X
F["Y"] >> Y
F["Z"] >> Z
F["Mob"] >> newmob
newmob.loc = locate(X,Y,Z)
newmob.client = src.client


Thanks for reading.

Your not setting your variables right or calling them right, examples:
runtime error: bad loc
usr: null

DON'T USE USR!

In SaveChar:
runtime error: Cannot read null.mob

The line thats messing it up:
F["Mob"] << usr.client.mob

Again, don't use usr... Also put an if(client) before that line.

In Death()
runtime error: Cannot read null.exp
Death(null)

The mob/killer is null, so that means there is no killer, or whatever, so its messing up when you have:
killer.exp+=100


So put an if(killer) or define the killer when you first call Death(Killer goes right here!).

Also, just re-do your whole load proc, why do you make a new mob when the player already is a mob? That makes no sense at all.
In response to Bakasensei
So... I need to replace usr with src?
And how to define killer?
I'm begginer coder :P
In response to FiveUSSJ
Whoever kills the person should be in the parenthesis in Death() like this:
...
m.HP+=9000//m is being hurt some how
if(m.HP>9000) //ITS OVER 9000!
m.Death(src)//m is dying, src killed him.


Thats just how you define it. Mainly all your problems where with defining things, and yes in most cases switch usr to src.
In response to Bakasensei
You should be subtracting instead of adding if you plan on killing a mob <.<
In response to Andre-g1
...

...

I seriously don;t even know how to answer this, but if your serious I wasn't being so, and thought that you would clearly now to subtract would taking away hp... But it was for teh lulz.
In response to Bakasensei
Bakasensei, thanks, all is working except the Load() thing. I found that code on Byond Resources and don't rly know how to do that :P can you just explain me what's wrong in that code?
mob
proc
LoadCharacter()
worldlog+="[src]/[src.key]([src.client.address]) enters game.<br>"
var/savefile/F = new("players/[src.ckey].sav")
var/X
var/Y
var/Z
var/mob/newmob = new()
F["name"] >> name
F["X"] >> X
F["Y"] >> Y
F["Z"] >> Z
F["Mob"] >> newmob
newmob.loc = locate(X,Y,Z)
newmob.client = src.client

turf/LoadChar
icon = 'load.bmp' // change the bmp to the bmp to your "Load Character" image
Click()
if(fexists("players/[usr.ckey].sav")) // check to see if the character has a savefile
usr.LoadCharacter() // Make a call to load the character
world << "[usr] has entered."
for(var/obj/letters/O in world)
if(O.owner==src)
O.invisibility=0
usr << "Welcome back." // Welcome the player
return ..()
else
alert("No character found.")
// Uh oh! No player file found when they clicked Load!
return ..()
..()
In response to FiveUSSJ
src.client=newmob


That should work.
In response to Bakasensei
Well.. it still don't work.
mob
proc
LoadCharacter()
worldlog+="[src]/[src.key]([src.client.address]) enters game.<br>"
var/savefile/F = new("players/[src.ckey].sav")
var/X
var/Y
var/Z
var/mob/newmob = new()
F["name"] >> name
F["X"] >> X
F["Y"] >> Y
F["Z"] >> Z
F["Mob"] >> newmob
newmob.loc = locate(X,Y,Z)
newmob.client = src.client
src.client=newmob
In response to FiveUSSJ
Take out
newmob.client = src.client


In response to Bakasensei
Why should setting a variable that's supposed to reference a client to a mob reference work? >_>
You probably meant using the client.mob variable.
In response to Bakasensei
0_o Sorz guys but I dont understand you at all now x_x thats still not working, I've found better Saving but still.. one bug X_X my code is:
        SaveChar()
var/savefile/F = new("Save/[src.ckey]") // This creates a new file called your key.sav in the file Save
F["last_x"] << src.last_x// This stuff saves the players location
F["last_y"] << src.last_y
F["last_z"] << src.last_z
Write(F) // This Writes the file

mob
proc
LoadCharacter()
worldlog+="[src]/[src.key]([src.client.address]) enters game.<br>"
var/savefile/F = new("Save/[src.ckey]")
Read(F) // This reads the file!
F["last_x"] >> src.last_x
F["last_y"] >> src.last_y
F["last_z"] >> src.last_z
src.loc=locate(src.last_x,src.last_y,src.last_z)

All works, saving verbs and vars too but when I load it I've got black screen. I think it's not saving XYZ...'
In response to FiveUSSJ
Any ideas?
In response to FiveUSSJ
You're probably not calling ..() on a client/New() override. And thus get a black screen and a connection failed message.
In response to Andre-g1
Nope, that's not this. Load() is being called when player click Load button on login screen. And i don't get Connection died. message. Screen just goes black, but i can teleport to npc using GM verb.
In response to FiveUSSJ
Check out your << and >> operators. Are you using the right ones for saving and loading?

Should it go:
F["yada"]<<stuff
and
F["yada"]<<stuff


OR

F["yada"]<<stuff
and
stuff<<F["yada"]
In response to FiveUSSJ
Maybe you are not loading any file or the file is empyt?what will do the 'last_x' 'last_y' 'last_z' be null and sending you to nowhere, you should use fexists() to check out if the savefile exists, or be sure that 'SaveChar()' proc is called and creating the savefile properly.
In response to EGUY
Thanks, now it's working but verbs wont save.
Error that appears in Dream Daemon:
runtime error: Cannot write to atom.verbs.
proc name: LoadCharacter (/mob/proc/LoadCharacter)
usr: FiveUSSJ (/mob/Player)
src: FiveUSSJ (/mob/Player)
call stack:
FiveUSSJ (/mob/Player): LoadCharacter()
LoadChar (32,44,7) (/turf/LoadChar): Click(LoadChar (32,44,7) (/turf/LoadChar), "default.map1", "icon-x=8;icon-y=21;left=1;scre...")

My coding:
mob
proc
LoadCharacter()

worldlog+="[src]/[src.key]([src.client.address]) enters game.<br>"
var/savefile/F = new("Save/[src.ckey].sav")
Read(F) // This reads the file!
F["last_x"] >> src.last_x
F["last_y"] >> src.last_y
F["last_z"] >> src.last_z
src.verbs=src.verbssaved
src.loc=locate(src.last_x,src.last_y,src.last_z)
Name()
world<<"[src] has logged in."
SaveChar()
src.verbssaved=src.verbs
src.last_x=src.x
src.last_y=src.y
src.last_z=src.z
var/savefile/F = new("Save/[src.ckey].sav") // This creates a new file called your key.sav in the file Save
F["last_x"] << src.last_x// This stuff saves the players location
F["last_y"] << src.last_y
F["last_z"] << src.last_z
Write(F) // This Writes the file
In response to FiveUSSJ
On load you should check if he even has a save first.
In response to Bakasensei
I did that in another place, now i just need to know how to make verbs save
Page: 1 2