O.k I've been looking through the code to try and find were the character is created.
CreateCharacterScreen --> send off request with name -->ClientPacket --> sends off name and request to server --> ServerPacketHandler --> receives request and checks for valid account or to see if he's logged in. If everything is fine call the function to create the character (Server.CreateAccountCharacter(conn, name);
however were in that function does it make the character? it attempts to make it and if it fails send back to the client but I can't see were it makes the character with the name specified.
any help would be nice
O.k I've think I've done everything now however when I try and make the character the server stops on the line
var retReader = cmd.ExecuteReader();
I think its because the value I'm trying to stick in the database is an int.
const string _queryStr = "SELECT CreateUserOnAccount(@accountName, @userName, @characterID, @career)";
I'm wondering is that right as career is an int, I have no idea as all the other variables are Strings (except characterID) so I have no clue if I was suppose to convert it at any point during dbQuary file.
please help again Spodi
so close to implanting classes to my game.
Edit
I forgot to say in mysql the column career is an int.
You should have the career set to some default value, then add another database function to change the career. This way, setting up the career-specific values is easier (such as some starting items and stuff), and you'll also automatically get support for the ability to change careers (even if just as an admin command).
Going this route, you'd want the initial career value to be some "invalid" career value so people don't accidentally get stuck without their career getting set at all.
isn't setting it up so default value in mysql is 0 and changing the career when you make a character enough? must say you've kind of lost me
edit
and were should I be looking for that function but for something like names so I can see how its done.. (I must say it seems like I'm a lazy bastard when it comes to ctrl + F >.<)
Yeah, that would work, but then what if you want certain careers to start out with different items? All of that would end up having to be added into the CreateUserOnAccount function. Not like that won't work, it'd just get messy. Its your game, so your call. ![]()
thanks for the guilt trip ^_^ I'll start looking at how its done with the name function QQ.
Sorry for double posting, at the moment I'm trying to do my original way first do I can learn the source more, however I'm currently stuck (again). I've edited the create on user account unction to accept careers however when I try and run the game it claims that The function should only take 3 parameters instead of 4, I've checked the code over and over again but I can't see anything wrong with it. Is there another section of the project in Which you should clarify how many parameters it should take (except for when you call the function its self
Yeah - in the function declaration. Just like any other language.
FUNCTION `CreateUserOnAccount`(accountName VARCHAR(50), characterName VARCHAR(30), characterID INT) RETURNS varchar(100) CHARSET latin1 BEGIN DECLARE character_count INT DEFAULT 0; DECLARE max_character_count INT DEFAULT 3; DECLARE is_id_free INT DEFAULT 0; DECLARE is_name_free INT DEFAULT 0; DECLARE errorMsg VARCHAR(100) DEFAULT ""; DECLARE accountID INT DEFAULT NULL; SELECT `id` INTO accountID FROM `account` WHERE `name` = accountName; IF ISNULL(accountID) THEN SET errorMsg = "Account with the specified name does not exist."; ELSE SELECT COUNT(*) INTO character_count FROM `character` WHERE `account_id` = accountID; SELECT `max_characters_per_account` INTO max_character_count FROM `game_constant`; IF character_count > max_character_count THEN SET errorMsg = "No free character slots available in the account."; ELSE SELECT COUNT(*) INTO is_id_free FROM `character` WHERE `id` = characterID; IF is_id_free > 0 THEN SET errorMsg = "The specified CharacterID is not available for use."; ELSE SELECT COUNT(*) INTO is_name_free FROM `user_character` WHERE `name` = characterName; IF is_name_free > 0 THEN SET errorMsg = "The specified character name is not available for use."; ELSE INSERT INTO `character` SET `id` = characterID, `name` = characterName, `account_id`= accountID; END IF; END IF; END IF; END IF; RETURN errorMsg; END;
Just look in db.sql to see the raw function.
oops I now know were I've gone wrong the entire time I thought you meant it as in netgore.db rather then the .sql file. Well you learn something new every day.
Its in the database - function CreateUserOnAccount. The idea was that so you could easily add character creation to web sites.