ID:169284
 
This is my first time posting...blahblah.....

But this isn't going to be your usual "Erm you make it so it saves the usr.x usr.y usr.z" this time its going to be alot more challanging so ANY help at all would be great..

I need a way to save a mob's location by the roomid the mob is in

i.e "Gate" is roomid1 and "Hell" is roomid2 , A logs in and goes to "hell" and logs out, how would I go about making an output into a save file so that it the mob then has "2" in their 'lastroom' variable so that when they login they get checked for a 'lastroom' variable, if its not null it loads them BACK to the room they were in.

Thanks in advance! if you cant understand this please say and i'll try explain it otherwise.

p.s if your wondering why i need this coding, im making an MUD where players dont run around on a physical map
I'm guessing that no one is going to aid me with this?
In response to Bunnie
In response to Jmurph
There is a 3 hour gap, assuming people were going to aid me they would've posted well within that three hour mark...
In response to Bunnie
You have to wait til the next day to bump and it can't be on the front page. For your question, if you just save the player's "character", all of their vars will be saved. So restoring them will put them back in their right spot. So all you have to do is save their vars.
In response to Bunnie
Bunnie wrote:
There is a 3 hour gap, assuming people were going to aid me they would've posted well within that three hour mark...

The forums are not a real-time medium like a chat or messenging program. It takes longer on forums for people to see the post and respond, because many people only check a few times a day and many even fewer than that.

The rule is, don't bump your post until at least 24 hours have passed, and the post is no longer visible on the first page of the forum where it was posted. This is only slightly fungible, such as in cases where one extremely huge thread has eclipsed all others, and then maybe for a single bump you could cut back a bit on that 24-hour restriction.

Generally a bogus bump is simply deleted without fanfare, and someone who continues to bump irresponsibly may receive a warning for it. In extreme cases when a person just refuses to learn, their entire thread may be axed.

Lummox JR
In order to change to update the ids, you'll probably want to use areas to this effect:

area
Gate
Entered(atom/movable/A)
if(ismob(A))
var/mob/M = A
M.lastroom = "roomid1" //make a mob's (who entered) lastroom become roomid1
Hell
Entered(atom/movable/A)
if(ismob(A))
var/mob/M = A
M.lastroom = "roomid2" //make a mob's (who entered) lastroom become roomid2


Then in the saving proc save the id.
mob/proc/SavingProc()
var/savefile/F = new("[src].sav")
F["src"] << src
F["id"] << src.lastroom


Also, please bump posts according to forum rules. And don't expect help the same day as your post and sometimes even 2 days after your post.
In response to MechaJDI
MechaJDI wrote:
You have to wait til the next day to bump and it can't be on the front page. For your question, if you just save the player's "character", all of their vars will be saved. So restoring them will put them back in their right spot. So all you have to do is save their vars.

I save their vars and they do not return to the spot they were last at, they return to the starting point of the game.
In response to Bunnie
Then you clearly need a loading proc called upon mob/Login() or client/New() or perhaps through a start screen.
In response to DeathAwaitsU
DeathAwaitsU wrote:
Then you clearly need a loading proc called upon mob/Login() or client/New() or perhaps through a start screen.

I have a loading proc upon mob/Login()

it loads their mob data fine i.e race etc, however it does not load their location... and im confused as to why.. nothing is interfering with the save or manipulating the location of the loading mob. so theoretically this should work... im assuming?
In response to DeathAwaitsU
DeathAwaitsU wrote:
In order to change to update the ids, you'll probably want to use areas to this effect:

> area
> Gate
> Entered(atom/movable/A)
> if(ismob(A))
> var/mob/M = A
> M.lastroom = "roomid1" //make a mob's (who entered) lastroom become roomid1
> Hell
> Entered(atom/movable/A)
> if(ismob(A))
> var/mob/M = A
> M.lastroom = "roomid2" //make a mob's (who entered) lastroom become roomid2

Then in the saving proc save the id.
> mob/proc/SavingProc()
> var/savefile/F = new("[src].sav")
> F["src"] << src
> F["id"] << src.lastroom

