Hi everyone,
I've downloaded the Addon Doll script for random outfits/addons from OpenTibiaBR (Actions | OpenTibiaBR (https://docs.opentibiabr.com/opentibiabr/downloads/revscripts/actions)). I've modified the script so that it always grants the full outfit instead of randomly giving just one addon or the second.
However, the issue I'm facing is that the Addon Doll still gets consumed and grants outfits/addons even if the player already owns them. I am using the latest Canary version.. anyone know's how to make it work so it does not gives the same outfit twice and does not consume the doll instead gives a message like "You already own this outfit" or so? (I removed most outfits from the list otherwise it's maybe too long to read)
script:
I've downloaded the Addon Doll script for random outfits/addons from OpenTibiaBR (Actions | OpenTibiaBR (https://docs.opentibiabr.com/opentibiabr/downloads/revscripts/actions)). I've modified the script so that it always grants the full outfit instead of randomly giving just one addon or the second.
However, the issue I'm facing is that the Addon Doll still gets consumed and grants outfits/addons even if the player already owns them. I am using the latest Canary version.. anyone know's how to make it work so it does not gives the same outfit twice and does not consume the doll instead gives a message like "You already own this outfit" or so? (I removed most outfits from the list otherwise it's maybe too long to read)
script:
--local actionId = 8221
local itemDollId = 40964
local outfits = {
{136, 128, "Citizen"},
{137, 129, "Hunter"},
{138, 130, "Mage"},
{1271, 1270, "Poltergeist"},
{1280, 1279, "Herder"},
{1283, 1282, "Falconer"},
{1676, 1675, "Darklight Evoker"},
{1681, 1680, "Flamefury Mage"},
{1714, 1713, "Doom Knight"},
{1723, 1722, "Draccoon Herald"},
{1726, 1725, "Celestial Avenger"},
{1746, 1745, "Blade Dancer"},
{1775, 1774, "Rootwalker"},
{1777, 1776, "Beekeeper"},
{1808, 1809, "Fiend Slayer"},
}
local randOutfit = Action("RandomOutfitForNewPlayers")
-- Strict check for full ownership of both genders and both addons
local function hasFullOutfit(player, male, female)
return player:hasOutfit(male, 1) and player:hasOutfit(male, 2)
and player:hasOutfit(female, 1) and player:hasOutfit(female, 2)
end
local function grantFullOutfit(player, male, female)
for addon = 1, 2 do
player:addOutfitAddon(male, addon)
player:addOutfitAddon(female, addon)
end
end
function randOutfit.onUse(player, item, fromPosition, target, toPosition, isHotkey)
-- Sanity check: prevent multiple actions affecting this item
if item:getId() ~= itemDollId then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "This item is not configured correctly.")
return true
end
-- Filter list of unowned outfits
local unowned = {}
for _, outfit in ipairs(outfits) do
if not hasFullOutfit(player, outfit[1], outfit[2]) then
table.insert(unowned, outfit)
end
end
if #unowned == 0 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You already own all available outfits with both addons.")
return true -- Don't consume item
end
local chosen = unowned[math.random(#unowned)]
local male, female, name = chosen[1], chosen[2], chosen[3]
grantFullOutfit(player, male, female)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE,
string.format("You obtained the full %s outfit with both addons!", name))
item:remove(1)
return true
end
randOutfit:id(itemDollId)
randOutfit:register()