I am trying to make a system of rewards for killing wither skeletons and it makes the server lag due to the "else if"s, I want to use functions and someone told me to use:
My code:
If anyone could help it would be greatly appreciated.
Code:
function checkChance(chance: number, number: number) :: boolean:
return true if {_chance} <= {_number} else false
My code:
Code:
on script load:
set {-coin} to sunflower of unbreaking 10 named "&6&lCoin"
on death:
if attacker is a player:
if victim is a wither skeleton:
clear drops
set {-chance} to a random integer between 1 and 100
if {-chance} is less than or equal to 60:
drop 1 netherite block at victim
send "&7You got 1 netherite block" to attacker
else if {-chance} <= 89:
drop 3 of {-coin} at victim
send "&6You got 3 coins" to attacker
else if {-chance} <= 95:
drop 8 of {-coin} at victim
send "&6You got 8 coins" to attacker
else if {-chance} <= 99:
drop 10 of {-coin} at victim
send "&6You got 10 coins" to attacker
else if {-chance} <= 100:
drop 32 of {-coin} at victim
send "&6&lJackPot! (32 coins)" to attacker
If anyone could help it would be greatly appreciated.