E.G. If key 1 makes there name Jeff then key 2 cant make there name Jeff.
Here is what I got so far:
world |
ID:158465
Aug 20 2009, 12:53 am
|
||
Basically I have a basic login system that is buggy as you can probally notice. If you can point out some bugs and also help me by telling me how to create a Auto-Save every so long and also make it only allow one person to have the name desired.
E.G. If key 1 makes there name Jeff then key 2 cant make there name Jeff. Here is what I got so far:
| ||
Personally I'd do it like this :
Like I said previously on chatters, no usr in procs. If you're not going to call Load/New/Delete procs anywhere else, you could just define them in the Click() procs of the turfs. One more thing, you shouldn't save a mob's icon and overlays, you should restore them upon login so you don't end up with a big savefile size. | ||
To save, you should not call Write() directly, but rather you should output the mob to the savefile. Instead of src.Write(F) you would use F << src. You will also have to be prepared to read it properly as well: simply load the mob from the savefile into any variable, and it should log you into the mob. IE:
Your old mob will remain and should be deleted, though, if it wouldn't automatically be picked up by the garbage collector. Anyway, you didn't address the issue of preventing duplicate names. To do that, you would do something like this:
That will maintain a list of used names. By only adding to it in mob/Write() instead of when we create a character, we prevent the case where a player is created, but never saved (due to the game crashing, perhaps), and having the name taken up when there is no character with that name. Alternatively, if you only saved in world/Del(), if the game crashed then names of players that were created and saved before the crash would be lost. It's up to you to prevent somebody picking a name that's already in the names list, but that's simple anyway. | |||
I actually didn't know you could load a mob like that, nice to know.
But is there something wrong with calling Write() or Read() directly ? | |
Yes: it does not properly resolve references to the mob, which can result in the proc crashing upon load under certain not-uncommon circumstances, such as simply having an obj in contents with a variable pointing to the mob (IE: an owner variable).
| |
Hmm Garthor you totally lost me can you explain more simpler and throughly please.
I sort of get the duplicate name one but why adress it in save when it would be easier to do it in the create I don't want two people with the same name in the game or it will confuse everyone and also will mess the saves up. The first bit your saying not you call the Write directly so can give me an example of both the Write and Read procs being called proply. | |
I already explained why: if you reserve the name the moment the character is created, then if the character never gets saved, that name is permanently lost.
And I already gave an example of how to save and load properly:
| ||
ahhh-ok sorry ill post what I go so far in a sec and maybe we can look for bugs and ways to improve it :D Ahh got confused half way through when errors start poping up
| ||
No joke ive been at my computer all day yesterday waiting for a reply Ive been refreshing like every 15 mins and no help :( that makes me sad please someone help me im ready to help myself.