Advertisement
Guest User

Untitled

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