1
0

Added quantity checks to trading so you can't trade over your item count

This commit is contained in:
Emagi 2025-05-06 09:06:58 -04:00
parent 11d46887db
commit c5f09e846d
2 changed files with 8 additions and 1 deletions

View File

@ -9979,6 +9979,8 @@ void Commands::Command_TradeAddItem(Client* client, Seperator* sep)
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items."); client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items.");
else if (result == 3) else if (result == 3)
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items."); client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items.");
else if (result == 253)
client->Message(CHANNEL_COLOR_YELLOW, "You do not have enough quantity...");
else if (result == 254) else if (result == 254)
client->Message(CHANNEL_COLOR_YELLOW, "You are trading with an older client with a %u trade slot restriction...", client->GetPlayer()->trade->MaxSlots()); client->Message(CHANNEL_COLOR_YELLOW, "You are trading with an older client with a %u trade slot restriction...", client->GetPlayer()->trade->MaxSlots());
else if (result == 255) else if (result == 255)

View File

@ -44,7 +44,9 @@ int8 Trade::AddItemToTrade(Entity* character, Item* item, int8 quantity, int8 sl
LogWrite(PLAYER__ERROR, 0, "Trade", "Player (%s) adding item (%u) to slot %u of the trade window", character->GetName(), item->details.item_id, slot); LogWrite(PLAYER__ERROR, 0, "Trade", "Player (%s) adding item (%u) to slot %u of the trade window", character->GetName(), item->details.item_id, slot);
if (slot == 255) if (slot == 255)
slot = GetNextFreeSlot(character); slot = GetNextFreeSlot(character);
if(!quantity)
quantity = 1;
if (slot < 0) { if (slot < 0) {
LogWrite(PLAYER__ERROR, 0, "Trade", "Player (%s) tried to add an item to an invalid trade slot (%u)", character->GetName(), slot); LogWrite(PLAYER__ERROR, 0, "Trade", "Player (%s) tried to add an item to an invalid trade slot (%u)", character->GetName(), slot);
return 255; return 255;
@ -52,6 +54,9 @@ int8 Trade::AddItemToTrade(Entity* character, Item* item, int8 quantity, int8 sl
else if(slot >= trade_max_slots) { else if(slot >= trade_max_slots) {
return 254; return 254;
} }
else if(quantity > item->details.count) {
return 253;
}
Entity* other = GetTradee(character); Entity* other = GetTradee(character);
int8 result = CheckItem(character, item, other); int8 result = CheckItem(character, item, other);