uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type) { // need fix it! QueryResult *result = CharacterDatabase.PQuery("SELECT arenateamid FROM arena_team_member WHERE guid='%u'", GUID_LOPART(guid)); if(result) { bool found = false; // init id to find the type of the arenateam uint32 id = (*result)[0].GetUInt32(); do { QueryResult *result2 = CharacterDatabase.PQuery("SELECT type FROM arena_team WHERE arenateamid='%u'", id); if(result2) { uint8 dbtype = (*result2)[0].GetUInt32(); delete result2; if(dbtype == type) { // if the type matches, we've found the id found = true; break; } } } while(result->NextRow()); delete result; if(found) return id; } // no arenateam for the specified guid, return 0 return 0; }