Skip to content

Commit

Permalink
improvement: /addaddon to support adding specific or all outfit addons
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires committed Oct 31, 2024
1 parent 08c1ead commit 475b76b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 110 deletions.
45 changes: 0 additions & 45 deletions data/scripts/talkactions/god/add_addon.lua

This file was deleted.

76 changes: 53 additions & 23 deletions data/scripts/talkactions/god/add_addons.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
-- /addaddons playername
local addAddons = TalkAction("/addaddons")

local addons = TalkAction("/addaddons")
local looktypes = {

-- Female Outfits
136,
137,
Expand Down Expand Up @@ -121,6 +119,12 @@ local looktypes = {
1681,

-- Male Outfits
1714,
1723,
1726,
1746,
1775,
1777,
128,
129,
130,
Expand Down Expand Up @@ -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 <player name>")
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 <player name>, <looktype or 'all'>, <value>")
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()
42 changes: 0 additions & 42 deletions data/scripts/talkactions/god/add_outfit.lua

This file was deleted.

0 comments on commit 475b76b

Please sign in to comment.