ID:146751
 
mob
var
save_x
save_y
save_z
Write(savedfile/F)
save_x = x
save_y = y
save_z = z
..()
Read(savefile/F)
..()
Move(locate(save_x,save_y,save_z))


mob
Login()
..()
var/savefile/F = new(ckey)
Read(F)
return
Logout()
..()
var/savefile/F = new(ckey)
Write(F)
del(src)


Problem: It won't warp me to my save_x,save_y and save_z coords.

~>Jiskuha
Write(savefile/F)
..()
F["last_x"] << x
F["last_y"] << y
F["last_z"] << z
Read(savefile/F)
..()
var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
src.loc = locate(last_x, last_y, last_z)


try that
In response to Zero's Baby
That sends me to a blank screen.

~>Jiskuha
In response to Jiskuha
hmmm.. works fine for me....
In response to Jiskuha
Jiskuha wrote:
That sends me to a blank screen.

~>Jiskuha

Are you reading it if there is no savefile or anything?
In response to Hell Ramen
client
proc
Save()
var/savefile/F=new("players/[src.ckey].sav")
F<<src.mob


client/proc/Load()
var/savefile/F=new("players/[src.ckey].sav")
F>>src.mob

mob
Login()
..()
world << "CONNECTED"
if(fexists("players/[src.ckey].sav"))
world << "Save Loaded"
src.client.Load()
src.loc=locate(1,1,1)
sleep(10)
src.client.Save()
else
world << "Save not found"
src.loc=locate(1,1,1)
src.client.Save()


I get the "Save loaded" part so that's working fine however when it goes to Load() it gives me a blackish screen. Any suggestions?

~>Jiskuha
The only potential problem I see with this code (although other code posted on this thread would be a better choice) is that you're using Move() to move the player, which is a bad idea because that location might be taken. Set src.loc directly instead.

You should also have a fallback location if none is available from the savefile. I.e.:

loc = locate(last_x, last_y, last_z)
if(!loc) loc = locate("start") // starting turf


Lummox JR
In response to Lummox JR

(although other code posted on this thread would be a better choice)

So you are saying i should use the method another's example shows me?

~>Jiskuha
client
proc
Load()
var/savefile/load
load = new ("saves/[src.mob.ckey].sav")
load["mob"] >> src.mob
load["x"] >> src.mob.x
load["y"] >> src.mob.y
load["z"] >> src.mob.z
Save()
var/savefile/save
save = new ("saves/[src.mob.ckey].sav")
save["mob"] << src.mob
save["x"] << src.mob.x
save["y"] << src.mob.y
save["z"] << src.mob.z


mob/proc/NewGame()
src.loc = locate(6,6,1)
src.SaveAuto()
..()
mob
Login()
..()
Tester(src)
var
PASSWORD = "nulled"
mob
proc
Tester()
src.sight |= BLIND
src << "<small>Please input Testers pass code."
sleep(5)
var/ACCESS = input(src,"Enter Testers Code:","Password") as password
if(ACCESS != PASSWORD)
Tester(src)
else
src.sight &= ~BLIND

if(fexists("saves/[src.ckey].sav"))
src.client.Load()
src.loc = locate(6,3,1)
src.SaveAuto()
else
NewGame()




mob/proc/SaveAuto()
src.client.Save()
src<<"<small>Your game has been auto-saved."
sleep(3000)
SaveAuto()

mob
Logout()
..()
del(src)


Here is what keeps happening. I log in load my save and then after i load my save file it bumps me back to the beginning of the testers() proc. Any help?

~>Jiskuha


In response to Jiskuha
Of course Tester() is being called when you load a mob from a savefile. When you load the mob it loads with the same key and all, which in turn switches your client over to using that new mob. (Plus, you're loading directly into client.mob, so you're also forcing it to be set as your new mob.) Logout() and Login() are called implicitly whenever you switch mobs.

