diff options
| author | Michael <martin.dev.446@gmail.com> | 2019-12-28 16:58:18 -0500 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-12-19 15:46:20 +0100 |
| commit | 72e61625bca5a8420fc76666db3481673b180a69 (patch) | |
| tree | b38f9f028c45104e6fc1a270ebf3d70574b3c305 /src/server/scripts/Commands | |
| parent | bfc8889d544925182e2ddc4617ac5301c15745ae (diff) | |
additional output for additem command (#24006)
* additional output for additem command
when removing items with additem:
if the user provides an amount too large of a negative amount, the command will now output the amount of items that could not be destroyed.
* renamed sql file to hopefully avoid conflicts
* added clarification to failure string
* changed unneeded else if condition to else
* code style; braces
* Update and rename 9999_99_99_99_world.sql to 2019_12_28_01_world.sql
(cherry picked from commit 6b19f4a0ab1f77ea969a080a6eea0379baf9f8df)
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 7b74a54774f..af77c7466d2 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1333,8 +1333,27 @@ public: // Subtract if (count < 0) { - playerTarget->DestroyItemCount(itemId, -count, true, false); - handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget).c_str()); + uint32 destroyedItemCount = playerTarget->DestroyItemCount(itemId, -count, true, false); + + if (destroyedItemCount > 0) + { + // output the amount of items successfully destroyed + handler->PSendSysMessage(LANG_REMOVEITEM, itemId, destroyedItemCount, handler->GetNameLink(playerTarget).c_str()); + + // check to see if we were unable to destroy all of the amount requested. + uint32 unableToDestroyItemCount = -count - destroyedItemCount; + if (unableToDestroyItemCount > 0) + { + // output message for the amount of items we couldn't destroy + handler->PSendSysMessage(LANG_REMOVEITEM_FAILURE, itemId, unableToDestroyItemCount, handler->GetNameLink(playerTarget).c_str()); + } + } + else + { + // failed to destroy items of the amount requested + handler->PSendSysMessage(LANG_REMOVEITEM_FAILURE, itemId, -count, handler->GetNameLink(playerTarget).c_str()); + } + return true; } |