Also, please bump posts according to forum rules. And don't expect help the same day as your post and sometimes even 2 days after your post.

Would that work with the dan.mud library? im simply using that system and i attempted to modify the move for the mob like so...
mob
move()
if(usr.frozen==1)
..
else
..()
usr.currentroom = loc

But then the library decided it would not load the player into the world, regardless of what command was used (there is a 'GM' command supplied allowing you to 'teleport').

[edit]
what the hell? i put merb instead of mob! *shoots self
[/edit]
In response to Bunnie
I'm sorry but I have no clue what a MUD is. Also instead of doing if(variable==1) do if(variable), atleast for a boolean variable (a variable that can either be 1 or 0 - true or false).
In response to DeathAwaitsU
DeathAwaitsU wrote:
I'm sorry but I have no clue what a MUD is. Also instead of doing if(variable==1) do if(variable), atleast for a boolean variable (a variable that can either be 1 or 0 - true or false).

I have heard MUD be defined as multiple things so i'll explain this quite simply for my one.

A MUD = Text-based game.

Also your approach of saving seems to collide with the mud library.. they negate each other and i loose the view tab again (The view tab gives a description of the room your in and stuff)
In response to Bunnie
If it is text based when would Move() be called?
In response to DeathAwaitsU
DeathAwaitsU wrote:
If it is text based when would Move() be called?

Move() is called to move the player like so...
P.Move(mud.LocateRoom(roomnum))


P being the changable thing, like usr etc (duh,)
and the roomnum being where roomid is inputted (i.e 1)
example:
mob/var/roomid // the roomid var
mob
verb
Gotoroom()
var/room= input("What room do you want to go","room") in typesof(/obj/roomids)//gives a list of all the roomids (you should make a roomid a obj)
alert("ok, you are now in room:[O]")
usr.roomid=O//changes the users roomid
mob
verb
say(var/msg as text)
for(var/mob/M in world) /// defines a var for every mob in world
if(M.roomid==usr.roomid)//if M is in the users channel
M <<"[usr] says: [msg]" //M gets the message

//and now a save proc and a verb that saves the room

client/proc/SaveMob() // I'm not that good at making save/load procs so please correct me if I did something wrong
var/firstletter=copytext(src.ckey, 1, 3)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
var/char_ckey = cKey(src.mob.name)

client/proc/LoadMob(char_ckey)
var/firstletter=copytext(src.ckey, 1, 3)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
F["/[ckey]/[char_ckey]"]>>src.mob


I hope that helped you =).

O-matic
In response to O-matic
O-matic wrote:
example:
> [code was here]
>

I hope that helped you =).

I have a similar system to that and it does not load me or players to the last location, it simply returns them to the first room
In response to Bunnie
Bunnie wrote:
I have a similar system to that and it does not load me or players to the last location, it simply returns them to the first room

thats because you don't have a save/load verb. it never got a chance to save
example of a save verb.
client
verb
save()
usr.SaveMob()
usr <<"saved!"

and now for the loading procedure
mob/Login()
..()
var/firstletter=copytext(src.ckey, 1, 3)
if(fexist("players/[firstletter]/[src.ckey].sav"))
src.client.LoadMob()
else
//put here what you desire if the user has no savefile


O-matic

In response to O-matic
O-matic wrote:
Bunnie wrote:
I have a similar system to that and it does not load me or players to the last location, it simply returns them to the first room

thats because you don't have a save/load verb. it never got a chance to save
example of a save verb.
> [Code was here]
>

and now for the loading procedure
> [More code was here]
>


Sorry to ruin your day but I am not that stupid when it comes to coding, It loads the save file it simply locates them to the first room. it brings up their character data, i.e LVL, EXP and crap.
In response to Bunnie
Bunnie wrote:
Sorry to ruin your day but I am not that stupid when it comes to coding, It loads the save file it simply locates them to the first room. it brings up their character data, i.e LVL, EXP and crap.

are you sure that you didn't overide the roomid var somewhere else in a login proc?

O-matic
Page: 1 2