1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

player cant send message

Discussion in 'Help' started by GilBenDavid, Jun 24, 2017.

  1. GilBenDavid

    GilBenDavid Silverfish

    Messages:
    20
    ok so i try to create register plugin but then i have seen this problam
    all the time when i try to send message the message dont send
    please try to relate what i say and dont ask what exactly is this code supposed to achieve
    (sorry about my english)
    tanks for answers !
    PHP:
          public function onJoin(PlayerJoinEvent $event){
           
    $pl $event->getPlayer();
          
    $this->lgn[$pl->getName()] = 0;
           
    $cfg $this->cfg;
          
    $plcfg $cfg->get($pl->getName());
          if(
    $plcfg != null){
          if(
    $plcfg[1] == $pl->getAddress()){
            
    $this->lgn[$pl->getName()] = 1;
            
    $pl->sendMessage(TextFormat::AQUA."you are authenticated by ip");
          }else{
          
    $pl->sendMessage(TextFormat::AQUA."Login with your password !");
          }
          }else{
          
    $pl->sendMessage(TextFormat::AQUA."You need to register : type your new password !");
          }
          }
          public function 
    onMove(PlayerMoveEvent $event){
              if (
    $this->lgn[$event->getPlayer()->getName()] === 0){
              
    $event->setCancelled();
          }else{
             
          }
          }
         
          public function 
    onChat(PlayerChatEvent $event){
              
    $pl $event->getPlayer();
              
    $pln $pl->getName();
              
    $msg $event->getMessage();
              
    $cfg $this->cfg;
               
    $plcfg $cfg->get($pln);
              
    $lgin $this->lgn[$pln];
             
               
               
              if(
    $lgin === 0){
              
    $event->setCancelled();
              if(
    $plcfg != null){
              if(
    $msg == $plcfg[0]){
               
    $pl->sendMessage(TextFormat::GREEN."you are authenticated !");
                
    $lgin 1;
              }else{
                
    $pl->sendMessage(TextFormat::RED."This is not your password !");
              }
              }else{
               if(isset(
    $this->a[$pln])){
                  if(
    $this->a[$pln] == $msg){
                  
    $pl->sendMessage(TextFormat::GREEN."you are authenticated !");
                  
    $cfg->setNested($pln,[$msg,$pl->getAddress]);
                  
    $lgin 1;
                  }else{
                     
    $pl->sendMessage(TextFormat::RED."passwords do not match !
                     Type it agin !"
    );
                     
    $this->a[$pln] = null;
                  }
              }else{
                  
    $pl->sendMessage(TextFormat::AQUA."Please re-enter your password to confirm");
                    
    $this->a[$pln] = $msg;
              }
              }
          }else{
          }
          }
         
                public function 
    onCommandPreprocess(PlayerCommandPreprocessEvent $event){
              if (
    $this->lgn[$event->getPlayer()->getName()] === 0){
              
    $event->setCancelled();
          }else{
     
          }
          }
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    does your class implement Listener?
     
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    it's a very bad idea to try to use clear password as authentication, password_hash highly recommended
    anything the player send will fire preprocess first, since it's canceled, on msg will never be called AFAIK
     
    InspectorGadget likes this.
  4. GilBenDavid

    GilBenDavid Silverfish

    Messages:
    20
    yes
     
  5. GilBenDavid

    GilBenDavid Silverfish

    Messages:
    20
    HOOO ok thank you :)
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.