Ok. There are some things to understand before you start this.
1. You must remove all of the code or comment it out that has to do with the isOldClient variable and functions. Its a deprecated function that was supposed to be cross client compatible but just ended up becoming a headache.
2. You need to change the player.cpp to reflect this. Open the file and navigate to the switch for the packet headers and change the following:
Change it to:Code:// Player closed trade dialog with npc case 0x00ff00b2: return false;
This will ensure that no error comes about when using the packet.Code:// Player closed trade dialog with npc case 0x00ff00b2: return true;
3.
Add this or change it if you already have it : ShopPacket.cpp:
As you can see, this is the code in its entiredy. I am going to give you ONE text file so you can get started. To make more use the file as a guide. The first one on each line is the amount items on each tab. Its IMPERITIVE that you keep this number consistant with the items on each line. failure to do so will crash the server. So here is an example of Luda's Shop.Code:#include "Packets/NPCsPacket.h" #include "NPC.h" #include "ShopPacket.h" #include "Player.h" #include "Packets/PacketCreator.h" #include "ItemBank.h" #include "ItemBanks.h" #include "windows.h" #include <string> #include "tchar.h" #include <iostream> #include <fstream> #include <vector> void ShopPacket::showShop(NPC* npc, Player* player) { int count=0; string line; char* next_token; ifstream myfile; int i, j; int slots, linenum = 0; char* filename; vector<int> tab1; vector<int> tab2; vector<int> tab3; vector<int> tab4; printf("NPC id: %d\n", npc->id); switch(npc->id) { case 513: filename = "C:\\kims\\databaseLoad\\Shops\\MaFl_Lui.txt"; myfile.open(filename); printf("Opening file %s\n", filename); break; case 514: filename = "C:\\kims\\databaseLoad\\Shops\\MaFl_Dior.txt"; myfile.open(filename); printf("Opening file %s\n", filename); break; case 515: filename = "C:\\kims\\databaseLoad\\Shops\\MaFl_Is.txt"; myfile.open(filename); printf("Opening file %s\n", filename); break; case 519: filename = "C:\\kims\\databaseLoad\\Shops\\MaFl_Boboku.txt"; myfile.open(filename); printf("Opening file %s\n", filename); break; case 520: filename = "C:\\kims\\databaseLoad\\Shops\\MaFl_Boboko.txt"; myfile.open(filename); printf("Opening file %s\n", filename); break; case 524: filename = "C:\\kims\\databaseLoad\\Shops\\MaFl_Luda.txt"; myfile.open(filename); printf("Opening file %s\n", filename); break; case 554: filename = "C:\\kims\\databaseLoad\\Shops\\MaFl_Losha.txt"; myfile.open(filename); printf("Opening file %s\n", filename); break; default: printf("No shop to open or id unknown %d please recheck the id and or filename", npc->id); } if (myfile.fail()) { printf("%s couldn't be read\n",filename); //system("pause"); //exit(1); } else { // If the file is open start parsing the text line by line. if (myfile.is_open()) { i=0; linenum++; while(!myfile.eof()) { getline (myfile,line); slots = atoi(strtok_s((char*)line.c_str(), " ", &next_token)); //strtok_s(NULL, " ", &next_token); switch(linenum) { case 1: for(j = 0; j<slots;j++) { tab1.push_back(strval(strtok_s(NULL, " ", &next_token))); } linenum++; break; case 2: for(j = 0; j<slots;j++) { tab2.push_back(strval(strtok_s(NULL, " ", &next_token))); } linenum++; break; case 3: for(j = 0; j<slots;j++) { tab3.push_back(strval(strtok_s(NULL, " ", &next_token))); } linenum++; break; case 4: for(j = 0; j<slots;j++) { tab4.push_back(strval(strtok_s(NULL, " ", &next_token))); } break; } } } myfile.close(); } vector< vector<int> > shopTabs; shopTabs.push_back(tab1); shopTabs.push_back(tab2); shopTabs.push_back(tab3); shopTabs.push_back(tab4); Packet pak = Packet(); pak.setPlayer(player); pak.addHeader(npc,0x14); //cycle through all four tabs for (int tab = 0; tab < 4; tab++) { for(i=0; i <100; i++) pak.addInt(i); pak.addByte(shopTabs[tab].size()); for(unsigned int k=0; k < shopTabs[tab].size(); k++) { // process each tab if(shopTabs[tab].empty()) continue; ItemBank* shopItem = ItemBanks::getItemBankById(shopTabs[tab].at(k)); pak.addByte(k); pak.addInt(k); pak.addInt(shopItem->id); pak.addInt(0); pak.addInt(0); pak.addShort(shopItem->maxItems); pak.addByte(0); if(shopItem->endurance == 0) { pak.addInt(-1); } else { pak.addInt(shopItem->endurance); } pak.addInt(0); pak.addInt(0); pak.addInt(0); pak.addInt(0); pak.addInt(0); pak.addInt(0); pak.addInt(0); pak.addInt(0); pak.addInt(0); pak.addInt(0); } for(i=0; i <100; i++) pak.addInt(i); } pak.completePacket(); pak.packetSend(); shopTabs.clear(); tab1.clear(); tab2.clear(); tab3.clear(); tab4.clear(); }
Save this as MaFl_Luda.txt and place it in the databaseLoad/Shops folder. You can change the path name to your liking. I just kept it the default pathname.Code:7 21 23 25 81 27 61 83 11 510 506 502 500 511 507 503 514 520 518 516 5 2001 2003 2005 2007 2009
There should be no errors but if the errors arise, at least try and fix them before posting them here.
Enjoy!
oh, one more thing. YOU CANNOT BUY NOR SELL ITEMS AS OF THIS RELEASE! It will crash at this point.



![[Share] DragonSource Shop Packet Implementation](http://ragezone.com/hyper728.png)




