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

Player points system

Comments in 'Plugin Development' started by LoveToBeDev, Aug 31, 2015.

  1. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    Hello Guys, im trying to make a new plugin, but as im learning more advanced things, i was wondering how can i make a points system, like if a player kills another player, he gets a point, but i want to make a command that like gets the points in total of the player and it sends to the $sender the point count. i think i need a Player.yml file, but i never worked in that before, can you help me?? thanks??

    like here:
    If player executes "/myscore"
    tab should appear like here:
    oh, and like, to make a tab where the players with most points appear (obviously executing a command).

    like to appear like this:

    If player executes "/best"
    tab should appear like here:
    If you have a video tutorial or something like that, please share ill be very grateful, thanks!!!!!!!!!!!

    KEEP IN MIND THAT IM NOT ASKING YOU TO MAKE THE FULL PLUGIN FOR ME, THANKS FOR UNDERSTANDING.
  2. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev

    Ummmm, i really didnt understand, i tried to implement the code, but the problem is that it says that the "if" has a problem, and like, the command to get the list???
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    You will need to create a playerfile inside of a players folder for each player that joins.
    To create the folder:
    PHP:
    public function onEnable() {
      @
    mkdir($this->getDataFolder() . "Players/");
    }
    To create the playerfiles:
    PHP:
    public function onJoin(PlayerJoinEvent $event) {
      
    $player $event->getPlayer();
      
    $this->player = new Config($this->getDataFolder() . "Players/" strtolower($player->getName()), Config::YAML, array(
      
    "points" => 0
    ));
    $this->player;
    }
    And you can give a player a point when they die like:
    PHP:
    $points $this->player->get("points");
    $this->player->set("points"$points 1);
    $this->player->save(); 
  4. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    so, i need to create a folder called players? and inside of it a players.yml?
  5. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Use
    PHP:
     @mkdir($this->getDataFolder() . "Players/"); 
    to make the players folder.
  6. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    like this?
    PHP:
     public function onJoin(PlayerJoinEvent $event) {
            
    $player $event->getPlayer();
            
    $this->player = new Config($this->getDataFolder() . "Players/" strtolower($player->getName()), Config::YAML, array(
            
    "points" => 0));
            
    $this->player;
            
    $points $this->player->get("points");
    $       
    $this->player->set("points"$points 1);
    $       
    $this->player->save();
        }
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Your supposed to give them points when they die, right? Your giving them points when they join.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Learn PHP. It is just a simple syntax error that you should be able to fix yourself. Actually, you don't even need to know PHP to fix it, if you have a functional usable cerebrum.
    CraftYourBukkit and Primus like this.

Share This Page

Advertisement