EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Support::Windows Servers (https://www.eqemulator.org/forums/forumdisplay.php?f=587)
-   -   Prevent Merchant From Buying (https://www.eqemulator.org/forums/showthread.php?t=41464)

The_Beast 08-03-2017 09:13 PM

Prevent Merchant From Buying
 
This is an old snippet of code I copied from somewhere on these forums, long ago. (I don't remember where)
I never got around to trying it out until now, but I just tested it out and it works awesome. I simply set the
(vendor->GetSTA() == 999) which I set the STA to 999 on the custom merchant NPC. This comes in real
handy for a custom vendor that you don't want players selling all their vendor trash to and making it hard for
others to shop. A client will still get that infamous message "I will give you xxx plat....", but also get a msg,
"I am not interested in that....." So whoever wrote this, Thank YOU !!!

In client_packet.cpp
Code:

// EDIT NOTE: add the parts inbetween //CUSTOM Will STOP a merchant from buying (with GetSTA value)
 
 
 void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
 {
        if (app->size != sizeof(Merchant_Purchase_Struct)) {
@@ -12373,9 +12374,24 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
 
        Mob* vendor = entity_list.GetMob(mp->npcid);
 

        if (vendor == 0 || !vendor->IsNPC() || vendor->GetClass() != MERCHANT)
                return;
 
+        //CUSTOM - Prevent merchant from buying any items from players
+        if (vendor->GetSTA() == 999){ //Can change to this to whatever
+                EQApplicationPacket* outapp = new EQApplicationPacket(OP_ShopPlayerSell, sizeof(Merchant_Purchase_Struct));
+                Merchant_Purchase_Struct* mco = (Merchant_Purchase_Struct*)outapp->pBuffer;
+                mco->npcid = vendor->GetID();
+                mco->itemslot = -1;
+                mco->quantity = 0;
+                mco->price = 0;
+                QueuePacket(outapp);
+                safe_delete(outapp);
+                return;
+        }
+        //CUSTOM - End
+
        //you have to be somewhat close to them to be properly using them
        if (DistanceSquared(m_Position, vendor->GetPosition()) > USE_NPC_RANGE2)
                return;



All times are GMT -4. The time now is 10:08 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.