runtime error: Cannot read null.mob
proc name: SaveChar (/mob/proc/SaveChar)
source file: Proc.dm,24
usr: Red (/mob)
src: Red (/mob)
call stack:
Red (/mob): SaveChar()
Red (/mob): Save()
Red (/mob): Logout()
Red (/mob): Logout()
Red (/mob): Load()
Create (1,6,10) (/turf/GSScreens/LoadCharacter): Click(Create (1,6,10) (/turf/GSScreens/LoadCharacter), "default.map", "icon-x=40;icon-y=43;left=1;scr...")
runtime error: Cannot read null.screen
proc name: updateHealth (/mob/proc/updateHealth)
source file: healthbar.dm,8
usr: Red (/mob)
src: Red (/mob)
call stack:
Red (/mob): updateHealth()
Red (/mob): updateHealth()
Okay, the stack errors only shows up when I load a character,It seems to be something to do with my loading proc
Sep 5 2015, 2:02 pm
|
|
Nobody can help unless you provide the problem code.
|
In response to Doohl
|
|
mob
proc updateHealth() var/percent=round(src.powerlevel/src.powerlevel_max*100,10) if(percent>200) percent = 101 else if(percent>100) percent=100 if(percent<0) percent=0 for(var/obj/ohudMeters/o in src.client.screen) o.icon_state=num2text(percent) spawn(10) src.updateHealth() AND mob/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 mob/proc/Load() 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 |
usr.client.mob usr.client is null. Further, stop and think about this: usr = the mob. usr.client = the mob's client. usr.client.mob = the mob again. usr.client.mob = usr. Further, you shouldn't be using usr there. It should be src. Change F["Mob"] << usr.client.mob to F["Mob"] << src |
F["Mob"] << usr.client.mob
This is extremely redundant... you could replace usr.client.mob with src and it'd do the same exact thing. Also, if you're saving the character after the mob's logged out, they won't even have a client anymore. EDIT: ninja'd |
Okay so that fixed the loading error but i'm still left with
runtime error: Cannot read null.screen proc name: updateHealth (/mob/proc/updateHealth) source file: healthbar.dm,8 usr: Red (/mob) src: Red (/mob) call stack: Red (/mob): updateHealth() Red (/mob): updateHealth() |
Again, client is null. You are updating the client's screen when there is no client.
|
In the future, your code will come out more readable on the forums if you put it in between DM tags like this:
<DM> [CODE GOES HERE] </DM> It'll come out looking like this: [CODE GOES HERE] |