mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 02:20:27 +00:00
fix(Core/Command): additem checks (#2898)
* Add check if the player has 0 items to be destroyed * Add check if the player has less than items trying to be destroyed
This commit is contained in:
@@ -1466,8 +1466,23 @@ public:
|
||||
// Subtract
|
||||
if (count < 0)
|
||||
{
|
||||
playerTarget->DestroyItemCount(itemId, -count, true, false);
|
||||
handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget).c_str());
|
||||
if (!playerTarget->HasItemCount(itemId, 0))
|
||||
{
|
||||
// output that player don't have any items to destroy
|
||||
handler->PSendSysMessage(LANG_REMOVEITEM_FAILURE, handler->GetNameLink(playerTarget).c_str(), itemId);
|
||||
}
|
||||
else if (!playerTarget->HasItemCount(itemId, -count))
|
||||
{
|
||||
// output that player don't have as many items that you want to destroy
|
||||
handler->PSendSysMessage(LANG_REMOVEITEM_ERROR, handler->GetNameLink(playerTarget).c_str(), itemId);
|
||||
}
|
||||
else
|
||||
{
|
||||
// output successful amount of destroyed items
|
||||
playerTarget->DestroyItemCount(itemId, -count, true, false);
|
||||
handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget).c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user