ITJA
Member
1. item.h — Fonksiyonlar Ekle
Kod:
Kod:
Kod:
Not: GetOwner() null olabilir, koruma yapabilirsin.
Kod:
Bu sayede item envantere her alındığında veya giyildiğinde sahibin adı kayıt olur.
5. char_battle.cpp — PvP ve PvM Öldürme Takibi
Dosyada Attack() içinde BATTLE_DEAD durumunu bul:
Kod:
Kod:
Bu kodları, ilgili victim->IsDead() veya iRet == BATTLE_DEAD bölgelerine yerleştirebilirsin.
6. cmd_general.cpp — Komut Tanımı: /iteminfo
Dosyanın sonuna ekle:
Kod:
Kod:
ACMD(do_iteminfo);
{ "iteminfo", do_iteminfo, 0, POS_DEAD, GM_PLAYER },
Dosya: shop.cpp
Kod:
Kod:
KANIT
Kod:
Code:
class CItem içine private alanlara şunları ekle:[/FONT][/SIZE][/COLOR][/FONT]
[FONT=Quicksand][COLOR=rgb(54, 57, 90)][SIZE=13px][FONT=Monaco]// item.h
private:
std::string m_szCreatorName;
int m_iPvPKills = 0;
int m_iPvMKills = 0;
std::vector<std::string> m_vecOwners;
public:
void SetCreatorName(const std::string& name) { m_szCreatorName = name; }
void AddOwner(const std::string& name);
void AddPvPKill() { ++m_iPvPKills; }
void AddPvMKill() { ++m_iPvMKills; }
void ShowHistory(LPCHARACTER ch) const;
2. item.cpp — Fonksiyonları Tanımla
Kod:
Code:
// item.cpp[/FONT][/SIZE][/COLOR][/FONT]
[FONT=Quicksand][COLOR=rgb(54, 57, 90)][SIZE=13px][FONT=Monaco]void CItem::AddOwner(const std::string& name)
{
if (!name.empty() && (m_vecOwners.empty() || m_vecOwners.back() != name))
{
if (m_vecOwners.size() >= 5)
m_vecOwners.erase(m_vecOwners.begin()); // En eskiyi sil
m_vecOwners.push_back(name);
}
}
void CItem::ShowHistory(LPCHARACTER ch) const
{
ch->ChatPacket(CHAT_TYPE_INFO, "=== [Item Geçmişi] ===");
ch->ChatPacket(CHAT_TYPE_INFO, "İlk Sahibi: %s", m_szCreatorName.c_str());
ch->ChatPacket(CHAT_TYPE_INFO, "PvP Öldürme Sayısı: %d", m_iPvPKills);
ch->ChatPacket(CHAT_TYPE_INFO, "PvM Öldürme Sayısı: %d", m_iPvMKills);
ch->ChatPacket(CHAT_TYPE_INFO, "Önceki Sahipler:");
if (m_vecOwners.empty())
ch->ChatPacket(CHAT_TYPE_INFO, "- [Kayıt Yok]");
else
for (const auto& owner : m_vecOwners)
ch->ChatPacket(CHAT_TYPE_INFO, "- %s", owner.c_str());
}
3. item_manager.cpp — İlk Oluşturulanda Sahip Ata
Kod:
Code:
LPITEM ITEM_MANAGER::CreateItem(...) içinde şu satırları CreateItem()'ın içinde Initialize() ve SetProto()'dan hemen sonra ekle:[/FONT][/SIZE][/COLOR][/FONT]
[FONT=Quicksand][COLOR=rgb(54, 57, 90)][SIZE=13px][FONT=Monaco]// item_manager.cpp
if (item && item->GetOwner())
{
item->SetCreatorName(item->GetOwner()->GetName());
item->AddOwner(item->GetOwner()->GetName());
}
Not: GetOwner() null olabilir, koruma yapabilirsin.
4. char_item.cpp — Item Giyme/Çıkarma Anında Sahip Kaydet
Kod:
Code:
void CHARACTER::SetItem(...) içinde şu satırı ekle:[/FONT][/SIZE][/COLOR][/FONT]
[FONT=Quicksand][COLOR=rgb(54, 57, 90)][SIZE=13px][FONT=Monaco]
if (pItem)
pItem->AddOwner(GetName());
5. char_battle.cpp — PvP ve PvM Öldürme Takibi
Dosyada Attack() içinde BATTLE_DEAD durumunu bul:
PvP
Kod:
Code:
if (victim->IsPC() && GetWear(WEAR_WEAPON))[/FONT][/SIZE][/COLOR][/FONT]
[FONT=Quicksand][COLOR=rgb(54, 57, 90)][SIZE=13px][FONT=Monaco]{
if (LPITEM pWeapon = GetWear(WEAR_WEAPON))
pWeapon->AddPvPKill();
}
PvM öldürme:
Kod:
Code:
if (!victim->IsPC() && GetWear(WEAR_WEAPON))[/FONT][/SIZE][/COLOR][/FONT]
[FONT=Quicksand][COLOR=rgb(54, 57, 90)][SIZE=13px][FONT=Monaco]{
if (LPITEM pWeapon = GetWear(WEAR_WEAPON))
pWeapon->AddPvMKill();
}
Bu kodları, ilgili victim->IsDead() veya iRet == BATTLE_DEAD bölgelerine yerleştirebilirsin.
6. cmd_general.cpp — Komut Tanımı: /iteminfo
Dosyanın sonuna ekle:
Kod:
Code:
ACMD(do_iteminfo)[/FONT][/SIZE][/COLOR][/FONT]
[FONT=Quicksand][COLOR=rgb(54, 57, 90)][SIZE=13px][FONT=Monaco]{
LPITEM item = ch->GetWear(WEAR_WEAPON);
if (!item)
{
ch->ChatPacket(CHAT_TYPE_INFO, "Üzerinizde silah bulunmamaktadır.");
return;
}
item->ShowHistory(ch);
}
7.
Kod:
ACMD(do_iteminfo);
8. cmd_general.cpp veya cmd.cpp Komut Listesine Ekle
Kod:{ "iteminfo", do_iteminfo, 0, POS_DEAD, GM_PLAYER },
Dosya: shop.cpp
Fonksiyon: CShop::Buy(...) içinde, item oluşturulduktan hemen sonra:
Şu kısmı bul:
Kod:
Code:
item = ITEM_MANAGER::instance().CreateItem(r_item.vnum, r_item.count);[/FONT][/SIZE][/COLOR][/FONT]
[FONT=Quicksand][COLOR=rgb(54, 57, 90)][SIZE=13px][FONT=Monaco]if (!item)
return SHOP_SUBHEADER_GC_SOLD_OUT;
Hemen altına şunu EKLE:
Kod:
Code:
if (!m_pkPC && item)[/FONT][/SIZE][/COLOR][/FONT]
[FONT=Quicksand][COLOR=rgb(54, 57, 90)][SIZE=13px][FONT=Monaco] item->AddOwner(ch->GetName()); // Sadece NPC shop ise geçmişe ekle
KANIT