Kill streak help?

Discussion in 'Plugin Development' started by jasonderlo22, Jul 19, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    jasonderlo22

    How would I do this: If someone kills another player I add an apple to their inventory and then after that cooked steak so like if there is a 2 kill streak. It keeps going. I tried onPlayerKillEvent, but there is no such thing. So every 1 kill it adds an apple, then the next on it adds cooked porkchop, then melon........ And how would I make it so that the food makes your heath go up? Anyway thanks if you could help me that would be fantastic. And how I would add this to my plugin.yml.

    Thanks jasonderlo22
     
  2. Offline

    ZeusAllMighty11 Retired Staff

    PlayerDeathEvent is the event


    Store players in a hashmap, with their name and the killstreak they are on


    Add what to your plugin.yml?
     
  3. Offline

    jasonderlo22

    I'm sorry if I sound nooby. But I'm new to bukkit, how would I do what your talking about? Sorry :(
     
  4. Offline

    Loogeh

    jasonderlo22 If you don't know how to use events and hashmaps, look it up on youtube. I think TheNewBoston has a good HashMap tutorial (because he does good java tuts).

    What you would do is you would do is have a HashMap which stores a String (as the player name) and an Integer (as the amount of kills). You would use the PlayerDeathEvent as TheGreenGamerHD said and check if the hashmap contains the killer's name. Next, if it does, you would get the integer from the map using yourMapNameHere.get(player.getName()) and add 1 to it. Else if it doesn't contain the killer's name you would put them in there with the integer with a value of 1 using yourMapNameHere.put(player.getName(), 1)

    Also, i'm pretty sure you're try to replicate MCInfected's killstreak system hahaha :)

    Oh and I forgot about the items. In the same PlayerDeathEvent you would check if the integer is equal to a number of your choice and then give them an item of your choice.

    Example

    Code:java
    1. if(yourMap.get(player.getName()) == 2) {
    2. player.getInventory().addItem(new ItemStack(Material.APPLE));
    3. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  5. Offline

    jasonderlo22

    Loogeh Will Bukkit automatically know that 2 = 2 kills, or do I have to define it?
     
  6. Offline

    Loogeh

    jasonderlo22 No, it doesn't know that they're kills but you don't have to define them as kills. You just get if the integer is 2 then give them an apple. It doesn't know that they're kills but because you're adding 1 to the integer every time a player gets a kill, it's still holding the amount of kills. Then when they die, you set the amount to 0, or remove them from the map and re-add them.

    If you don't know anything about HashMaps, watch this video.

    I haven't actually watched it but i think it will be an informative and helpful tutorial.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  7. Offline

    jasonderlo22

    Loogeh IS it up to date?

    I'm actually on MCi, I'm making a custom plugin like that and I need a kill streak, I don't want to be like minecustoms! :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  8. Offline

    Loogeh

    Yeah I checked the Super gaming website hahaha. I used to be one of the best players on there, in the top 10 :) Back in August last year I think. I would've been the 3rd person to get 10000 kills if I didn't quit.
    Also, that tutorial should be up to date, I don't think Java is changed that much.
     
  9. Offline

    jasonderlo22

    Loogeh We should play together on MCi and the new gamemodes they have implemented :)
     
  10. Offline

    microgeek

    Generally speaking stuff like that stays the same from version to version of Java.
     
  11. Offline

    jasonderlo22

Thread Status:
Not open for further replies.

Share This Page