case 2: /*Guild House 1*/ { QueryResult *result = NULL; // Just defining our result as a member of QueryResult result = CharacterDatabase.Query("SELECT taken FROM guildhouses WHERE id='1'"); // Runs the query to select the field uint32 taken = result->Fetch()->GetUInt32(); // Determines whether the field returns 1 (taken) or 0 (free) if(taken==1) // If guild house is taken... { Plr->BroadcastMessage("The house you selected is already taken!"); // Tell the person that selected house is taken return; } else if(taken==0) { } uint32 price=10000000;// uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE); if (currentgold>=price){ int32 newgold = currentgold - price; Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); Plr->SafeTeleport(451,0,15637.739258,-16175.264648,44.936722,6.273752); char msg[1024]; snprintf((char*)msg, 1024, "%s %s", static_cast(Plr)->GetName(), "has chosen Guild House 1!"); sWorld.SendWorldText(msg); sWorld.SendWorldWideScreenText(msg); Plr->BroadcastMessage("You have selected Guild House 1 and recieved the key!"); // Tell the person they selected house CharacterDatabase.Execute("UPDATE guildhouses SET taken='1' WHERE id='1'"); // Update the DB so taken=1, no one else can pick the house // Send to all players of the same guild // NOTE: plr is the guild leader OR replace plr->GetGuildId() with the specific ID of the guild Player * thisPlr; objmgr._playerslock.AcquireReadLock(); HM_NAMESPACE::hash_map::const_iterator itr; for (itr = objmgr._players.begin(); itr != objmgr._players.end(); itr++) { thisPlr = itr->second; if( thisPlr->GetGuildId() == plr->GetGuildId() ) { // Same Faction Item * item = objmgr.CreateItem( 99999 , thisPlr ); thisPlr->GetItemInterface()->AddItemToFreeSlot( item ); } } objmgr._playerslock.ReleaseReadLock(); } } break;