Damage sorter

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

2844

New Member
Nov 21, 2020
6
0
1
24
I want to give something to the player that did the most damage to a mob

Code:
every 1 hour:
    send title "&c&lBOSS" with subtitle "&fBoss just spawned! /boss" to all players for 5 seconds
    play sound "entity.lightning_bolt.impact" with volume 70 to all players
    spawn 1 of zombie at will put it later
    equip last spawned zombie with diamond chestplate of protection 2
    equip last spawned zombie with diamond leggings of protection 2
    equip last spawned zombie with netherite boots of protection 3
    set last spawned zombie's held item to iron sword of sharpness 3
    set last spawned zombie's max health to 100
    set last spawned zombie's health to 100
    set display name of last spawned zombie to "&c&lBoss Zombie"


on death:
    if display name of victim is "&c&lBoss Zombie":
        set {_r} to random integer between 500 and 5000
        cancel drops
        #give {r} of emerald to %player who did most damage%
 
try getting the damage from on damage event and saving it as variable

so something like this

Code:
on damage:
 if attacker is player:
  if victim's name is "name of the boss":
   add damage to {%player%.bossdamage}
 
try getting the damage from on damage event and saving it as variable

so something like this

Code:
on damage:
 if attacker is player:
  if victim's name is "name of the boss":
   add damage to {%player%.bossdamage}

yeah but how do i sort it after so it gives to the one that did most damage?
 
You could use a list variable with all the players that dealt damage and the damage then
sort the list from highest to lowest do stuff accordingly, Just not sure how and what would be the most
efficient way
 
You can add damage to a list:
Code:
add damage to {bossdamage::%player%}
Then, sort it. Have a look here if you're not sure how.

When you're done, you can delete all the variables and start again:
Code:
clear {bossdamage::*}
 
so damage is a class double(means its a number)
so you can add the amount of damage that the player gave to his own variable.
example:
Code:
on damage:
  if vicitm's name is "bossname":
    add damage to {bossdamage::%player%}
then when the boss dies you can check who has the most
 
Status
Not open for further replies.