Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Item swapper
- Created by yvoms & Rochet2, enjoy the swapper.
- Please do not alter the credits.
- */
- struct tokenData {uint32 TAKE_ENTRY, TAKE_AMOUNT, GIVE_ENTRY, GIVE_AMOUNT; };
- struct tokenData Tokens[] =
- {
- // {TAKE_ENTRY, TAKE_AMOUNT, GIVE_ENTRY, GIVE_AMOUNT},
- // Make a custom structure, so for example.
- //this takes itemid 50 and gives itemid 62 in return
- {50, 1, 62, 1},
- //you can also take 5000 and give itemid 62 back 1000 times.
- {50, 500, 62, 1000},
- //And so on
- {50, 500, 62, 1000},
- {50, 1000, 62, 2000},
- {50, 1500, 62, 3000},
- {50, 2500, 62, 5000},
- {50, 5000, 62, 10000},
- {50, 10000, 62, 20000},
- {50, 100000, 62, 200000},
- //The above takes an item, and gives a different item back in a higher quantity.
- //its also possible to do it in negatives.
- {62, 1000, 50, 500},
- {62, 2500, 50, 1250},
- {62, 5000, 50, 2500},
- {62, 10000, 50, 5000},
- {62, 50000, 50, 25000},
- /*
- This is all up to you you can do whatever u want with it.
- Enjoy :)
- */
- };
- const uint32 tokensSize = sizeof Tokens/sizeof(*Tokens);
- #include "ScriptPCH.h"
- class CustomSwapItems : public CreatureScript
- {
- public:
- CustomSwapItems() : CreatureScript("CustomSwapItems") { }
- std::string GetName(uint32 entry)
- {
- return sObjectMgr->GetItemTemplate(entry)->Name1;
- }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- for (uint32 i = 0; i < tokensSize; ++i)
- {
- std::ostringstream ss;
- // Swap 50 x Token to 10 x token2 (names set automatically)
- ss << "Swap " << Tokens[i].TAKE_AMOUNT << " x " << GetName(Tokens[i].TAKE_ENTRY) << " to " << Tokens[i].GIVE_AMOUNT << " x " << GetName(Tokens[i].GIVE_ENTRY);
- player->ADD_GOSSIP_ITEM_EXTENDED(0, ss.str(), GOSSIP_SENDER_MAIN, i, "Are you sure?", 0, false);
- }
- player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
- {
- player->PlayerTalkClass->ClearMenus();
- if(sender == GOSSIP_SENDER_MAIN && action < tokensSize)
- {
- if(player->HasItemCount(Tokens[action].TAKE_ENTRY, Tokens[action].TAKE_AMOUNT))
- {
- if(player->AddItem(Tokens[action].GIVE_ENTRY, Tokens[action].GIVE_AMOUNT))
- {
- player->DestroyItemCount(Tokens[action].TAKE_ENTRY, Tokens[action].TAKE_AMOUNT, true);
- player->GetSession()->SendAreaTriggerMessage("%u x %s swapped to %u x %s", Tokens[action].TAKE_AMOUNT, GetName(Tokens[action].TAKE_ENTRY).c_str(), Tokens[action].GIVE_AMOUNT, GetName(Tokens[action].GIVE_ENTRY).c_str());
- }
- }
- else
- player->GetSession()->SendNotification("You need at least %u x %ss", Tokens[action].TAKE_AMOUNT, GetName(Tokens[action].TAKE_ENTRY).c_str());
- }
- OnGossipHello(player, creature);
- return true;
- }
- };
- void AddSC_CustomSwapItems()
- {
- new CustomSwapItems();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement