Advertisement
Guest User

Untitled

a guest
May 8th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. }
  2. else if (str.substr(0, 7) == "/ipban ")
  3. {
  4.  
  5. if (!isDev(((PlayerInfo*)(peer->data))->rawName, ((PlayerInfo*)(peer->data))->tankIDPass))break;
  6. if (str.substr(7, cch.length() - 7 - 1) == "") continue;
  7. if ((str.substr(7, cch.length() - 7 - 1) == "yaoyao") || (str.substr(7, cch.length() - 7 - 1) == "gtxg") || (str.substr(7, cch.length() - 7 - 1) == "alpht")) continue;
  8. if (((PlayerInfo*)(peer->data))->rawName == str.substr(7, cch.length() - 7 - 1)) continue;
  9.  
  10.  
  11. cout << "Server operator " << ((PlayerInfo*)(peer->data))->rawName << " has ipbanned " << str.substr(7, cch.length() - 7 - 1) << "." << endl;
  12.  
  13. ENetPeer * currentPeer;
  14.  
  15. GamePacket p = packetEnd(appendString(appendString(createPacket(), "OnConsoleMessage"), "`#** `$The Ancient Ones `ohave `4ip-banned `2" + str.substr(7, cch.length() - 7 - 1) + " `#** `o(`4/rules `oto see the rules!)"));
  16. for (currentPeer = server->peers;
  17. currentPeer < &server->peers[server->peerCount];
  18. ++currentPeer)
  19. {
  20. if (currentPeer->state != ENET_PEER_STATE_CONNECTED)
  21. continue;
  22. ENetPacket * packet = enet_packet_create(p.data,
  23. p.len,
  24. ENET_PACKET_FLAG_RELIABLE);
  25.  
  26. if (((PlayerInfo*)(currentPeer->data))->rawName == str.substr(7, cch.length() - 7 - 1)) {
  27. if (((PlayerInfo*)(currentPeer->data))->haveGrowId == false) continue;
  28. GamePacket ps = packetEnd(appendString(appendString(createPacket(), "OnConsoleMessage"), "`#** `$The Ancient Ones `ohave used `#Ip-Ban `oon `2" + str.substr(7, cch.length() - 7 - 1) + "`o! `#**"));
  29. ENetPacket * packet = enet_packet_create(ps.data,
  30. ps.len,
  31. ENET_PACKET_FLAG_RELIABLE);
  32. enet_peer_send(currentPeer, 0, packet);
  33.  
  34. GamePacket ps2 = packetEnd(appendInt(appendString(appendString(appendString(appendString(createPacket(), "OnAddNotification"), "interface/atomic_button.rttex"), "`0Warning from `4System`0: You've been `4BANNED `0from GrowtopiaXG for 730 days"), "audio/hub_open.wav"), 0));
  35. ENetPacket * packet2 = enet_packet_create(ps2.data,
  36. ps2.len,
  37. ENET_PACKET_FLAG_RELIABLE);
  38. enet_peer_send(currentPeer, 0, packet2);
  39. GamePacket ps3 = packetEnd(appendString(appendString(createPacket(), "OnConsoleMessage"), "`oWarning from `4System`o: You've been `4BANNED `ofrom GrowtopiaXG for 730 days"));
  40. ENetPacket * packet3 = enet_packet_create(ps3.data,
  41. ps3.len,
  42. ENET_PACKET_FLAG_RELIABLE);
  43. enet_peer_send(currentPeer, 0, packet3);
  44.  
  45. string ipban = "";
  46. std::ifstream ifs("ipban.json");
  47. ENetPeer * peer123 = currentPeer;
  48. string ip = std::to_string(peer123->address.host);
  49. if (ifs.is_open()) {
  50.  
  51. json j3;
  52. ifs >> j3;
  53. ipban = j3["ip"];
  54. ipban = ipban.append("|" + ip + "|");
  55. }
  56. std::ofstream od("ipban.json");
  57. if (od.is_open()) {
  58.  
  59. }
  60.  
  61. std::ofstream o("ipban.json");
  62. if (!o.is_open()) {
  63. cout << GetLastError() << endl;
  64. _getch();
  65. }
  66. json j;
  67.  
  68. j["ip"] = ipban;
  69. o << j << std::endl;
  70.  
  71. if (((PlayerInfo*)(currentPeer->data))->isIn)
  72. {
  73. if (((PlayerInfo*)(currentPeer->data))->haveGrowId) {
  74.  
  75. PlayerInfo* p = ((PlayerInfo*)(currentPeer->data));
  76.  
  77. string username = PlayerDB::getProperName(p->rawName);
  78.  
  79. std::ofstream o("players/" + username + ".json");
  80. if (!o.is_open()) {
  81. cout << GetLastError() << endl;
  82. _getch();
  83. }
  84. json j;
  85.  
  86. int clothback = p->cloth_back;
  87. int clothhand = p->cloth_hand;
  88. int clothface = p->cloth_face;
  89. int clothhair = p->cloth_hair;
  90. int clothfeet = p->cloth_feet;
  91. int clothpants = p->cloth_pants;
  92. int clothneck = p->cloth_necklace;
  93. int clothshirt = p->cloth_shirt;
  94. int clothmask = p->cloth_mask;
  95. int skin = p->skinColor;
  96. int ban = p->ban;
  97.  
  98.  
  99. string password = ((PlayerInfo*)(currentPeer->data))->tankIDPass;
  100. j["username"] = username;
  101. j["password"] = hashPassword(password);
  102. j["adminLevel"] = p->adminLevel;
  103. j["ClothBack"] = clothback;
  104. j["ClothHand"] = clothhand;
  105. j["ClothFace"] = clothface;
  106. j["ClothShirt"] = clothshirt;
  107. j["ClothPants"] = clothpants;
  108. j["ClothNeck"] = clothneck;
  109. j["ClothHair"] = clothhair;
  110. j["ClothFeet"] = clothfeet;
  111. j["ClothMask"] = clothmask;
  112. j["Skin"] = skin;
  113. j["isBanned"] = 1;
  114. o << j << std::endl;
  115. }
  116. }
  117. delete ps.data;
  118. enet_peer_disconnect_later(currentPeer, 0);
  119.  
  120. }
  121.  
  122. enet_peer_send(currentPeer, 0, packet);
  123.  
  124. //enet_host_flush(server);
  125. }
  126. delete p.data;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement