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

if player kill 5

Comments in 'Plugin Development' started by JUZEXMOD, Oct 14, 2016.

  1. JUZEXMOD
    Offline

    JUZEXMOD New Member

    Joined:
    May 28, 2016
    Posts:
    19
    Minecraft User:
    JUZEXMOD
    Hellow

    i need a simple code

    Example:

    give player Diamond Sword on Kill 5 Players
  2. JUZEXMOD
    Offline

    JUZEXMOD New Member

    Joined:
    May 28, 2016
    Posts:
    19
    Minecraft User:
    JUZEXMOD
  3. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
  4. corytortoise
    Offline

    corytortoise New Member

    Joined:
    Aug 23, 2015
    Posts:
    10
    Minecraft User:
    corytortoise
    This isn't that simple, you have to store the data for kills somewhere, and use that to manage when to give a player the sword.
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You shouldn't ask for the code, but for an idea how to do it. Otherwise you would just copy it, probably call the plugin your own one and never learn it.

    Create a public(or whatever you want) array where you store each player's amount of kills inside. When the player kills someone, +1 it.

    If the value is 5, then do something.
    archie426 and Nawaf_Craft1b like this.
  6. dktapps
    Offline

    dktapps Active Member

    Joined:
    Jul 25, 2016
    Posts:
    101
    Needlessly pinging people also isn't going to get you anywhere.
  7. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    PHP:
    public $killstreak = [];

    // Join
    $this->killstreak[$event->getPlayer()->getName()] = 0;

    // Quit
    unset($this->killstreak[$event->getPlayer()->getName()]);

    // death
    $this->killstreak[$event->getPlayer()->getName()] = 0;

    // if player kill other player && diamond sword on killstreak
    $this->killstreak[$killer->getName] + 1;

    if(
    $this->killstreak[$killer->getName()] == 5){
    // give player diamond sword...
    }
    i dont test this but i hope i help you :)
    Last edited: Oct 15, 2016
    Thunder33345 likes this.
  8. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    since you are in plugin
    theoritically should work fine
    PaulchenHD likes this.
  9. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Set it to 0 at death as well, since it's killstreak and not total kills
    PaulchenHD likes this.
  10. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    fixed :)
    CraftYourBukkit likes this.
  11. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    # to add 1 kills
    $killarray{$n} += 1;
    # To Check
    if(!isset($killarray[$n])){
    // add Player to array
    }
  12. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    He is adding him on join
    PaulchenHD likes this.

Share This Page

Advertisement