ID:145652
 
Code:
mob
proc
LoadCharacter() // The load character proc
var/savefile/F = new("savefile/[usr.ckey]")
var/mob/newmob = new()
F["name"] >> usr.name
F["X"] >> usr.x
F["Y"] >> usr.y
F["Z"] >> usr.z
F["mob"] >> newmob
world << "[src.name] has logged in!"
newmob.loc = locate(x,y,z)
newmob.client = src.client
src.saveable = 1
usr.sight = 0


Problem description:
Well, when i Try to load with this code, it doesnt move the mob to the saved Location,
and it doesnt blackscreen them. (found the blackscreen problem except it wont unblackscreen)
it creates the Mob, names it, then drops it on the title screen

Ive been stuck on this problem for a while, every way i go turns into a dead end, any point in the right direction would be greatly apreacated


Make 3 temporary variables for extracting the x, y, and z variables to. Then set the mob.loc = locate(temp_x,temp_y,temp_z).

I've never seen anyone set mob.client to another client, but I have seen it done frequently as something like client.mob=new_mob, where you are setting the client's mob variable, rather than the mob's client var.

Also, what's up with your code? I'm assuming it came from different sources, because it alternates between from the use of usr and src religiously, when it should really only use src.

Edit: Well, after the client.mob has been changed, src will no longer reference the new mob, so use the reference that you created for the new mob for its operations

Hiead
In response to Hiead
Ah, got it, my new code is like this:

mob
proc
LoadCharacter() // The load character proc
var/savefile/F = new("savefile/[usr.ckey]")
var/mob/newmob = new()
var/temp_x
var/temp_y
var/temp_z
F["name"] >> usr.name
F["X"] >> temp_x
F["Y"] >> temp_y
F["Z"] >> temp_z
F["icon"] >> src.icon
F["state"] >> src.icon_state
world << "[src.name] has logged in!"
src.client = newmob
sleep(10)
src.loc = locate(temp_x,temp_y,temp_z)
src.login = 0
src.sight = 0
src.saveable = 0


thanks for the help ^ ^
In response to Pirion
Your welcome, but...

Pirion wrote:
>           src.client = newmob
> sleep(10)
> src.loc = locate(temp_x,temp_y,temp_z)
> src.login = 0
> src.sight = 0
> src.saveable = 0
>

This ending part should be rewritten as such:
>           src.client.mob = newmob
> sleep(10)
> // src still references the original mob
> // but now the client is controlling the new mob.
> // Luckily we have the newmob reference
> newmob.loc = locate(temp_x,temp_y,temp_z)
> newmob.login = 0
> newmob.sight = 0
> newmob.saveable = 0
> del src // At the end, because it will end code execution.

Try something like that.

Edit: Woops, I originally started with using newmob, and ended using new_mob. *Fixes*

Hiead