• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] CustomExtendedCosts

Status
Not open for further replies.

Lstm

Respected Member
Yes, edited DBCS .. however I did not want to create a patch for the Brazil players are lazy and do not download patch .. wanted a function to send a message to the player when he tried to buy the item

like this one
http://i.imgur.com/vuSK5ly.png
 

Tommy

Founder
You can do this without editing any dbcs. However, player laziness is a really poor excuse not to do a custom patch (which will be a lot more simple to do).

There's no hooks in Eluna that handles such actions (unless changing VendorBuyItem packet data before sending is an option). You can handle that by adding your own custom checks inside:

ItemHandler.cpp
Code:
[URL="https://github.com/ElunaLuaEngine/ElunaTrinityWotlk/blob/master/src/server/game/Handlers/ItemHandler.cpp#L697"]void WorldSession::HandleBuyItemOpcode(WorldPacket& recvData)[/URL]

And will be handled through the method:

Player.cpp:
Code:
[URL="https://github.com/ElunaLuaEngine/ElunaTrinityWotlk/blob/master/src/server/game/Entities/Player/Player.cpp#L21388"]bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot)[/URL]

Which will have to be done with C++, not Lua as stated above.
 

Tommy

Founder
Well, for example:

Code:
bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot)
{
    // cheating attempt
    if (count < 1) count = 1;

    // cheating attempt
    if (slot > MAX_BAG_SIZE && slot != NULL_SLOT)
        return false;

    if (!IsAlive())
        return false;

    ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item);
    if (!pProto)
    {
        SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, item, 0);
        return false;
    }

[COLOR="#00FF00"]    if (pProto->GetEntry() == 1234 && GetHonorPoints() <= 4323)
    {
        SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, nullptr, nullptr);
        return false;
    }[/COLOR]
 

Lstm

Respected Member
So in case if I add this feature in my Player.cpp will ever work the way I'm needing?
 

Lstm

Respected Member
I've been checking on honor points and found this function I could not add a TC_LOG_ERROR with direction to the value that the search extended cost?
in the case to receive a message with the value that is charged as I showed at the beginning

Code:
    if (crItem->ExtendedCost)
    {
        ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
        if (!iece)
        {
            TC_LOG_ERROR("entities.player", "Player::BuyItemFromVendorSlot: Item %u has wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost);
            return false;
        }

        // honor points price
        if (GetHonorPoints() < (iece->reqhonorpoints * count))
        {
            SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, nullptr, nullptr);
            return false;
        }
 

slp13at420

Mad Scientist
If I'm reading this right the function receives the id for the item via the calling of the function:
Code:
[COLOR="#808080"]
bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 [B][U][COLOR="#FFD700"]item[/COLOR][/U][/B], uint8 count, uint8 bag, uint8 slot)
[/COLOR]

sObjectMgr->GetItemTemplate(item) requires an item id.
So i'm assuming that the variable `item` is the uint32 item id.

So wouldn't you just use:
Code:
[COLOR="#808080"]
	if (([B][U][COLOR="#FFD700"]item[/COLOR][/U][/B] == 1234) && (GetHonorPoints() <= 4323))
[/COLOR]
 
Last edited:

Lstm

Respected Member
I should add in this way?
Code:
if ((item == 1234) && (GetHonorPoints() <= 4323))
    {
        SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, nullptr, nullptr);
        return false;
    }
 

slp13at420

Mad Scientist
I should add in this way?
Code:
if ((item == 1234) && (GetHonorPoints() <= 4323))
    {
        SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, nullptr, nullptr);
        return false;
    }

yes :)


replace
Code:
[COLOR="#808080"]
    if (pProto->GetEntry() == 1234 && GetHonorPoints() <= 4323)
    {
        SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, nullptr, nullptr);
        return false;
    }
[/COLOR]

with
Code:
[COLOR="#808080"]
    if ((item == 1234) && (GetHonorPoints() <= 4323))
    {
        SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, nullptr, nullptr);
        return false;
    }
[/COLOR]
 
Last edited:

Tommy

Founder
If I'm reading this right the function receives the id for the item via the calling of the function:
Code:
[COLOR="#808080"]
bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 [B][U][COLOR="#FFD700"]item[/COLOR][/U][/B], uint8 count, uint8 bag, uint8 slot)
[/COLOR]

sObjectMgr->GetItemTemplate(item) requires an item id.
So i'm assuming that the variable `item` is the uint32 item id.

So wouldn't you just use:
Code:
[COLOR="#808080"]
	if (([B][U][COLOR="#FFD700"]item[/COLOR][/U][/B] == 1234) && (GetHonorPoints() <= 4323))
[/COLOR]

Wasn't paying attention, lal.
 

Lstm

Respected Member
Unfortunately it did not work, does not appear the value of the item as I described in the first image continues in the same way
http://prntscr.com/b0syxz


I wanted to leave it so when the player were to buy and did not have honor the message with the value of the item
http://i.imgur.com/vuSK5ly.png

- - - Updated - - -

I saw something on the Eternal-Wow and I intend to put custom honor to put patches in Brazil any player usually download patch and will be a tremendous headache for it was in need put it this way
 
Status
Not open for further replies.
Top