RBAC.hRBAC_PERM_COMMAND_CUSTOMINFO = 799,cs_misc.cpp{ "showaccount", rbac::RBAC_PERM_COMMAND_CUSTOMINFO, false, &HandleNewCommand, "", NULL },static bool HandleNewCommand(ChatHandler * handler, char const* args) { Player* target; ObjectGuid targetGuid; std::string targetName; QueryResult resulta = CharacterDatabase.PQuery("SELECT Info FROM characterinfo WHERE acc='%s'", targetGuid); handler->PSendSysMessage("Info: %s", resulta); return true; }
QueryResult result = WorldDatabase.Query("SELECT * FROM hm_waves"); if (result) { do { Field *fields = result->Fetch(); int waveid = fields[0].GetInt32(); creature.id = fields[1].GetInt32(); } while (result->NextRow()); }
RBAC.hRBAC_PERM_COMMAND_CUSTOMINFO = 799,cs_misc.cpp{ "showaccount", rbac::RBAC_PERM_COMMAND_CUSTOMINFO, false, &HandleNewCommand, "", NULL },static bool HandleNewCommand(ChatHandler* handler, char const* args) { Player* target; ObjectGuid parseGUID = ObjectGuid::Create<HighGuid::Player>(strtoull(args, nullptr, 10)); std::string targetName; if (ObjectMgr::GetPlayerNameByGUID(parseGUID, targetName)) { target = ObjectAccessor::FindPlayer(parseGUID); targetGuid = parseGUID; } else if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; QueryResult resulta = CharacterDatabase.PQuery("SELECT Info FROM characterinfo WHERE acc=%u", targetGuid); if (resulta) { handler->PSendSysMessage("Info: %s", (*resulta)[0].GetString()); return true; } return false; }
static bool HandleNewCommand(ChatHandler* handler, char const* args){ // get world session WorldSession* session = handler->GetSession(); // make sure it exists. It doesnt if this command is called from the console if (!session) return false; // get the player that invoked this command Player* player = session->GetPlayer(); if (!player) return false; // get the player's target and make sure its a player Player* target = player->GetSelectedPlayer(); if (!target) return false; // make a database query with the account ID // dont use strings to identify things :) And you can get the name from auth database by the account id anyways if needed QueryResult result = CharacterDatabase.PQuery("SELECT `info` FROM `characterinfo` WHERE `accountid` = %u", target->GetSession()->GetAccountId()); if (!result) // always make sure a row was returned before actually using it { handler->SendSysMessage("Info: no info"); } else { // get the info string from the query. the selected values are indexed starting from 0, so info is at position 0 std::string info = result->Fetch()[0].GetString(); handler->PSendSysMessage("Info: %s", info.c_str()); // using c_str() to convert the std::string into const char* which is what PSendSysMessage, printf and other need. } // command succeeded, return true to not show syntax info or error message return true;}