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

Help me for config

Discussion in 'Plugin Help' started by Mochi, May 7, 2020.

  1. Mochi

    Mochi Baby Zombie

    Messages:
    113
    how to save the player kill status to config

    Loader:
    PHP:
    $kills = new Config($this->getDataFolder()."kills.yml"Config::YAML);
    SWArena:
    PHP:
    public function getKills($name){
            return 
    $this->kills[$name];
            
    $this->kills->save();
        }
       
        public function 
    addKills($name){
            
    $this->kills[$name] += 1;
        }
       
        public function 
    getLastHit($name){
            
    $time time();
            if(isset(
    $this->lastHit[$name])){
                
    $data $this->lastHit[$name];
                if((
    $time $data['time']) >= 8){
                    return 
    false;
                }
                return 
    $data['damager'];
            }
            return 
    false;
        }
    SWListener:
    PHP:
    $arena->addKills($arena->getLastHit($player->getName()));
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    (if $config is your Config object and $this->kills is just an array as used by the code you provided)
    PHP:
    $config->set("kills"$this->kills);
    $config->save(); // saves the data to the file
    To retrieve the data:
    PHP:
    $this->kills $config->get("kills");
     
  3. Mochi

    Mochi Baby Zombie

    Messages:
    113
    where should i put it
     
  4. Mochi

    Mochi Baby Zombie

    Messages:
    113
    do i have to put it in the kill function, can you help me to put the code sir?
     
  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.