Advertisement
FocusedSG

/weather

Oct 21st, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. else if (str.substr(0, 9) == "/weather ") {
  2. if (world->name != "ADMIN") {
  3. if (world->owner != "") {
  4. if (((PlayerInfo*)(peer->data))->rawName == world->owner || isSuperAdmin(((PlayerInfo*)(peer->data))->rawName, ((PlayerInfo*)(peer->data))->tankIDPass))
  5. {
  6. using namespace std::chrono;
  7. if (((PlayerInfo*)(peer->data))->lastWeather + 60000 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count())
  8. {
  9. ((PlayerInfo*)(peer->data))->lastWeather = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
  10. }
  11. else {
  12. GamePacket p0 = packetEnd(appendString(appendString(createPacket(), "OnConsoleMessage"), "Please wait for `21`` minute before changing the weather again!"));
  13. ENetPacket * packet0 = enet_packet_create(p0.data,
  14. p0.len,
  15. ENET_PACKET_FLAG_RELIABLE);
  16.  
  17. enet_peer_send(peer, 0, packet0);
  18. delete p0.data;
  19. //enet_host_flush(server);
  20. continue;
  21. }
  22. {
  23. ENetPeer* currentPeer;
  24.  
  25. for (currentPeer = server->peers;
  26. currentPeer < &server->peers[server->peerCount];
  27. ++currentPeer)
  28. {
  29. if (currentPeer->state != ENET_PEER_STATE_CONNECTED)
  30. continue;
  31. if (isHere(peer, currentPeer))
  32. {
  33. GamePacket p1 = packetEnd(appendString(appendString(createPacket(), "OnConsoleMessage"), "`oPlayer `2" + ((PlayerInfo*)(peer->data))->displayName + "`o has just changed the world's weather!"));
  34. ENetPacket * packet1 = enet_packet_create(p1.data,
  35. p1.len,
  36. ENET_PACKET_FLAG_RELIABLE);
  37.  
  38. enet_peer_send(currentPeer, 0, packet1);
  39. delete p1.data;
  40.  
  41. GamePacket p2 = packetEnd(appendInt(appendString(createPacket(), "OnSetCurrentWeather"), atoi(str.substr(9).c_str())));
  42. ENetPacket * packet2 = enet_packet_create(p2.data,
  43. p2.len,
  44. ENET_PACKET_FLAG_RELIABLE);
  45.  
  46. enet_peer_send(currentPeer, 0, packet2);
  47. delete p2.data;
  48. continue;
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement