So I am creating a KitPvP plugin and I dont know how to make it so when a player joins the game it would set their 'Points' to 0 and every time they kill someone they get 1 point abd when they die they go back to 0 points again. Then I want to be able to see how many points the player has and when they get for example 10 points it will give them upgraded items. Thanks, TheAJ471
Okay...First here is the event list that you will need: PlayerLoginEvent and PlayerDeathEvent. If you follow the bukkit plugin tutorial and know a little about java then it will be easy. If you need more help just let me know.
The_Coder So how would I add 1 point to the player who killed the dead player. (I know how to get the killer of that player btw)
FlareLine The_Coder GaaTavares So I thought of a possible easier way to do this maybe. Each time the player gets a kill I could give them 1 diamond in their inventory. So how would I get how many diamonds are in the inventory?
To check how many of an item are in someone's inventory, iterate over their whole inventory, and if an itemstack's type is diamond, add its quantity to a running total. It would also be much easier to store a Map of String (UUID for 1.7.5 forwards) to Integers storing the players' scores.
xTigerRebornx Getting/creating that whole hashmap each time would be unnecessarily taxing on processor cycles and memory.
coasterman10 xTigerRebornx So I have this. haven't tested it yet and sto is a int of 5 and I have all the inventories defined for the people like killer and stuff. Code:java if(plugin.pvp.contains(p) && pk.containsAtLeast(diamond, sto)){ killer.getInventory().setHelmet(new ItemStack(Material.AIR)); killer.getInventory().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); killer.getInventory().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); killer.getInventory().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); ItemStack sword = new ItemStack(Material.STONE_SWORD, 1); sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1); pk.addItem(sword); killer.sendMessage(ChatColor.AQUA + "You are on a" + ChatColor.GOLD + " 5 " + ChatColor.AQUA + "kill streak and have been upgraded!");
TheAJ471 That should work, though unless you specifically want them to have diamonds showing their killstreak, it would probably be better just to store it in a Map.
coasterman10 Well what I have works for now so i will probably just keep it with what I have but thanks for all the help.
It would be a lot easier to create an int to count how many kills/deaths a player has. Whenever he dies reset the int...