First question, is there a way to boost a player's damage without using strength? I am sorry if something similar was posted previously. I searched everywhere but couldn't find one that fit my need. Second question, I am not really familiar with time(), so could someone teach me how to set a cooldown on item use event? Thank you!
yes, you can add more damages by function EntityDamageByEntityEvent, you can do this like: PHP: /*** @param EntityDamageByEntityEvent $event*/public function onPvP(EntityDamageByEntityEvent $event) { $player = $event->getEntity(); $damager = $event->getDamager(); if ($damager instanceof Player && $player instanceof Player) { //check if player won't damage mobs or ... $player->setHealth($player->getHealth() - 2); //every 2 damage = 1 Heart in Minecraft }} now its done, every damage by players, you lose (({sword_damage} or {Tools_Damage} or hand damage)) + 1 heart its boosted
or you can check if item in damafer hand is Sword like this code (if player damaging you by hand your damaging speed won't boost) : PHP: /*** @param EntityDamageByEntityEvent $event*/public function onPvP(EntityDamageByEntityEvent $event) { $player = $event->getEntity(); $damager = $event->getDamager(); if ($damager instanceof Player && $player instanceof Player) { //check if player won't damage mobs or ... if ($damager->getInventory()->getItemInHand() instanceof Sword) { //check if you are damaging by sword $player->setHealth($player->getHealth() - 2); //every 2 damage = 1 Heart in Minecraft } }} Done?
also in the end if you want to check if player damaging you by hand use this code: PHP: /*** @param EntityDamageByEntityEvent $event*/public function onPvP(EntityDamageByEntityEvent $event) { $player = $event->getEntity(); $damager = $event->getDamager(); if ($damager instanceof Player && $player instanceof Player) { //check if player won't damage mobs or ... if ($damager->getInventory()->getItemInHand()->getId() === Item::AIR) { //check if you are damaging by Hand $player->setHealth($player->getHealth() - 2); //every 2 damage = 1 Heart in Minecraft } }}
search it on forum, i remember i anwsered a person with this problem and his problem solved. also im using task for cooldown, its better in my mind . if you want to know about create task with cooldown just look at my plugin, and for timezone(0 first read a bout this function on php.net, then see my paste thread, i told a person how is that possible .
Check these two posts: https://forums.pmmp.io/threads/how-top-create-a-command-cooldown.10050/#post-73687 https://forums.pmmp.io/threads/how-can-i-delay-the-use-of-items.10184/page-2#post-74432