What you'll need to do is probably set some sort of var that will signal that this mob has just been loaded and doesn't need to call Tester() when it logs in.

You have a few other problems, though, that need addressing first. First of all, your Load() proc is actually much much worse off than it was before. You're loading x,y,z directly into mob.x, mob.y, and mob.z; that's not going to work. You have to load directly into local vars just like the other code in this thread did. Your load code actually worked before (as far as setting the player's old position is concerned) because it did something similar to that.

One other big problem is the infinite recursion in Tester(). That is, the proc is calling itself just to loop--which it doesn't need to do in this case--and it's doing so without calling spawn(). In fact there's a security hole here because 1) anyone can just keep entering passwords indefinitely, and 2) if they do so without success, it will cause a runtime error.

Wrong:
src << "<small>Please input Testers pass code."
sleep(5)
var/ACCESS = input(src,"Enter Testers Code:","Password") as password
if(ACCESS != PASSWORD)
Tester(src)


Right:
// always close your HTML tags
src << "<small>Please input Testers pass code.</small>"
sleep(5)
var/tries = 3
var/access
// verify src.client is valid each time because the player may log out
while(client && tries-- > 0 && access != PASSWORD)
access = input(src,"Enter Testers Code:","Password") as null|password
// allow cancel; delete mob
if(!access) del(src)
// if player failed
if(access != PASSWORD)
src << "Your password was incorrect."
temp_ban_keys += key
del(src)


Lummox JR
In response to Lummox JR
So if i removed the Testers() Proc the original save system should work?

~>Jiskuha
In response to Jiskuha
client/proc/Save()
var/savefile/save
save = new ("saves/[src.mob.key].sav")
save["mob"] << src.mob
client/proc/Load()
var/savefile/save
save = new ("saves/[src.mob.key].sav")
save["mob"] >> src.mob

mob/proc/SaveAuto()
src.client.Save()
src<<"<small>Your game has been auto-saved."
sleep(3000)
SaveAuto()



I tried that and i removed the testers proc however i am still getting logged out on load.

~>Jiskuha
In response to Jiskuha
mob/Login()
if(!post.notanswered)
src.BumpPost()
else
return 0


Bump.
~>Jiskuha
In response to Jiskuha
New system(AGAIN!)
mob/verb/Save()
var/savefile/F = new("saves/[usr.ckey].sav")
Write(F)
mob/verb/Load()
var/savefile/F = new("saves/[usr.ckey].sav")
Read(F)


This one now wont load.

~>Jiskuha
In response to Jiskuha
Is it really so hard for someone to help me? I've tried to re-program this thing multiple times to get a working code.

~>Jiskuha
Bump again.


~>Jiskuha
In response to Jiskuha
*cough*ID:332702*cough*
In response to Jiskuha
You really haven't been posting enough code for anyone to help you further. You've been making such drastic changes in fact that not posting some of those procs made it impossible to figure out what was going on. If you screwed with Login(), you should've posted Login(). You should post Logout() too since you keep logging out during a load.

Bumping your post over and over is useless if you're not going to provide enough information.

Lummox JR
In response to Jiskuha
My login/Logout is simply this:

mob
Login()
..()
world << "CONNECTED"
src.loc=locate(1,1,1)


mob
Logout()
..()
world << "DISCONNECTED"
del(src.client)



and for testing purposes my saving system is two verbs:

mob/verb/Save()
var/savefile/F = new("saves/[usr.ckey].sav")
Write(F)
mob/verb/Load()
var/savefile/F = new("saves/[usr.ckey].sav")
Read(F)


Problem: it still does not work(Like before) even with the testers proc removed.


~>Jiskuha
In response to Jiskuha
No wonder your players are logging out when they load a character. Logout() isn't deleting the mob itself; it's deleting the whole client.

When a character loads, there's going to be a change of mobs involved, which means Logout() and Login() get called automatically. Since Logout() calls del(src.client), the client goes bye-bye.

Lummox JR
Page: 1 2