local config = {
[DOLL_ID] = {female = outfitId, male = outfitId, addon = 2}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
-- Lets check if the item, is not nil
local cfg = config[item.itemid]
if not cfg then
return false
end
-- Lets check if the player has the outfit or own the addon already, then we stop the code from execute
local looktype = player:getSex() == PLAYERSEX_FEMALE and cfg.female or cfg.male
if not player:hasOutfit(looktype) or player:hasOutfit(looktype, cfg.addon) then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You do not own this outfit or you have already this addon.")
return true
end
-- Everything is fine, lets execute the code
player:addOutfitAddon(looktype, cfg.addon)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received a new addon.")
player:getPosition():sendMagicEffect(math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
item:remove()
return true
end