From 475b76b971696f421c2b28fe431644265557e66f Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 30 Oct 2024 17:53:59 -0300 Subject: [PATCH] improvement: /addaddon to support adding specific or all outfit addons --- data/scripts/talkactions/god/add_addon.lua | 45 ------------ data/scripts/talkactions/god/add_addons.lua | 76 ++++++++++++++------- data/scripts/talkactions/god/add_outfit.lua | 42 ------------ 3 files changed, 53 insertions(+), 110 deletions(-) delete mode 100644 data/scripts/talkactions/god/add_addon.lua delete mode 100644 data/scripts/talkactions/god/add_outfit.lua diff --git a/data/scripts/talkactions/god/add_addon.lua b/data/scripts/talkactions/god/add_addon.lua deleted file mode 100644 index 026336e270e..00000000000 --- a/data/scripts/talkactions/god/add_addon.lua +++ /dev/null @@ -1,45 +0,0 @@ -local addons = TalkAction("/addaddon") - -function addons.onSay(player, words, param) - -- create log - logCommand(player, words, param) - - local target - local split = param:split(",") - local name = split[1] - - if param == "" then - target = player:getTarget() - if not target then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Gives players the ability to wear addon for a specific outfit. Usage: /addaddon , ") - return true - end - else - target = Player(name) - end - - if not target then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Player " .. name .. " is currently not online.") - return true - end - - local looktype = tonumber(split[2]) - if not looktype then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Invalid looktype.") - return true - end - - local addons = tonumber(split[3]) - if not addons or addons < 0 or addons > 3 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Invalid addon.") - return true - end - - target:addOutfitAddon(looktype, addons) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Addon for looktype " .. looktype .. "a for " .. target:getName() .. " set to " .. addons .. ".") - return true -end - -addons:separator(" ") -addons:groupType("god") -addons:register() diff --git a/data/scripts/talkactions/god/add_addons.lua b/data/scripts/talkactions/god/add_addons.lua index 5498ae1e11b..3c91dbb55a6 100644 --- a/data/scripts/talkactions/god/add_addons.lua +++ b/data/scripts/talkactions/god/add_addons.lua @@ -1,8 +1,6 @@ --- /addaddons playername +local addAddons = TalkAction("/addaddons") -local addons = TalkAction("/addaddons") local looktypes = { - -- Female Outfits 136, 137, @@ -121,6 +119,12 @@ local looktypes = { 1681, -- Male Outfits + 1714, + 1723, + 1726, + 1746, + 1775, + 1777, 128, 129, 130, @@ -236,42 +240,68 @@ local looktypes = { 1662, 1675, 1680, + 1713, + 1722, + 1725, + 1745, + 1774, + 1776, } -function addons.onSay(player, words, param) - -- create log +function addAddons.onSay(player, words, param) + -- Create log logCommand(player, words, param) - local target if param == "" then - target = player:getTarget() - if not target then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Gives players the ability to wear all addons. Usage: /addaddons ") - return true - end - else - target = Player(param) + player:sendCancelMessage("Command param required.") + return true + end + + local split = param:split(",") + if #split < 3 then + player:sendCancelMessage("Usage: /addaddon , , ") + return true end + local playerName = split[1] + local target = Player(playerName) + if not target then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Player " .. param .. " is currently not online.") + player:sendCancelMessage("Player not found.") return true end - if player:getAccountType() < ACCOUNT_TYPE_GOD then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Cannot perform action.") + local addonParam = string.trim(split[2]) + local addonValue = tonumber(string.trim(split[3])) + + if not addonValue or addonValue < 0 or addonValue > 3 then + player:sendCancelMessage("Invalid addon value. It should be between 0 and 3.") return true end - for i = 1, #looktypes do - target:addOutfitAddon(looktypes[i], 3) + if addonParam == "all" then + for _, looktype in ipairs(looktypes) do + target:addOutfitAddon(looktype, addonValue) + end + + target:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added addon %d to all your looktypes.", player:getName(), addonValue)) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have successfully added addon %d to all looktypes of player %s.", addonValue, target:getName())) + else + local looktype = tonumber(addonParam) + if not looktype then + player:sendCancelMessage("Invalid looktype.") + return true + end + + target:addOutfitAddon(looktype, addonValue) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("Addon %d for looktype %d set for player %s.", addonValue, looktype, target:getName())) + target:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added addon %d for looktype %d to you.", player:getName(), addonValue, looktype)) end - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All addons unlocked for " .. target:getName() .. ".") - target:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All of your addons have been unlocked!") + logger.debug("[addAddons.onSay] - Player: {} has added addon: {} for looktype: {} to the player: {}", player:getName(), addonValue, addonParam, target:getName()) return true end -addons:separator(" ") -addons:groupType("god") -addons:register() +addAddons:separator(" ") +addAddons:groupType("god") +addAddons:register() diff --git a/data/scripts/talkactions/god/add_outfit.lua b/data/scripts/talkactions/god/add_outfit.lua deleted file mode 100644 index a27fb4f8a18..00000000000 --- a/data/scripts/talkactions/god/add_outfit.lua +++ /dev/null @@ -1,42 +0,0 @@ ---[[ - /addoutfit playername, looktype - make sure you’re adding a male outfit to a male character - if you try to add a female outfit to a male character, it won’t work -]] - -local printConsole = true - -local addOutfit = TalkAction("/addoutfit") - -function addOutfit.onSay(player, words, param) - -- create log - logCommand(player, words, param) - - if param == "" then - player:sendCancelMessage("Command param required.") - return true - end - - local split = param:split(",") - local name = split[1] - - local target = Player(name) - if target then - local lookType = tonumber(split[2]) - target:addOutfit(lookType) - target:sendTextMessage(MESSAGE_ADMINISTRATOR, "" .. player:getName() .. " has been added a new outfit for you.") - player:sendTextMessage(MESSAGE_ADMINISTRATOR, "You have sucessfull added looktype " .. lookType .. " to the player " .. target:getName() .. ".") - if printConsole then - logger.info("[addOutfit.onSay] - Player: {} has been added looktype: {} to the player: {}", player:getName(), lookType, target:getName()) - end - return true - else - player:sendCancelMessage("Player not found.") - return true - end - return true -end - -addOutfit:separator(" ") -addOutfit:groupType("god") -addOutfit:register()