Is it possible to prohibit a same character name when trying to start a game with name input at start of the game?
Ex: aaa is already saved , then a new game with aaa name again cannot be used at another new game.
Prohibiting same character name
● ARCHIVED · READ-ONLY
-
-
This sounds like a good idea... One could also use such a system to prevent players from giving inappropriate names to characters! :D
-
well to do that you'd need to access every save file to determine the name of the actor in the files... it's doable
-
I initially thought that, but there's a much easier way. Give me a minute ...
-
I'm also thinking of just making another file that saves already used names, but then IDK how to remove an entry once a save file is deleted... so well, let's wait for your other idea. :)
-
Well, it was another save file, just as you say. How do you delete save files? You'd have to do that through the file system, as RM doesn't have a way to do it.
Here's a script that will work, but in testing I realised a shortcoming ... this is updated when you GIVE the character the name - even if you never actually save the game. So start a game, name your character, exit to title without saving, start a new game, you can't use the same name.
However I'd need more information from you to fix that - specifically, what actor/s are they able to name and you want to keep unique? Do you only have one actor in the party? Or do you have several, but can they only name one? Or can they name several?
Anyway, here's what I've already done, if you want to play around with it. Saving the names only when the game is saved would require a few changes.
So you'd use it something like this:Spoilermodule DataManager class << self alias shaz_unique_names load_normal_database end def self.load_normal_database shaz_unique_names begin $data_names = load_data("PC_Names.rvdata2") rescue $data_names = [] end end def self.save_names File.open("PC_Names.rvdata2", "wb") do |file| Marshal.dump($data_names, file) end endendclass Game_Interpreter def actor_name_used?(actor_id) $data_names.include?($game_actors[actor_id].name) end def save_actor_name(actor_id) $data_names.push($game_actors[actor_id].name) DataManager.save_names endend
Code:where actor_name_used?(1) and save_actor_name(1) use the id of the actor whose name you changed.Text: Please choose a name for your actorLoop Name Input Processing: Eric, 10 characters Conditional Branch: Script: actor_name_used?(1) Text: Sorry, that name has already been used before. Please choose one that's never been used Else Script: save_actor_name(1) Break Loop Branch EndRepeat AboveControl Self Switch: A = ON -
I was wondering that like on MMORPG's if the user enters a name that is already entered and saved it'll prompt that is already taken, you will enter a different name that's it.
-
Soulpour777 has a script that does what you want, in some way:
http://infinitytears.wordpress.com/2014/02/09/soul-engine-ace-actor-banned-names-script/
To start with, when Eric's name is already entered, you can ban the name Eric so the player won't be able to enter that. -
You still didn't state how many characters there are in your party and if you're allowing all of them to be named.
Also don't assume that everyone has played MMORPGs. They haven't, so they'd really not have much of an idea of what you mean. -
Only one character on the game, if saved, then if you create new game you cant enter the same name again.
-
Alright. I'll see if I can fix that script for you today.
-
Thank you sir :D
-
Here you go - new version. Now you don't need to pass the actor id, as it will always be 1. If you were going to have more than 1 actor I'd make it more elegant.
This will NOT make a name available again if you save over an existing save file - so if actor 1 is Eric in your save file 1, then you play a new game with actor 1 named Ernest and save it into save slot 1, both Eric and Ernest will be unavailable.Spoilermodule DataManager class << self alias shaz_unique_names_load_normal_database load_normal_database alias shaz_unique_names_save_game_without_rescue save_game_without_rescue end def self.load_normal_database shaz_unique_names_load_normal_database begin $data_names = load_data("PC_Names.rvdata2") rescue $data_names = [] end end def self.save_game_without_rescue(index) save_name return shaz_unique_names_save_game_without_rescue(index) end def self.save_name $data_names.push($game_actors[1].name) File.open("PC_Names.rvdata2", "wb") do |file| Marshal.dump($data_names, file) end endendclass Game_Interpreter def actor_name_used? $data_names.include?($game_actors[1].name) endend -
wow..In simple the only way is erase pc_data for rehave the original name?
-
Not really. If you REALLY want them to be able to use the same name, you'd just do a Script call with $data_names.delete(name) and it'd get rid of it. The only thing stopping you using the same name is the event commands that come after the Name Input. The script does nothing but record which ones have been used.
If the player really wants to use the same name again, they'd have to erase the pc_names.rvdata2 file.
If you want it to re-allow the name when you delete or save over an existing save file, then I think you'd either have to change it again so if you're saving in a slot that's already used, it'll load that file into a temporary variable, "give back" the name used, and record the name used in the new save slot. But that doesn't cater for files being erased through the file system. The only way to cover that is to - at some point (launch the game, save a file, whatever) - load EVERY save file, grab the names used into a variable, and use that in the game. If you did that, there'd be no reason to even save it, because you're just going to rebuild it again next time. But I'd say you'd probably do that on launching, because if you have a lot of save files or they're very big, you don't want the player sitting there for ages waiting for it to run. -
-
Oh, sorry - I noted that I had to tell you that, and then I forgot.
Because I've changed the point where it's saved, you no longer need to tell it to save - I've removed the save_name method. That happens automatically when you do save.
Instead, you only need to do the check to see if the name exists, but you don't need to pass in any argument. And as you've said you only have one actor, it's going to use that Actor 1 all the time. If you ever wanted to have more than one, the script would need to be changed.
It's not elegant, but it does the job, and something more flexible would take longer to create :) (Having said that, if you ever DO decide to add more actors, just post back here and I'll make the necessary changes). -
Can you post a screenie so I can do what you've changed :D
-
Text: Please choose a name for your actor
Loop
Name Input Processing: Eric, 10 characters
Conditional Branch: Script: actor_name_used? <<< this line has changed
Text: Sorry, that name has already been used before.
Please choose one that's never been used
Else
Break Loop <<<<<< removed the save line before here
Branch End
Repeat Above
Control Self Switch: A = ON -
It works like a charm now :D Thank you :)
