ID:145549
 
Code: A login code. It loads your savefile if you have one. If you haven't passed the Tutorial, you play it again. If you have you go to your old location. If you don't exist then you start the tutorial.
mob/Player
icon = 'Person.dmi'
icon_state = "Base"
Login()
if ("players/[usr.ckey].sav")
LoadCharacter()
if (usr.playedbefore == 0)
var/turf/start/random_start = pick(starting_turfs)
loc = random_start
world << "<b>[usr] is now in the tutorial.</b>"
usr << "Welcome to the tutorial."
usr << "To complete this tutorial, you must talk to a person to be teleported to the next."
usr << "Then your free to do whatever."
usr << "Use the left mouse button to Click on a NPC to talk."
return ..()
if (usr.playedbefore == 1)
world << "<b>[usr] has joined the game.</b>"
return ..()
else
var/turf/start/random_start = pick(starting_turfs)
loc = random_start
world << "<b>[usr] is now in the tutorial.</b>"
usr << "Welcome to the tutorial."
usr << "To complete this tutorial, you must talk to a person to be teleported to the next."
usr << "Then your free to do whatever."
usr << "Use the left mouse button to Click on a NPC to talk."
return
Logout()
world << "<B>[usr] has left the game.</b>"

mob
proc
LoadCharacter() // The load character proc
var/savefile/F = new("players/[src.ckey].sav") // define the location of the save file
var/X // Defines a temporary X variable
var/Y // Defines a temporary Y variable
var/Z // Defines a temporary Z variable
var/mob/newmob = new() // Initialize a new mob
F["name"] >> name // Load the name from the list into the character's name
F["X"] >> X // Load the X variable from the savefile to the temporary X variable
F["Y"] >> Y // Load the Y variable from the savefile to the temporary Y variable
F["Z"] >> Z // Load the Z variable from the savefile to the temporary Z variable
F["Mob"] >> newmob // Load all the mob data into the initialized mob
newmob.loc = locate(X,Y,Z) // Move the initialized mob to the last saved location
newmob.client = src.client // Set the mob's client to players client
..()


Problem description:

has left the game.
is now in the tutorial.
has left the game.
has joined the game.
has left the game.
has joined the game.
has left the game.
has joined the game.
has left the game.
has joined the game.
has left the game.
has joined the game.


For some reason the name don't show up, and since it keeps loading my location I can't move.


The problem is that usr is the original player that connected. The loaded mob is a totally new and different one.
In response to Jon88
Try F["Mob"] << Mob or something...
In response to KirbyRules
KirbyRules wrote:
Try F["Mob"] << Mob or something...

Dude, don't just make suggestions at random. No such var as Mob even appears in that code. What he has to do is replace usr with the correct var.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
No such var as Mob even appears in that code.

Oh really?

RedlineM203 wrote:
F["Mob"] >> newmob


Look harder next time.
In response to KirbyRules
"Mob" is an index in the savefile. And is not a defined variable, like he said. Maybe you should learn to program just a little bit before giving foolish advice, and trying to correct someone a million times better than you.
In response to Cheetoz
Sorry, I'm not experianced in save files...
In response to KirbyRules
Then don't try and help?
In response to KirbyRules
Where do you see the variable 'Mob'?

Before telling somebody to 'look harder next time', you 'look harder next time'.
In response to Jon88
Hm... is there a way to correct that?
In response to KirbyRules
KirbyRules wrote:
Sorry, I'm not experianced in save files...

Then why are you weighing in with advice on a thread all about them?

Lummox JR
In response to RedlineM203
RedlineM203 wrote:
Hm... is there a way to correct that?

Well, one obvious one: No put usr in proc. Ungh.

Lummox JR