Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Whats wrong?

Comments in 'Plugin Development' started by JackboyPlay, Mar 20, 2016.

  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    PHP:
    $c $this->getConfig();
    if(!(
    $c->get("m1s1") == $event->getPlayer()->getName())){
    $c->set("m1s1"$event->getPlayer()->getName());
    $c->save();
    }
    Last edited: Mar 20, 2016
  2. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    No error message
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    What are you doing there? "m1s1" is already Player::$name.
    Btw parse error on line: 3.
    PocketKiller and PEMapModder like this.
  4. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    But the player wasnt saved!
    @Primus
    Last edited: Mar 20, 2016
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If there is a red pencil in the box, change the box's content to a red pencil.
    Did anything get changed, the box originally having a red pencil or not?
  6. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    But it means if in the config in m1s1 isnt the playername it set the playername in m1s1 in the config
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No it won't.
    You see this line? You are only executing the code below if m1s1 is the player name.
    Did you actually mean != or !== ?
  8. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Okay whats the correct version? I want if the player isnt in the config at m1s1 that his name will putted in the config in m1s1
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If player name is not at m1s1
    That means, if m1s1 is not equal to player name
    That means, if player name !== value of m1s1, right?
    JackboyPlay likes this.
  10. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Oh thanks you're my HERO xD
  11. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    What is if I want that the player will be only inputted in m1s1 or if in m1s1 an another player is that the player will be inputted in m1s2?
    PHP:
    if($cf->get("m1s1") !== $event->getPlayer()->getName()){
    $cf->set("m1s1"$event->getPlayer()->getName());
    }
    if(
    $cf->get("m1s2") !== $event->getPlayer()->getName()){
    $cf->set("m1s2"$event->getPlayer()->getName());
    }
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    if($m1s1 !== $name){
      
    $m1s1 $name;
    }else{
      
    $m1s2 $name;
    }
    But you can achieve this more easily through an array.
  13. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @PEMapModder I have an problem, the player will be inputted in m1s1 and m1s2 and I want that he will only inputted in one of they two like:
    PHP:
    m1s1player1
    m1s2
    player2

    and not

    m1s1
    player1
    m1s2
    player2
    And no I'm to dump for arrays
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Hmm... What is different between the two?
  15. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    the name
  16. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Suggestion: Use Sessions or cache data and save it to config onDisable() if necessary.
    JackboyPlay likes this.
  17. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Whuuuuttttttttttt?
  18. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I assume you're creating 1 versus 1 duel plugin, right? If so, it's not necessary to write data immediately.
  19. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    I write a QSG Plugin :D
  20. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    But without multiworld and the plugin sends the players the message so:
    PHP:
    $this->getServer()->getPlayer($this->getConfig()->get("m1s1"))->sendMessage("Youre Player1");
    $this->getServer()->getPlayer($this->getConfig()->get("m1s2"))->sendMessage("Youre Player2");
    $this->getServer()->getPlayer($this->getConfig()->get("m1s3"))->sendMessage("Youre Player3");
    $this->getServer()->getPlayer($this->getConfig()->get("m1s4"))->sendMessage("Youre Player4");
    And if the player klicks on the sign :
    PHP:
    if($cf->get("m1s1") !== $event->getPlayer()->getName()){
    $cf->set("m1s1"$event->getPlayer()->getName());
    }
    if(
    $cf->get("m1s2") !== $event->getPlayer()->getName()){
    $cf->set("m1s2"$event->getPlayer()->getName());
    }
    if(
    $cf->get("m1s3") !== $event->getPlayer()->getName()){
    $cf->set("m1s3"$event->getPlayer()->getName());
    }
    if(
    $cf->get("m1s4") !== $event->getPlayer()->getName()){
    $cf->set("m1s4"$event->getPlayer()->getName());
    }
    But if the player klicks on the sign the player1's name will be inputted in m1s1 and m1s2 and m1s3 and m1s4

Share This Page

Advertisement