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

Position verification

Discussion in 'Development' started by PiloudeDakar, Jul 26, 2021.

  1. PiloudeDakar

    PiloudeDakar Witch

    Messages:
    62
    GitHub:
    piloudedakar
    Hello, I'm doing a quest plugin (it will be public in the lite version), and I need to verificate if player is on a certain position. I did it but it doesn't work. I tried several techniques so if you see inconsistencies it's normal.

    Here is my code :

    PHP:
        public function onPlayerMove(PlayerMoveEvent $event){
            
    $player $event->getPlayer();
            foreach (
    $this->quests as $quest) {
                if (
    $quest instanceof Quest) {
                    
    $type $quest->getType();
                    
    $playerPos $player->getPosition();
                    if (
    $type == QuestTypes::WALK_POINT){
                        
    $quest_data = new Config($this->getDataFolder() . 'quests/' $quest->getName() . '.yml');
                        
    $level $objectiveValue[3];
                        if (
    $playerPos->getFloorX() == $quest_data->get('value_x') && $playerPos->getFloorY() == $quest_data->get('value_y') && $playerPos->getFloorZ() == $quest_data->get('value_z') && $playerPos->getLevelNonNull()->getName() == $quest_data->get('value_level')) {
                            if (
    file_exists($this->getDataFolder() . 'players/' $player->getName() . '.yml')) {
                                
    $player_data = new Config($this->getDataFolder() . 'players/' $player->getName() . '.yml'Config::YAML);
                                if (
    $player_data->exists($quest->getName())) {
                                    
    $player_data->setNested($quest->getName() . '.value''finish');
                                    
    $player_data->save();
                                    
    $this->questFinish($quest$player$player_data);
                                }
                            }
                        }
                    }
                }
            }
        }
    And here is my .yml quest data :
    PHP:
    nameWalkpoint-item
    description
    Walk to 0 150 0 in world
    type
    #Walkpoint
    codewalkitem
    reward
    :
      - 
    #Give item
      
    64
      
    "1:0"
      
    -
      -
    value_x0
    value_y
    150
    value_z
    0
    value_level
    world
     
  2. PiloudeDakar

    PiloudeDakar Witch

    Messages:
    62
    GitHub:
    piloudedakar
    Update : I did experimentations and that's the config's get function who don't work
     
  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.