This repository has been archived by the owner on Dec 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed The Dupe Command Again (#4434)
Fixed the offhand option in dupe. (didn't do anything before)
- Loading branch information
Showing
1 changed file
with
8 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,38 @@ | ||
#include "DupeCommand.h" | ||
|
||
DupeCommand::DupeCommand() : IMCCommand("dupe", "Duplicates the item in hand", "<count> <mode: give / offhand : 1/0>") { | ||
registerAlias("d"); | ||
} | ||
|
||
DupeCommand::~DupeCommand() { | ||
} | ||
|
||
bool DupeCommand::execute(std::vector<std::string>* args) { | ||
C_PlayerInventoryProxy* supplies = g_Data.getLocalPlayer()->getSupplies(); | ||
C_Inventory* inv = supplies->inventory; | ||
auto transactionManager = g_Data.getLocalPlayer()->getTransactionManager(); | ||
|
||
C_Inventory* inv = supplies->inventory; | ||
int selectedSlot = supplies->selectedHotbarSlot; | ||
C_ItemStack* item = inv->getItemStack(selectedSlot); | ||
|
||
int count = item->count; | ||
bool isGive = true; | ||
|
||
if (args->size() > 1) | ||
item->count = assertInt(args->at(1)); | ||
if (args->size() > 2) | ||
isGive = static_cast<bool>(assertInt(args->at(2))); | ||
|
||
if (isGive) { | ||
int slot = inv->getFirstEmptySlot(); | ||
|
||
C_InventoryAction* firstAction = nullptr; | ||
C_InventoryAction* secondAction = nullptr; | ||
|
||
firstAction = new C_InventoryAction(0, item, nullptr, 507, 99999); | ||
|
||
transactionManager->addInventoryAction(*firstAction); | ||
|
||
inv->addItemToFirstEmptySlot(item); | ||
} else | ||
} else { | ||
C_InventoryAction* pp = nullptr; | ||
pp = new C_InventoryAction(0, item, nullptr, 507, 99999); | ||
transactionManager->addInventoryAction(*pp); | ||
g_Data.getLocalPlayer()->setOffhandSlot(item); | ||
|
||
} | ||
if (args->size() > 1) | ||
item->count = count; | ||
|
||
clientMessageF("%sSuccessfully duplicated the item!", GREEN); | ||
clientMessageF("%sSuccessfully duplicated the item!", GREEN); | ||
return true; | ||
} |