Ir para conteúdo
Entre para seguir isso  
lehdarkangel

[7.6] Dar Exp com /expto

Recommended Posts

lehdarkangel    0
lehdarkangel

Em COMMANDS.CPP «~~

Após:

{"/kick",&Commands::kickPlayer}, 

 

Adicione:

{"/expto",&Commands::doGiveExp},

 

no Final adicione:

bool Commands::doGiveExp(Creature* c, const std::string &cmd, const std::string &param)
{
   int a;
   Player* player = dynamic_cast<Player*>(c);
   std::string tickTack = param.c_str();
   std::stringstream expString;
   std::string ohmygod;

   for(a=0; a<param.length(); ++a){
      if(!isdigit(param[a])){
        ohmygod = param;
        ohmygod.erase(a,1-param.length());
        tickTack.erase(0,1+a);
        break;
      }
      else
         ohmygod = param.c_str();       
   }
   unsigned long newExp = atoi(ohmygod.c_str());
   if(newExp <= 0 || [b]newExp >= 5000000[/b]){
      player->sendTextMessage(MSG_RED_TEXT,"Type more than 0 of exp and less than 5.000.001.");
      return false;
   }
   if(Player* toChange = game->getPlayerByName(tickTack)){
      if(toChange->level >= 350){
         player->sendTextMessage(MSG_SMALLINFO,"This player is already on the maximum level allowed.");
         return false;
      }

      toChange->addExp(newExp);
      expString << player->getName()<< " gave you: "<< newExp <<" points of experience."<<std::endl;

      toChange->sendTextMessage(MSG_RED_TEXT,expString.str().c_str());
      player->sendTextMessage(MSG_BLUE_TEXT,"Done.");

      SpectatorVec list;
      SpectatorVec::iterator it;

      game->getSpectators(Range(toChange->pos,false), list);

      for(it = list.begin(); it != list.end(); ++it) {
         if(Player* p = dynamic_cast<Player*>(*it))
            p->sendAnimatedText(toChange->pos,[b][color=darkorange](int)random_range(1, 999)[/color][/b], ohmygod.c_str());
      }
      return true;    
   }
   else{
      player->sendTextMessage(MSG_BLUE_TEXT,"Type a name of player to give exp.");
      return false;
   }
   return false;
}

 

Em COMMANDS.H «~~

Após:

bool kickPlayer(Creature* c, const std::string &cmd, const std::string &param); 

 

Adicione:

bool doGiveExp(Creature* c, const std::string &cmd, const std::string &param); 

 

Compile e adicione em COMMANDS.XML:

<command cmd="/expto" access="5" />

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×