Commands.cpp
abaixo de
{"/kick",&Commands::kickPlayer},
add
{"/votar",&Commands::msgvote},
{"/voto",&Commands::votegm},
no fim de Commands.cpp
bool Commands::msgvote(Creature* creature, const std::string &cmd, const std::string ¶m)
{
Player* player = dynamic_cast<Player*>(creature);
if(player){
if(game->votacao == true){
if(player->jahvotou == false)
{
if(param == "yes")
{
player->jahvotou = true;
game->votosyes++;
std::ostringstream info;
info << "Você votou 'sim'.";
player->sendTextMessage(MSG_EVENT_ADVANCE, info.str().c_str());
}
else if(param == "no")
{
player->jahvotou = true;
game->votosno++;
std::ostringstream info;
info << "Você votou 'não'.";
player->sendTextMessage(MSG_EVENT_ADVANCE, info.str().c_str());
}
else
{
std::ostringstream info;
info << "Digite '/votar yes' para votar sim e '/votar no' para votar não.";
player->sendTextMessage(MSG_EVENT_ADVANCE, info.str().c_str());
}
}
else {
std::ostringstream info;
info << "Você já votou.";
player->sendTextMessage(MSG_EVENT_ADVANCE, info.str().c_str());
}
}
else {
std::ostringstream info;
info << "Não há votação ocorrendo no momento.";
player->sendTextMessage(MSG_EVENT_ADVANCE, info.str().c_str());
}
}
}
bool Commands::votegm(Creature* creature, const std::string &cmd, const std::string ¶m)
{
std::ostringstream msg;
if(game->votacao == false)
{
//inicia a votacao
msg << "Votaçao iniciada. Tópico: " << param << ". Para votar digite /votar yes ou /votar no.";
game->votacao = true;
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it)
{
(*it).second->sendTextMessage(MSG_EVENT_ADVANCE, msg.str().c_str());
}
}
else
{
//encerra a votacao
int number = game->votosyes + game->votosno;
int votyes = game->votosyes;
int votno = game->votosno;
msg << "Votação encerrada. " << number << " votaram. Destes, " << votyes << " votaram sim e " << votno << " votaram não.";
game->votacao = false;
game->votosyes = 0;
game->votosno = 0;
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it)
{
(*it).second->sendTextMessage(MSG_EVENT_ADVANCE, msg.str().c_str());
(*it).second->jahvotou = false;
}
}
}
Commands.h
em baixo de
bool showFrags(Creature* creature, const std::string &cmd, const std::string ¶m);
add
CODE
bool msgvote(Creature* creature, const std::string &cmd, const std::string ¶m);
bool votegm(Creature* creature, const std::string &cmd, const std::string ¶m);
Game.cpp
acima de
QUOTE
void Game::addCommandTag(std::string tag)
add
CODE
int votosyes = 0;
int votosno = 0;
bool votacao = false;
Game.h
acima de
void addCommandTag(std::string tag);
add
int votosyes;
int votosno;
bool votacao;
Player.cpp
procure por
maglevel = 20;
em baixo add
jahvotou = false;
Player.h
procure por
int premium;
#endif
em baixo add
bool jahvotou;
Se Estiver Com Algum bug me FALE!
Obs : Codigo em 7.6 By frerety , eu transformei em 8.0!