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

How to test for values in config?

Discussion in 'Facepalm' started by Atomization, Jan 24, 2018.

  1. Atomization

    Atomization Baby Zombie

    Messages:
    120
    GitHub:
    iAtomPlaza
    Hey, I need help with my If statement. I want to see if a condition within the config file is true, then execute the php. in what i have done, the guardian value must be set to on before is runs the code

    PHP:
    public function onJoin(PlayerJoinEvent $join){
            if(
    $this->getConfig()->get("Guardian") = on) {
                
    $player $join->getPlayer();
                
    $this->getServer()->getScheduler()->scheduleDelayedTask(new ElderGuardianTask($this$player), 30);
            }
        }
     
  2. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    change on ur config.yml guardian: on to guardian: true (or false, as u want) and delete = on
    PHP:
    if($this->getConfig()->get("Guardian")) {
     
  3. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    PHP:
    if($this->getConfig()->get("Guardian") = on) {
    :facepalm:
     
  4. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    It should be true not on
     
  5. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    if he has the config saved as "on" why would it be true :facepalm:
     
  6. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    if($this->getConfig()->get("Guardian") = true) { I meant :facepalm:
     
  7. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    == true:facepalm:
     
  8. kenygamer

    kenygamer Banned Banned

    Messages:
    106
    GitHub:
    kenygamer
    === true :facepalm:
     
  9. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    Use the code i mentioned, if you put nothing it means == true
     
  10. Andrés Komet

    Andrés Komet Creeper

    Messages:
    3
    GitHub:
    GiantQuartz
    Actually, you all
    (except you) are right
     
  11. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    If you really use hard checks if true, that's sad lmao
     
  12. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    I just forgot = :/ I already know that time I was on phone
     
  13. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    then this thread is solved alright?
     
  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.