06-14-2021, 09:16 AM
7 hours ago, Dimaflash said:
Hi guys. This is my code for it. Checking the type of weapon. Whether the item is a weapon or not =).
- in doFuncItem.cpp
void do_ItemWear(CPC* ch, CNetMsg::SP& msg)
after:
case WEARING_ACCESSORY3:
{
int nOldState = ch->GetPlayerState();
ch->ResetPlayerState(PLAYER_STATE_SUPPORTER);
int i;
for (i = WEARING_ACCESSORY1; i <= WEARING_ACCESSORY3; i++)
{
if (ch->m_wearInventory.wearItemInfo[i])
{
if (ch->m_wearInventory.wearItemInfo[i]->m_itemProto->getItemIndex() == 1912)
ch->SetPlayerState(PLAYER_STATE_SUPPORTER);
}
}
if (nOldState != ch->GetPlayerState())
{
CNetMsg::SP rmsg(new CNetMsg);
ExPlayerStateChangeMsg(rmsg, ch);
ch->m_pArea->SendToCell(rmsg, ch, true);
}
}
break;
adding 1 more case:
case WEARING_WEAPON: // DmitryGreen
{
if (ch->m_wearInventory.wearItemInfo[WEARING_WEAPON]->m_itemProto->getItemTypeIdx() != ITYPE_WEAPON)
{
LOG_ERROR("HACKING? Error with slot Weapon charIndex[%d]", ch->m_index); // fix Weapon/Pet slot
ch->m_desc->Close("Invalid type WEAPON");
if (!ch->m_wearInventory.DelNormalItem(2))
ch->m_wearInventory.RemoveItem(2);
}
}
break;
Really nice!
I've also added this line of code:
after:
void do_ItemWear(CPC* ch, CNetMsg::SP& msg)
add:
if (packet->wearPos != item->m_itemProto->getItemWearing())
{
CNetMsg::SP rmsg(new CNetMsg);
ResponseClient::ItemWearMsg(rmsg, ResponseClient::WEAR_ERR_INVALID_POS);
SEND_Q(rmsg, ch->m_desc);
return;
}

