Advertisement
Guest User

/find

a guest
May 24th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. }
  2. else if (str.substr(0, 6) == "/find ") {
  3. string item = str.substr(6, str.length());
  4.  
  5.  
  6. if (item != "") {
  7. if (item.length() >= 3) {
  8. ItemDefinition def;
  9. PlayerInventory inv;
  10. InventoryItem pitem;
  11. string stuff;
  12. std::ifstream infile("CoreData.txt");
  13. for (std::string line; getline(infile, line);)
  14. {
  15. if (line.length() > 8 && line[0] != '/' && line[1] != '/')/*
  16. PlayerInventory inventory;
  17. InventoryItem item;
  18. item.itemID = atoi(str.substr(6, cch.length() - 6 - 1).c_str());
  19. item.itemCount = 200;
  20. inventory.items.push_back(item);
  21. item.itemCount = 1;
  22. item.itemID = 18;
  23. inventory.items.push_back(item);
  24. item.itemID = 32;
  25. inventory.items.push_back(item);
  26. sendInventory(peer, inventory);*/
  27. {
  28. vector<string> ex = explode("|", line);
  29. string xd = ex[1];
  30. string id = ex[0];
  31. std::transform(xd.begin(), xd.end(), xd.begin(), ::tolower);
  32.  
  33.  
  34. std::transform(item.begin(), item.end(), item.begin(), ::tolower);/**/
  35.  
  36. PlayerInventory inv;
  37. InventoryItem pitem;
  38.  
  39. if (xd.find(item) != std::string::npos) {
  40. stuff.append("\nadd_label_with_icon|small|" + xd + ". `#To use item do `5/item " + id + "|left|" + id + ""/*" + "\nadd_button|found" + xd + "|Get " + id + */"|noflags|");
  41. stuff.append("\nadd+spacer|small|");
  42. }
  43. }
  44. }
  45. string x = "set_default_color|`3\n";
  46.  
  47.  
  48. x.append("\nadd_label|big|`9Item Finder|left|");
  49. if (stuff == "") {
  50. GamePacket p = packetEnd(appendString(appendString(createPacket(), "OnConsoleMessage"), "`4No results!"));
  51. ENetPacket* packet = enet_packet_create(p.data,
  52. p.len,
  53. ENET_PACKET_FLAG_RELIABLE);
  54. enet_peer_send(peer, 0, packet);
  55. delete p.data;
  56. }
  57. else {
  58. x.append("\nadd_label|small|`wHere are the results of your `9search`w:|left|");
  59.  
  60.  
  61. x.append("\nadd_spacer|small|");
  62.  
  63.  
  64. x.append(stuff);
  65.  
  66.  
  67. //x.append(addspacer("big"));
  68. }
  69. x.append("\n\nadd_quick_exit|\nnend_dialog|gazette||OK|");
  70.  
  71.  
  72. GamePacket p = packetEnd(appendString(appendString(createPacket(), "OnDialogRequest"), x));
  73. ENetPacket* packet = enet_packet_create(p.data,
  74. p.len,
  75. ENET_PACKET_FLAG_RELIABLE);
  76. enet_peer_send(peer, 0, packet);
  77. delete p.data;
  78. }
  79. else {
  80. GamePacket p = packetEnd(appendString(appendString(createPacket(), "OnConsoleMessage"), "`4You must enter 3 or more letters!"));
  81. ENetPacket* packet = enet_packet_create(p.data,
  82. p.len,
  83. ENET_PACKET_FLAG_RELIABLE);
  84. enet_peer_send(peer, 0, packet);
  85. delete p.data;
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement