Hi,
I'm just wondering if it's possible to check if the players name is in use when they try to name their character. Like even check the save files to see if it's being used.
The save files are saved by ckey, so I can't just check the file names, I need to return the name of the mob stored in the save file without actually loading the mob from the save file.
1
2
ID:159625
Feb 7 2009, 1:06 am
|
|
Feb 7 2009, 2:01 am
|
|
Put names in a global list, save the list on world/Del() and load it on world/New()
|
Sprin wrote:
The save files are saved by ckey, so I can't just check the file names, You could technically loop through every savefile and read the name, though that would be pretty redundant to do multiple times if you have a lot of saves. You could do that once in world/New() and store the data into a list, or do it like Falacy outlined. The difference is which savefile(s) the data is initially fetched from. Or, if the file names are the ckeyed character names, you could use those. It's of course important to actually compare ckey versions of names when using saves named like that, since if you don't, people could make a character "@Bob@" even if a char "Bob" already exists, and those chars would have conflicting save files and overwrite eachother. |
In response to Falacy
|
|
That's what I was going to do, and I just realised now that I can remove names from the list whenever someone creates a new character. But how do I get the mob.name from the save file without loading the savefile mob into a new mob? Or is that the only way I can get it? There's no Savefile["mob/name"] or something I can use?
|
In response to Sprin
|
|
Actually there is :).
var/savefile/mySavefile = new("[whatever].sav") (Note: Haven't tested that) |
In response to Sprin
|
|
Sprin wrote:
That's what I was going to do, and I just realised now that I can remove names from the list whenever someone creates a new character. But how do I get the mob.name from the save file without loading the savefile mob into a new mob? Or is that the only way I can get it? There's no Savefile["mob/name"] or something I can use? There's no reason to load EVERY save file in the server, that's just a waste of time and processing power. As I already said, you just save all the names to one list, and then save and load that list. |
In response to Falacy
|
|
And when they overwrite their character? I need to know the name to remove, it wouldn't be for every savefile, just the one who's getting overwritten
|
In response to Sprin
|
|
Sprin wrote:
And when they overwrite their character? I need to know the name to remove, it wouldn't be for every savefile, just the one who's getting overwritten Well then, I'm not sure how it saves by default, but you can always just add a custom line to store their name. ["name"]<<mob.name ["name"]>>Name2Delete |
In response to Immibis
|
|
You can get the name of a mob out just by using "name"? Hmm thanks I'll try that out
|
In response to Sprin
|
|
If you use:
var/savefile/sf = new("[whatever].sav") then you should be able to get the mob's name with sf["name"] If you use: var/savefile/sf = new("[whatever].sav") Then I imagine the syntax would be something like sf["mob/name"] |
In response to Immibis
|
|
Immibis wrote:
> var/savefile/sf = new("[whatever].sav") is that even possible o.O |
In response to Falacy
|
|
Yes it is possible.
That calls the Write() proc, which throws in every var that isn't temp or constant. This can be a good thing if you keep your vars tidy, but if you have any references inside your savefile it will royally screw things up. -.-' |
In response to Falacy
|
|
I thought you had several games, and you're not sure if saving a mob instance into a savefile is possible? >_> Why wouldn't it? Anyway, you could always read about it in the DM Reference & Guide rather than wondering.
|
In response to AJX
|
|
Unless, of course, you prevent those vars from being saved by marking them as tmp, etc. Which is a good idea to do with most vars that hold refs to other atoms.
|
In response to Kaioken
|
|
Kaioken wrote:
I thought you had several games, and you're not sure if saving a mob instance into a savefile is possible? >_> Why wouldn't it? Anyway, you could always read about it in the DM Reference & Guide rather than wondering. I never save entire mobs, I only write the data that I'll be needing at load time. |
In response to Falacy
|
|
That's technically what object saving automatically does, provided you mark vars you don't need saved as such.
|
In response to Kaioken
|
|
Kaioken wrote:
That's technically what object saving automatically does, provided you mark vars you don't need saved as such. I use a decent amount of built-in variables that would be a waste of space to save, like icon. |
In response to Falacy
|
|
Normally it wouldn't save icon if it was at its original value, but you can fully control object saving by overriding Write() anyway, though that's getting pretty off-topic.
|
In response to Kaioken
|
|
Kaioken wrote:
Normally it wouldn't save icon if it was at its original value... That's my point. Even simple games that have different races/classes would use different icons. Unless they have a separate mob for each of them. ...but you can fully control object saving by overriding Write() anyway, though that's getting pretty off-topic. You can overwrite write to not save things? I guess you could overwrite the proc in its entirety, but that would be the same thing I do now in my own save procs. |
In response to Falacy
|
|
Falacy wrote:
Unless they have a separate mob for each of them. Which I'd think is pretty common. Though I'm not sure if it insists on saving such icons already in the RSC file in their entirety; that would be silly and something to change if it's so. You can overwrite write to not save things? Since you can do anything you want in the proc, you can trick it into doing anything, from not saving a var, to saving it as a different value (ie you could save a text string identifier to an object [f.ex. a guild datum] instead of letting the reference [and so the object] save), or just outputting "poo" to the world or log (of course). I guess you could overwrite the proc in its entirety, but that would be the same thing I do now in my own save procs. If it's essentially like Write(), why not just use that? Or maybe it's different (?). Commonly people have something like this- mob/proc/Save(fname) ...whereas redefining Write() is close to this: mob/Write(F) Generally if you use the built-in object saving you only need to do a little work to exclude saving vars (which for your own vars amounts to adding "tmp"), not save existing ones. |
1
2