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

Solved Form bug

Discussion in 'Development' started by Kyd, Dec 15, 2017.

  1. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    When player close form it execute code that's used for first button :/

    Sending form:
    PHP:
               $data = [];
                
    $data['type'] = 'form';
                
    $data['title'] = $p->getText('ITEM_PARTICLES' , []);
                
    $data['content'] = "";
                
    $content = ["text" => "NORMAL PARTICLES"];
                
    $data["buttons"][] = $content;
                
    $content = ["text" => "§dCloud Particle §2§l[LVL 8]"];
                
    $data["buttons"][] = $content;
                
    $content = ["text" => "§dCrystal Particle §2§l[LVL 13]"];
                
    $data["buttons"][] = $content;
                
    $content = ["text" => "§6VIP Particles"];
                
    $data["buttons"][] = $content;
                
    $content = ["text" => "§6VIP+ Particles"];
                
    $data["buttons"][] = $content;
                
    $pk = new ModalFormRequestPacket();
                
    $pk->formId 2;
                
    $pk->formData json_encode($data);
                
    $p->dataPacket($pk);
    Handling response:
    PHP:
      $result json_decode($pk->formDatatrue);
                    
    $data $result;
                    
    var_dump($data);
                        if(
    $data == 1){
                            if(!
    is_null($data)){
                                if(
    $p->hasPermission('netsword.vip') || $p->hasPermission('netsword.vipplus') || DatabaseManager::getPlayer($p->getName())['level'] >= 8){
                                     
    ParticleManager::activateParticle(45$p);
                                }else{
                                  
    $p->sendTranslatedMessage('PARTICLE_CANT', ['VIP']);
                                }
                         }
                       }
                       if(
    $data == 2){
                if(!
    is_null($data)){
                     if(
    $p->hasPermission('netsword.vip') || $p->hasPermission('netsword.vipplus') || DatabaseManager::getPlayer($p->getName())['level'] >= 13){
                                     
    ParticleManager::acitvateParticle(46$p);
                                }else{
                                  
    $p->getCustomInventory()->show(1);
                                  
    $p->sendTranslatedMessage('PARTICLE_CANT', ['VIP']);
                     }
                 }
              }
    So when close window it do
    PHP:
    ParticleManager::activateParticle(45$p);
    and it have to do only when click first button.
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    I made it in switch() and somehow fixed it
     
  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.