EOSERV Forum > Programming > I need help with some sql commands/eoserv related?
Topic is locked.
Page: << 1 >>
I need help with some sql commands/eoserv related?
Author Message
Post #196039 I need help with some sql commands/eoserv related?

I'm trying to get the account name from a character name? I know I can do it on my own...but I just plain suck with sql syntax and hope 1 of you guys could just shoot me a quick snippet.. so I dont have to waste a few hours on this 1 line of code!


I think it boils down to this

//select account from character name

//select all characters from acct name

//delete all characters from acct name

//delete acct name


9 years, 34 weeks ago
Post #196041 Re: I need help with some sql commands/eoserv related?

std::string name = "blah"

Database_Result res = this->world->db.Query("SELECT `account` FROM `characters` WHERE `name` = '$'", name.c_str());

std::string account = GetRow<std::string>(row, "account");

this->world->db.Query("DELETE FROM `characters` WHERE `account` = '$'", account.c_str());

this->world->db.Query("DELETE FROM `accounts` WHERE `username` = '$'", account.c_str());


Also, you might want to kick the player off if they're online before this happens so they dont end up logging off later and having the character saved back to the database with no account linked to it anymore.

I would put this above the code as well:


Character * victim = 0;

UTIL_FOREACH(this->world->characters, character)

{

if(character->name = name)

victim = character;

}


if(victim) this->world->Kick(0, victim, false);

9 years, 34 weeks ago
Post #196046 Re: I need help with some sql commands/eoserv related?

Thank you for your quick and accurate response! Here is what I came up with compiled in an older source.

https://tehsausage.com/paste/delete-chars-acct-command

9 years, 34 weeks ago
Page: << 1 >>
Topic is locked.
EOSERV Forum > Programming > I need help with some sql commands/eoserv related?