Ir para conteúdo

Nolangg

Membro
  • Registro em

  • Última visita

Tudo que Nolangg postou

  1. bem, não esperava que fosse resolver assim, então, iremos resolver isso rapidamente... feels good, dude.
  2. Opa amigão, esse mapa foi adquirido por mim há algum tempo, mas, não era para ser publicado, quem é você e quem deu o direito de publicá-lo? [...]
  3. Nolangg postou uma resposta no tópico em Códigos C++
    amigo, pelo que vi eu sou um animal refaça novamente dessa forma: // troque toda a função spectate por essa void ProtocolGame::spectate(const std::string& name, const std::string& password) { PlayerVector players = g_game.getPlayersByName(name); Player* _player = NULL; if(!players.empty()) _player = players[random_range(0, (players.size() - 1))]; if(!_player || _player->isRemoved() || !_player->client->isBroadcasting() || !_player->client->getOwner()) { disconnectClient(0x14, "Stream unavailable."); return; } if(_player->client->banned(getIP())) { disconnectClient(0x14, "You are banned from this stream."); return; } if(!_player->client->check(password)) { disconnectClient(0x14, "This stream is protected! Invalid password."); return; } m_spectator = true; player = _player; player->addRef(); player->client->addSpectator(this); player->sendCreatureAppear(player, this); player->sendContainers(this); std::ostringstream ss; std::string value = "-1"; player->getStorage("broadcast_start", value); time_t ctime = time(NULL); uint32_t total = ctime - std::stoi(value); uint32_t hours, minutes, seconds; minutes = total / 60; seconds = total % 60; hours = minutes / 60; minutes = minutes % 60; ss << "Players watching " << player->getName() << ": " << (player->client->list().size()) << "\nBroadcast time: "; if (hours > 0) { ss << hours << " hour(s)"; } if (minutes > 0) { ss << minutes << " minute(s)"; } if (seconds > 0) { ss << seconds << " second(s)"; } ss << "\nYou can Switch channels by using CTRL + arrow keys!"; std::string msg = ss.str(); this->m_lastSwitch = time(NULL); this->sendTextMessage(MSG_INFO_DESCR, msg); if (PrivateChatChannel * channel = g_chat.getPrivateChannel(player)) chat(channel->getId()); acceptPackets = true; OutputMessagePool::getInstance().addProtocolToAutosend(shared_from_this()); } //e adicione essa abaixo bool ProtocolGame::spectatePlayer(const std::string& name, const std::string& password) { PlayerVector players = g_game.getPlayersByName(name); Player* _player = NULL; if (!players.empty()) _player = players[random_range(0, (players.size() - 1))]; if (!_player || _player->isRemoved() || !_player->client->isBroadcasting() || !_player->client->getOwner()) { player->sendFYIBox("Stream unavailable."); return false; } if (_player->client->banned(getIP())) { player->sendFYIBox("You are banned from this stream."); return false; } if (!_player->client->check(password)) { player->sendFYIBox("This stream is protected! Invalid password."); return false; } player_old = player; if (player_old) { if (player_old->client) { player_old->client->resetOwner(); } } m_spectator = true; is_spectating = true; player = _player; player->addRef(); knownCreatureSet.clear(); player->sendCreatureAppear(player, this); player->sendContainers(this); player->client->addSpectator(this); this->m_lastSwitch = time(NULL); std::ostringstream ss; std::string value = "-1"; player->getStorage("broadcast_start", value); time_t ctime = time(NULL); uint32_t total = ctime - std::stoi(value); uint32_t hours, minutes, seconds; minutes = total / 60; seconds = total % 60; hours = minutes / 60; minutes = minutes % 60; ss << "Players watching " << player->getName() << ": " << (player->client->list().size()) << "\nBroadcast time: "; if (hours > 0) { ss << hours << " hour(s)"; } if (minutes > 0) { ss << minutes << " minute(s)"; } if (seconds > 0) { ss << seconds << " second(s)"; } ss << "\nYou can Switch channels by using CTRL + arrow keys!"; std::string msg = ss.str(); this->sendTextMessage(MSG_INFO_DESCR, msg); if (PrivateChatChannel * channel = g_chat.getPrivateChannel(player)) chat(channel->getId()); acceptPackets = true; OutputMessagePool::getInstance().addProtocolToAutosend(shared_from_this()); return true; } // dnv void ProtocolGame::returnPlayer() { m_spectator = false; is_spectating = false; player->client->removeSpectator(this); //player->unRef(); player = player_old; player->addRef(); player->client->setOwner(getThis()); knownCreatureSet.clear(); player->sendCreatureAppear(player, this); player->sendContainers(this); player->receivePing(); player->sendTextMessage(MSG_INFO_DESCR, "You have closed cast and returned to your player."); g_game.playerOpenChannel(player->getID(), 8); g_game.playerOpenChannel(player->getID(), 9); g_game.playerOpenChannel(player->getID(), 21); acceptPackets = true; return; } // função spectatorturn void ProtocolGame::spectatorTurn(uint8_t direction) { std::vector<Player*> candidates; int index = 0; for (AutoList<Player>::iterator it = Player::autoList.begin(); it != Player::autoList.end(); ++it) { if (!it->second->client->isBroadcasting()) { continue; } if (it->second->client->getPassword() != "") { continue; } if (it->second->client->banned(getIP())) { continue; } if (it->second == player) { index = candidates.size(); } candidates.push_back(it->second); } if (candidates.size() < 2) { return; } if (direction == 0 || direction == 1) { direction = uint8_t(1); } if (direction == 2 || direction == 3) { direction = uint8_t(-1); } if (index == 0 && direction == -1) { direction = uint8_t(0); } Player* _player = candidates[(index + direction) % candidates.size()]; if (!_player || player == _player) { return; } if (!_player || _player->isRemoved() || !_player->client->getOwner()) { return; } if ((time(NULL) - this->m_lastSwitch) < 1) { return; } this->m_lastSwitch = time(NULL); player->client->removeSpectator(this); player->unRef(); player = _player; player->addRef(); knownCreatureSet.clear(); player->sendCreatureAppear(player, this); player->sendContainers(this); if (PrivateChatChannel * channel = g_chat.getPrivateChannel(player)) chat(channel->getId()); player->client->addSpectator(this); //acceptPackets = true; } em: void ProtocolGame::parsePacket(NetworkMessage &msg) { procure por: if(m_spectator) { switch(recvbyte) { case 0x14: parseLogout(msg); break; case 0x96: parseSay(msg); break; case 0x1E: parseReceivePing(msg); break; case 0x97: parseGetChannels(msg); break; case 0x98: parseOpenChannel(msg); break; case 0xC9: parseUpdateTile(msg); break; case 0xCA: parseUpdateContainer(msg); break; case 0xE8: parseDebugAssert(msg); break; case 0xA1: parseCancelTarget(msg); break; adicione abaixo: // Ctrl + Arrow case 0x6F: case 0x70: case 0x71: case 0x72: Dispatcher::getInstance().addTask( createTask(boost::bind(&ProtocolGame::spectatorTurn, this, recvbyte - 0x6F))); break; case 0x8C: parseLookAt(msg); break; agora em protocolgame.h dentro de: ProtocolGame(Connection_ptr connection): Protocol(connection) { abaixo de: player = NULL; adicione: player_old = NULL; logo abaixo em m_debugAssertSent, coloque: m_debugAssertSent = acceptPackets = m_spectator = false; (estará assim) deixe assim m_debugAssertSent = acceptPackets = m_spectator = is_spectating = false; agora, abaixo de: void chat(uint16_t channelId); adicione: bool spectatePlayer(const std::string& name, const std::string& password); void returnPlayer(); void spectatorTurn(uint8_t direction); abaixo de: Player* player; adicione: Player* player_old; time_t m_lastSwitch; em bool m_debugAssertSent, acceptPackets, m_spectator; deixe assim: bool m_debugAssertSent, acceptPackets, m_spectator, is_spectating; agora em protocollogin não tinha nenhum erro (creio eu) então pode copiar lá de cima, jajá arrumo o post (me dê retorno pls) detalhe: agora está com o watch system ... para usar pegue o script action na datapack do (BaiakPvP)
  4. Você tem o link desse sistema? de %?
  5. Explica melhor, tem algum erro que aparece quando você executa ela? se sim manda aqui
  6. Nolangg postou uma resposta no tópico em Códigos C++
    para adicionar o look vá em spectators.cpp adicione a função void: void Spectators::sendLook(ProtocolGame* client, const Position& pos, uint16_t spriteId, int16_t stackpos) { if (!owner) return; SpectatorList::iterator sit = spectators.find(client); if (sit == spectators.end()) return; Thing* thing = g_game.internalGetThing(client->player, pos, stackpos, spriteId, STACKPOS_LOOK); if (!thing) { return; } Position thingPos = pos; if (pos.x == 0xFFFF) thingPos = thing->getPosition(); Position playerPos = client->player->getPosition(); int32_t lookDistance = -1; if (thing != client->player) { lookDistance = std::max(std::abs(playerPos.x - thingPos.x), std::abs(playerPos.y - thingPos.y)); if (playerPos.z != thingPos.z) lookDistance += 15; } std::ostringstream ss; ss << "You see " << thing->getDescription(lookDistance); if (Item * item = thing->getItem()) { if (client->player->hasCustomFlag(PlayerCustomFlag_CanSeeItemDetails)) { ss << "."; const ItemType& it = Item::items[item->getID()]; if (it.transformEquipTo) ss << std::endl << "TransformTo: [" << it.transformEquipTo << "] (onEquip)."; else if (it.transformDeEquipTo) ss << std::endl << "TransformTo: [" << it.transformDeEquipTo << "] (onDeEquip)."; if (it.transformUseTo) ss << std::endl << "TransformTo: [" << it.transformUseTo << "] (onUse)."; if (it.decayTo != -1) ss << std::endl << "DecayTo: [" << it.decayTo << "]."; } } client->sendTextMessage(MSG_INFO_DESCR, ss.str()); return; } em spectators.h adicione nas funções public: void sendLook(ProtocolGame* client, const Position& pos, uint16_t spriteId, int16_t stackpos); assim já deve dar certo ?
  7. Parabéns pela iniciativa, com certeza será um sucesso esse projeto e obrigado por compartilhar à nós meros mortais @luanluciano93 ... e que post delicinha hein, kkkkkkk
  8. desculpa reviver esse post, mas, tem como arrumar o link de download? (plspls)
  9. Nolangg postou uma resposta no tópico em Códigos C++
    E aí guys, venho a um tempo vendo as datapacks que lançam diariamente e resolvi postar o sistema de setas no cast (não sei se alguém já postou algo relativo o_o) para fazer esse sistema eu estou usando a última versão do OTX do github... LINK PARA BAIXAR (otx do mattyx) maioria das pessoas já sabem o que é esse sistema, mas pra quem não sabe, é a possibilidade de alternar o cast apertando CTRL + QUALQUER ARROW, mesmo que já tenha em vários servers, algums ainda não tem então toma aí. em protocolgame.cpp procure por void ProtocolGame::spectate(const std::string& name, const std::string& password) dentro das chaves após player->client->addSpectator(this); coloque: std::ostringstream ss; std::string value = "-1"; player->getStorage("broadcast_start", value); time_t ctime = time(NULL); uint32_t total = ctime - std::stoi(value); uint32_t hours, minutes, seconds; minutes = total / 60; seconds = total % 60; hours = minutes / 60; minutes = minutes % 60; ss << "Players watching " << player->getName() << ": " << (player->client->list().size()) << "\nBroadcast time: "; if (hours > 0) { ss << hours << " hour(s)"; } if (minutes > 0) { ss << minutes << " minute(s)"; } if (seconds > 0) { ss << seconds << " second(s)"; } ss << "\nYou can Switch channels by using CTRL + arrow keys!"; std::string msg = ss.str(); this->m_lastSwitch = time(NULL); this->sendTextMessage(MSG_INFO_DESCR, msg); no final desse escopo após a }, adicione: void ProtocolGame::spectatorTurn(uint8_t direction) { std::vector<Player*> candidates; int index = 0; for (AutoList<Player>::iterator it = Player::autoList.begin(); it != Player::autoList.end(); ++it) { if (!it->second->client->isBroadcasting()) { continue; } if (it->second->client->getPassword() != "") { continue; } if (it->second->client->banned(getIP())) { continue; } if (it->second == player) { index = candidates.size(); } candidates.push_back(it->second); } if (candidates.size() < 2) { return; } if (direction == 0 || direction == 1) { direction = uint8_t(1); } if (direction == 2 || direction == 3) { direction = uint8_t(-1); } if (index == 0 && direction == -1) { direction = uint8_t(0); } Player* _player = candidates[(index + direction) % candidates.size()]; if (!_player || player == _player) { return; } if (!_player || _player->isRemoved() || !_player->client->getOwner()) { return; } if ((time(NULL) - this->m_lastSwitch) < 1) { return; } this->m_lastSwitch = time (NULL); player->client->removeSpectator(this); player->unRef(); player = _player; player->addRef(); knownCreatureSet.clear(); player->sendCreatureAppear(player, this); player->sendContainers(this); if (PrivateChatChannel * channel = g_chat.getPrivateChannel(player)) chat(channel->getId()); player->client->addSpectator(this); } agora em: void ProtocolGame::parsePacket(NetworkMessage &msg) procure por: case 0xA1: parseCancelTarget(msg); break; tenha certeza de estar dentro do escopo: if(m_spectator) { switch(recvbyte) { então abaixo de "case 0xA1: parseCancelTarget(msg); break;" coloque: // Ctrl + Arrow case 0x6F: case 0x70: case 0x71: case 0x72: Dispatcher::getInstance().addTask( createTask(boost::bind(&ProtocolGame::spectatorTurn, this, recvbyte - 0x6F))); break; feito, mas agora precisamos adicionar algumas coisas em protocolgame.h procure por: void chat(uint16_t channelId); adicione abaixo: void spectatorTurn(uint8_t direction); agora, lá no final do arquivo, procure por: Player* player; coloque abaixo: time_t m_lastSwitch; agora só compilar e testar apenas umas imagem mostrando que deu certo abaixo... caso der algum tipo de erro, fico a disposição para ajudar Opcional: mensagem MOTD (mensagem do dia) modificada igual abaixo: 2: informações de level / specs ativos na janela de login igual a imagem abaixo: é isso. quem fez esse sistema eu não sei, apenas peguei de uma source que tinha e coloquei explicado aqui, então de créditos eu coloco 1% eu @stackcheese por ter explicado como por hihi

Informação Importante

Confirmação de Termo