chore(PlayerScript/Hook) : Add CanSetTradeItem Hook in PlayerScript (#18583)

* chore(PlayerScript/Hook) : Add CanSetTradeItem Hook in PlayerScript

* Allowing non traded slots

* Fix typo and codestyle
This commit is contained in:
Elmsroth
2024-03-27 01:28:37 +01:00
committed by GitHub
parent 5b8bc792b8
commit b1cf830009
4 changed files with 33 additions and 0 deletions

View File

@@ -708,6 +708,15 @@ void WorldSession::HandleSetTradeItemOpcode(WorldPacket& recvPacket)
return;
}
// PlayerScript Hook for checking traded items if we want to filter them in a custom module
if (!sScriptMgr->CanSetTradeItem(_player, item, tradeSlot))
{
// Do not send TRADE_STATUS_TRADE_CANCELED because it will cause double display of "Transaction canceled" notification
// On the trade initiator screen
SendTradeStatus(TRADE_STATUS_CLOSE_WINDOW);
return;
}
my_trade->SetItem(TradeSlots(tradeSlot), item);
}