Skip to content
This repository has been archived by the owner on Dec 26, 2021. It is now read-only.

Commit

Permalink
Fixed The Dupe Command Again (#4434)
Browse files Browse the repository at this point in the history
Fixed the offhand option in dupe. (didn't do anything before)
  • Loading branch information
NRGJobro authored Aug 19, 2021
1 parent 4307e66 commit d153833
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions Horion/Command/Commands/DupeCommand.cpp
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;
}

0 comments on commit d153833

Please sign in to comment.