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

Solved time() Error

Discussion in 'Development' started by BLOCKSTORM, Mar 25, 2018.

  1. BLOCKSTORM

    BLOCKSTORM Witch

    Messages:
    67
    Hello everyone,
    actually i'm coding an bansystem, but i'm having an issue with it.
    PHP:
    public function onJoin(PlayerPreLoginEvent $event){
        if(
    file_exists("/UniverseMC/AIOMod/Spieler/" $event->getPlayer()->getName() .".yml")){
            
            
    $cfg = new Config("/UniverseMC/AIOMod/Spieler/" $event->getPlayer()->getName() . ".yml"Config::YAML);
            if(
    $cfg->get("Aktiv") != null){
                
                
    $ban = new Config("/UniverseMC/AIOMod/Bans/" $cfg->get("Aktiv") . ".yml"Config::YAML);
                
                
                if(
    $ban->get("Dauer") == "Permanent"){
                    
    $event->getPlayer()->kick("§cDein Account auf dem §bNetzwerk§c wurde gesperrt. \n §cGrund: §e" $ban->get("Grund") . "§7[§c" $cfg->get("Aktiv") . "§7] §7| §cDauer: §4PERMANENT \n§aEA: §b§lrevengermc.de/support"false);
    }else{
    $jz time();
    $time $ban->get("Dauer") - $jz;
    #if($ban->get("Dauer") > $jz){

                
    if($time 86400){
                    
    $event->getPlayer()->kick("§cDein Account auf dem §bNetzwerk§c wurde gesperrt. \n §cGrund: §e" $ban->get("Grund") . "§7[§c" $cfg->get("Aktiv") . "§7] §7| §cDauer: §4".round($time/864000)." §eTag(e)\n§aEA: §b§lrevengermc.de/support"false);
                }elseif(
    $time 3600){
                    
    $event->getPlayer()->kick("§cDein Account auf dem §bNetzwerk§c wurde gesperrt. \n §cGrund: §e" $ban->get("Grund") . "§7[§c" $cfg->get("Aktiv") . "§7] §7| §cDauer: §4".round($time/36000)." §eStunde(n)\n§aEA: §b§lrevengermc.de/support"false);
                }elseif(
    $time 60){
                    
    $event->getPlayer()->kick("§cDein Account auf dem §bNetzwerk§c wurde gesperrt. \n §cGrund: §e" $ban->get("Grund") . "§7[§c" $cfg->get("Aktiv") . "§7] §7| §cDauer: §4".round($time/600)." §eMinute(n)\n§aEA: §b§lrevengermc.de/support"false);
    }


    /**}else{
        $cfg->set("Aktiv", null);
        $cfg->save();
        $ban->set("Status", "Inaktiv");
        $ban->save();
    }**/
    }
    }
    }else{
    $cfg = new Config("/UniverseMC/AIOMod/Spieler/" $event->getPlayer()->getName() . ".yml"Config::YAML);
                
    $cfg->set("Aktiv"null);
                
    $cfg->set("Punkte"null);
                
    $cfg->save();
    }
    }
    Assuming $ban->get("Dauer") is 7000000, then why dont this works? it resets the player file with the }else{ clause instead of kicking the player.
    Regards,
    BLOCKSTORM_
     
  2. BLOCKSTORM

    BLOCKSTORM Witch

    Messages:
    67
    Please remove the # and /**, that was just to test
     
  3. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    Does $ban->get('Dauer') return an unix timestamp?
     
  4. BLOCKSTORM

    BLOCKSTORM Witch

    Messages:
    67
    No, it was a really stupid fault by me. It has to be "<", not ">".
    //Closed thread
     
  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.