party leader changes his team's outfite and colour
Explanation of the use of party leader !outfit 143, 94, 86, 79, 77
Explanation of the use of party leader !outfit 143, 94, 86, 79, 77
Lua:
--Explanation of the use of party leader !outfit 143, 94, 86, 79, 77
local bannedOutfits = {
[1] = true, -- Addons: 3, 2, 1 Players cannot use it
[75] = true, -- Addons: 3, 2, 1 Players cannot use it
[264] = true, -- Addons: 3, 2, 1 Players cannot use it
[266] = true, -- Addons: 3, 2, 1 Players cannot use it
-- Add any outfits with IDs 300 or higher to be banned
}
for outfitID = 300, 99999999 do
bannedOutfits[outfitID] = true
end
local outfit = TalkAction("!outfit")
function outfit.onSay(player, words, param)
local party = player:getParty()
if not party or party:getLeader() ~= player then
player:sendCancelMessage("You need to be the party leader to use this command.")
return false
end
-- Parse parameters
local params = param:split(",")
if #params < 5 then
player:sendCancelMessage("Usage: !outfit lookType, lookHead, lookBody, lookLegs, lookFeet")
return false
end
local lookType = tonumber(params[1]:trim())
local lookHead = tonumber(params[2]:trim())
local lookBody = tonumber(params[3]:trim())
local lookLegs = tonumber(params[4]:trim())
local lookFeet = tonumber(params[5]:trim())
if not lookType or not lookHead or not lookBody or not lookLegs or not lookFeet then
player:sendCancelMessage("All parameters must be valid numbers.")
return false
end
-- Check if the outfit is banned
if bannedOutfits[lookType] then
player:sendCancelMessage("This outfit is banned and cannot be used.")
return false
end
local newOutfit = {
lookType = lookType,
lookHead = lookHead,
lookBody = lookBody,
lookLegs = lookLegs,
lookFeet = lookFeet,
lookAddons = 3
}
-- Apply the outfit to all party members
for _, targetPlayer in ipairs(party:getMembers()) do
if targetPlayer then
targetPlayer:setOutfit(newOutfit)
targetPlayer:getPosition():sendMagicEffect(CONST_ME_BATS)
end
end
-- Apply the outfit to the leader as well
player:setOutfit(newOutfit)
player:getPosition():sendMagicEffect(CONST_ME_BATS)
return false
end
function string:split(sep)
local result = {}
for match in (self .. sep):gmatch("(.-)" .. sep) do
table.insert(result, match)
end
return result
end
function string:trim()
return self:match("^%s*(.-)%s*$")
end
outfit:separator(" ")
outfit:register()