ID:171600
 
I know there isn't much of a problem, but when i click the
New char button it won't do anything if there isn't a
save file for that person. how would i get it to come up if there isn't one,

here is the coding in problem
turf/NewChar
icon = 'New.bmp'
Click()
if (fexists("players/[usr.ckey].sav"))
switch(alert("If you continue with a new character, your previous character will be erased. Do you wish to continue?","[world.name]","Yes","No"))
if ("Yes")
usr << "... Ok... You can now create a new character."
usr.CreateChar()
return ..()
if ("No")
usr << "Ok, Please reconnect for you are being disconnected now and then choose \"LOAD GAME\""
del(usr)
return ..()
else
usr.CreateChar()
return ..()
..()
It doesn't do anything if they don't have a save because you told it to do stuff only if they have a save. Thats what the if(fexists( line is for. You need something like this:
if(fexists("players/[usr.ckey].sav"))
//stuff
else
usr.CreateChar()
In response to Airjoe
Airjoe wrote:
It doesn't do anything if they don't have a save because you told it to do stuff only if they have a save. Thats what the if(fexists( line is for. You need something like this:
> if(fexists("players/[usr.ckey].sav"))
> //stuff
> else
> usr.CreateChar()
>



now when i have it like that, i have a load error.
when the character loads it had a runtime error in the byond client, and it woun't load the previously saved spot from where it was saved.
here is the dm of the load, can ne1 help
mob
proc
LoadCharacter()
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
In response to ElderKain
Yesh, but did the player save?
Try src.key also.
In response to Hell Ramen
Hell Ramen wrote:
Yesh, but did the player save?
Try src.key also.

i tried the src.ckey in the thing instead of usr.ckey and it comes up with it saying its an undefined variable.

when i click the load button it comes up with this error.
<font color="red">
runtime error: Cannot modify null.loc.
proc name: LoadCharacter (/mob/proc/LoadCharacter)
usr: ElderKain (/mob)
src: ElderKain (/mob)
call stack:
ElderKain (/mob): LoadCharacter()
LoadChar (10,3,30) (/turf/LoadChar): Click(LoadChar (10,3,30) (/turf/LoadChar))
</font>
In response to ElderKain
ElderKain wrote:
Hell Ramen wrote:
Yesh, but did the player save?
Try src.key also.

i tried the src.ckey in the thing instead of usr.ckey and it comes up with it saying its an undefined variable.

when i click the load button it comes up with this error.
<font color="red">
runtime error: Cannot modify null.loc.
proc name: LoadCharacter (/mob/proc/LoadCharacter)
usr: ElderKain (/mob)
src: ElderKain (/mob)
call stack:
ElderKain (/mob): LoadCharacter()
LoadChar (10,3,30) (/turf/LoadChar): Click(LoadChar (10,3,30) (/turf/LoadChar))
</font>

Turn on your debug so it tells you which line the error is on.
In response to ElderKain
ElderKain wrote:
<font color="red">
runtime error: Cannot modify null.loc.
proc name: LoadCharacter (/mob/proc/LoadCharacter)
usr: ElderKain (/mob)
src: ElderKain (/mob)
call stack:
ElderKain (/mob): LoadCharacter()
LoadChar (10,3,30) (/turf/LoadChar): Click(LoadChar (10,3,30) (/turf/LoadChar))
</font>

So newmob is null. Since you are creating newmob from scratch, thats happening because the "Mob" element in the savefile is null (Since this line sets newmob-> F["Mob"] >> newmob)