Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if (str.substr(0, 9) == "/weather ") {
- if (world->name != "ADMIN") {
- if (world->owner != "") {
- if (((PlayerInfo*)(peer->data))->rawName == world->owner || isSuperAdmin(((PlayerInfo*)(peer->data))->rawName, ((PlayerInfo*)(peer->data))->tankIDPass))
- {
- using namespace std::chrono;
- if (((PlayerInfo*)(peer->data))->lastWeather + 60000 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count())
- {
- ((PlayerInfo*)(peer->data))->lastWeather = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
- }
- else {
- GamePacket p0 = packetEnd(appendString(appendString(createPacket(), "OnConsoleMessage"), "Please wait for `21`` minute before changing the weather again!"));
- ENetPacket * packet0 = enet_packet_create(p0.data,
- p0.len,
- ENET_PACKET_FLAG_RELIABLE);
- enet_peer_send(peer, 0, packet0);
- delete p0.data;
- //enet_host_flush(server);
- continue;
- }
- {
- ENetPeer* currentPeer;
- for (currentPeer = server->peers;
- currentPeer < &server->peers[server->peerCount];
- ++currentPeer)
- {
- if (currentPeer->state != ENET_PEER_STATE_CONNECTED)
- continue;
- if (isHere(peer, currentPeer))
- {
- GamePacket p1 = packetEnd(appendString(appendString(createPacket(), "OnConsoleMessage"), "`oPlayer `2" + ((PlayerInfo*)(peer->data))->displayName + "`o has just changed the world's weather!"));
- ENetPacket * packet1 = enet_packet_create(p1.data,
- p1.len,
- ENET_PACKET_FLAG_RELIABLE);
- enet_peer_send(currentPeer, 0, packet1);
- delete p1.data;
- GamePacket p2 = packetEnd(appendInt(appendString(createPacket(), "OnSetCurrentWeather"), atoi(str.substr(9).c_str())));
- ENetPacket * packet2 = enet_packet_create(p2.data,
- p2.len,
- ENET_PACKET_FLAG_RELIABLE);
- enet_peer_send(currentPeer, 0, packet2);
- delete p2.data;
- continue;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement