Files
kill-sword.sk
Code
1 206
kill-sword.sk
# Kill Sword
# Requires: Skript 2.9+ on Minecraft Java 1.21.x
# No addon is required.
options:
sword-name: &6Kill Sword
menu-title: &8Kill Sword - Choose Ability
function makeKillSword(p: player) :: item:
set {_kills} to {ks.kills::%uuid of {_p}%}
set {_ability} to {ks.ability::%uuid of {_p}%}
if {_kills} is not set:
set {_kills} to 0
if {_kills} <= 0:
set {_sword} to wooden sword named "{@sword-name}"
else if {_kills} = 1:
set {_sword} to stone sword named "{@sword-name}"
else if {_kills} = 2:
set {_sword} to iron sword named "{@sword-name}"
else if {_kills} = 3:
set {_sword} to diamond sword named "{@sword-name}"
else:
set {_sword} to netherite sword named "{@sword-name}"
set lore of {_sword} to "&7Kills: &f%{_kills}%"
add "&7Ability: &f%{_ability}%" to lore of {_sword}
if {_ability} is "SHARPNESS VI":
enchant {_sword} with sharpness 6
return {_sword}
function hasKillSword(p: player) :: boolean:
loop all items in {_p}'s inventory:
if loop-item is not air:
if name of loop-item is "{@sword-name}":
return true
return false
function giveKillSword(p: player):
give makeKillSword({_p}) to {_p}
function openKillMenu(p: player):
open chest inventory with 1 row named "{@menu-title}" to {_p}
wait 1 tick
if {_p} is online:
set slot 2 of {_p}'s current inventory to feather named "&e🪶 DASH" with lore "&7اندفاع سريع إلى الأمام."
set slot 4 of {_p}'s current inventory to enchanted book named "&bSHARPNESS VI" with lore "&7يحصل Kill Sword على Sharpness VI."
set slot 6 of {_p}'s current inventory to potion named "&d🧪 SHRINK" with lore "&7تصغير الحجم إلى 0.5 لمدة 20 ثانية."
on join:
set {_id} to uuid of player
if {ks.kills::%{_id}%} is not set:
set {ks.kills::%{_id}%} to 0
if hasKillSword(player) is false:
giveKillSword(player)
if {ks.kills::%{_id}%} >= 4:
if {ks.ability::%{_id}%} is not set:
wait 2 ticks
if player is online:
openKillMenu(player)
on respawn:
wait 1 tick
loop all items in player's inventory:
if loop-item is not air:
if name of loop-item is "{@sword-name}":
remove loop-item from player's inventory
giveKillSword(player)
on quit:
set {_id} to uuid of player
if {ks.shrinking::%{_id}%} is set:
execute console command "attribute %player% minecraft:scale base set 1"
delete {ks.shrinking::%{_id}%}
on death of player:
set {_id} to uuid of player
set {ks.kills::%{_id}%} to 0
delete {ks.ability::%{_id}%}
delete {ks.cooldown::%{_id}%}
delete {ks.shrinking::%{_id}%}
execute console command "attribute %player% minecraft:scale base set 1"
loop drops:
if loop-item is not air:
if name of loop-item is "{@sword-name}":
remove loop-item from drops
on death of player:
if attacker is a player:
set {_killer} to attacker
set {_killer-id} to uuid of {_killer}
if name of {_killer}'s tool is "{@sword-name}":
if {ks.kills::%{_killer-id}%} is not set:
set {ks.kills::%{_killer-id}%} to 0
add 1 to {ks.kills::%{_killer-id}%}
set {_kills} to {ks.kills::%{_killer-id}%}
set {_killer}'s tool to makeKillSword({_killer})
if {_kills} >= 4:
if {ks.ability::%{_killer-id}%} is not set:
wait 1 tick
if {_killer} is online:
openKillMenu({_killer})
on right click:
if name of player's tool is not "{@sword-name}":
stop
set {_id} to uuid of player
if {ks.kills::%{_id}%} < 4:
stop
if {ks.ability::%{_id}%} is not set:
openKillMenu(player)
stop
if {ks.ability::%{_id}%} is "SHRINK":
if player is not sneaking:
stop
if {ks.cooldown::%{_id}%} is set:
if difference between now and {ks.cooldown::%{_id}%} is less than 20 seconds:
send action bar "&cKill Sword ability is on cooldown." to player
stop
set {ks.cooldown::%{_id}%} to now
set item cooldown of player's tool for player to 20 seconds
if {ks.ability::%{_id}%} is "DASH":
push player forwards at speed 1.35
push player upwards at speed 0.35
loop 20 times:
wait 1 second
if {_id} is set:
if {ks.cooldown::%{_id}%} is set:
if loop-number < 20:
send action bar "&6Kill Sword &7Cooldown: &e%20 - loop-number% seconds" to player
delete {ks.cooldown::%{_id}%}
stop
if {ks.ability::%{_id}%} is "SHRINK":
set {ks.shrinking::%{_id}%} to true
execute console command "attribute %player% minecraft:scale base set 0.5"
loop 20 times:
wait 1 second
if player is online:
if {ks.cooldown::%{_id}%} is set:
if loop-number < 20:
send action bar "&dShrink &7Remaining: &e%20 - loop-number% seconds" to player
execute console command "attribute %player% minecraft:scale base set 1"
delete {ks.shrinking::%{_id}%}
delete {ks.cooldown::%{_id}%}
on inventory click:
if name of event-inventory is "{@menu-title}":
cancel event
if clicked slot is 2:
set {ks.ability::%uuid of player%} to "DASH"
send "&aYour Kill Sword ability is now &eDASH&a." to player
close player's inventory
else if clicked slot is 4:
set {ks.ability::%uuid of player%} to "SHARPNESS VI"
set player's tool to makeKillSword(player)
send "&aYour Kill Sword now has &bSharpness VI&a." to player
close player's inventory
else if clicked slot is 6:
set {ks.ability::%uuid of player%} to "SHRINK"
send "&aYour Kill Sword ability is now &dSHRINK&a." to player
close player's inventory
on inventory drag:
if name of event-inventory is "{@menu-title}":
cancel event
on inventory close: