commit 893ed2014c400150f76e8c01c46916939d59d040 Author: Ruthenic Date: Wed Jun 29 00:56:20 2022 -0400 BetterKill diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..65e3ba2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +test/ diff --git a/BetterKill/main.lua b/BetterKill/main.lua new file mode 100644 index 0000000..f11f757 --- /dev/null +++ b/BetterKill/main.lua @@ -0,0 +1,93 @@ +IsRelease = false + +HelpMessage = "- BetterKill\n" .. + " literally just a better kill command because Core's sucks\n" .. + "Examples:\n" .. + " /bkill Player - kills the player named 'Player'\n" .. + " /bkill mtWither - kills all Withers known to the server\n" + +MobTypeTable = { + [-1] = "mtInvalid", + [0] = "mtBat", + [1] = "mtBlaze", + [3] = "mtCaveSpider", + [4] = "mtChicken", + [6] = "mtCow", + [7] = "mtCreeper", + [12] = "mtEnderDragon", + [13] = "mtEnderman", + [17] = "mtGhast", + [18] = "mtGiant", + [19] = "mtGuardian", + [20] = "mtHorse", + [24] = "mtIronGolem", + [26] = "mtMagmaCube", + [27] = "mtMooshroom", + [29] = "mtOcelot", + [33] = "mtPig", + [34] = "mtPiglin", + [35] = "mtPiglinBrute", + [39] = "mtRabbit", + [42] = "mtSheep", + [44] = "mtSilverfish", + [45] = "mtSkeleton", + [46] = "mtSkeletonHorse", + [47] = "mtSlime", + [48] = "mtSnowGolem", + [49] = "mtSpider", + [50] = "mtSquid", + [57] = "mtVillager", + [60] = "mtWitch", + [61] = "mtWither", + [62] = "mtWitherSkeleton", + [63] = "mtWolf", + [65] = "mtZombie", + [66] = "mtZombieHorse", + [67] = "mtZombiePigman", + [68] = "mtZombieVillager" +} + + +function Initialize(Plugin) + Plugin:SetName("BetterKill") + Plugin:SetVersion(1) + + cPluginManager.BindCommand("/bkill", "betterkill.bkill", OnCommandIssued, HelpMessage) + + LOG("Initalized BetterKill v" .. Plugin:GetVersion() .. (IsRelease == false and "-rc" or "")) + return true +end + +function OnCommandIssued(args, player) + LOG("Trying to kill.. something") + + if (#args < 2) then + player:SendMessage("Incorrect usage of /bkill. Please see /help bkill") + return true + end + + table.remove(args, 1) + + for _, testMTStr in ipairs(args) do + local i = 0 + + local doThing = function(entity) + if entity:IsMob() then + local mt = entity:GetMobType() + if (MobTypeTable[mt] == testMTStr) then + entity:TakeDamage(17, nil, 9999999, 9999999, 0) + i = i + 1 + end + else + -- player:SendMessage("Apologies, but BetterKill does not currently support non-mobs!") + end + end + + player:GetWorld():ForEachEntity(doThing) + + player:GetWorld():BroadcastChatDeath("Killed " .. i .. " " .. testMTStr .. "s!") + + end + + return true +end