ID:139380
 
I have 3 Codes that are involved with this.

1. Login()
mob/Login()

if(!usr.Saved)
Log()
return
else
Load()
return

mob/proc/Log()
if(usr.Ban == 1)
usr << "You have Banned from this Server"
spawn(20)
del(usr)

if("DeltaMaster")
usr.GMLevel = 5

usr<< "<B><center><font color = red>Welcome to Duel Monsters Game"
icon = 'MobIcons.dmi'
switch(alert("Are you male or female","Gender Select","Male","Female"))

if("Male")
icon_state = "Random Boy 1"
usr.Gender = "Male"
Create()

if("Female")
icon_state = "Random Girl 2"
usr.Gender = "Girl"
Create()

mob/proc/Create()
var/N=input("What is your Name?") as null|text
name = N

var/deckname=input("What is The name of your deck?") as null|text
usr.deck_count += 1
DeckName = deckname

switch(alert("Would you like a guild name?","Create Guild","Yes","No"))
if("Yes")
var/guild=input("What would you like to call your guild?") as null|text
Guild = guild
if("No")
..()

var/Acecard=input("What is your Ace Card") as null|text
Ace = Acecard

usr.verbs += typesof(/mob/voice/verb)
usr.verbs += typesof(/mob/person/verb)
usr.verbs += typesof(/mob/commands/verb)
AdminCheck()
loc = locate (50,50,1)
world<< "<font color = green>Welcome our Newest Player: [usr.name]([usr.key])"

mob/Logout()
world << "<font color = red>[usr] ([usr.key]) Has left the Game."
del(usr)


2. Load/Save Proc()
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


3. Save Verb
Save()
set name = "Save"
set category = "Commands"
usr.Saved = 1
SaveChar()


Problem description:
It always saves the game but it will still use goto create() proc. Which is a problem becuase It will always do it when I Login.
mob/proc/Load()
var/savefile/F = new("players/[src.ckey].sav")
F["mob"] >> src
F["X"] >> src.x
F["Y"] >> src.y
F["Z"] >> src.z



Try this, It may work.

And don't use F["name"] << src.name. Names get saved if you do F["mob"] << src
In response to Hashir
Thanks that would has simpled it for me. but the problem still exist.
In response to DeltaMaster
Add src.SaveChar() at Logout proc. So that it can save automatically.

And also, why are you using a variable to find if player is saved? Just use fexists code.
Just a quick hint, try to use src instead of usr as much as possible in procs etc.
Login() is not called when a player connects to the game, that's client/New(). Login() is called when a client takes control of a mob. When you load a mob, you are creating a new mob and then giving the client control of it, so Login() is called. What you need to do is create a new subtype of mob, like mob/login_mob, and set that to be the default mob type (world/mob = /mob/login_mob). Then, place the login stuff under mob/login_mob, so that it won't be called when an actual mob (presumably, of type /mob or /mob/player or something) is loaded.

Note that you will of course need to create a new mob for any new players as well, rather than just modifying the login_mob they logged into. Saving a login_mob would defeat the whole purpose of this.