Bodyguardd 1
Bodyguardd
kralhakan2009 1
kralhakan2009
Vahsi Uzman 1
Vahsi Uzman
sau reng 1
sau reng
Reklam vermek için turkmmo@gmail.com

Basit bir blok kod

  • Konuyu başlatan Konuyu başlatan OwnerShip
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 14
  • Görüntüleme Görüntüleme 2K
5.00 yıldız(lar) 1 Değerlendirme Değerlendirenler
return m_map_dwMobKillCount.contains(dwVnum);
C++:
#include <iostream>
#include <unordered_map>

class CHARACTER_MANAGER {
private:
    // A private member variable using an unordered_map to store mob kill counts with DWORD keys
    std::unordered_map<DWORD, int> m_map_dwMobKillCount;

public:
    // Other member functions can be added here

    // Function to check if a mob with the given Vnum has been killed before
    bool IsBeenKilledBefore(DWORD dwVnum) const {
        // Define an iterator type for the map
        using MapIteratorType = std::unordered_map<DWORD, int>::const_iterator;

        // Find the iterator for the given dwVnum in the map
        MapIteratorType it = m_map_dwMobKillCount.find(dwVnum);

        // Check if the iterator points to the end of the map, indicating the element was not found
        if (it == m_map_dwMobKillCount.end())
            // Return false if the element is not found
            return false;

        // Return true if the element is found
        return true;
    }
};

int main() {
    // Example usage
    CHARACTER_MANAGER characterManager;

    // Adding some mob kill counts for demonstration
    characterManager.IsBeenKilledBefore(1001);  // Assume mob with Vnum 1001 has been killed

    // Checking if a mob with Vnum 1001 has been killed before
    if (characterManager.IsBeenKilledBefore(1001)) {
        std::cout << "Mob with Vnum 1001 has been killed before." << std::endl;
    } else {
        std::cout << "Mob with Vnum 1001 has not been killed before." << std::endl;
    }

    // Checking if a mob with Vnum 2002 has been killed before
    if (characterManager.IsBeenKilledBefore(2002)) {
        std::cout << "Mob with Vnum 2002 has been killed before." << std::endl;
    } else {
        std::cout << "Mob with Vnum 2002 has not been killed before." << std::endl;
    }

    return 0;
}
 

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst