• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ Action add addon with item requirement

wizinx

Active Member
Joined
Jul 6, 2010
Messages
202
Solutions
3
Reaction score
46
Location
Chile, Santiago
Hello everyone, I have a script to add an addon when using the item, but my problem is that I want to make it take an amount of X of items to add it.

example: for the druid outfit ---> 100 wolf paw and bear paws.

this is the script i currently have, i have tried but give up, thanks.

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You received the Bear Paw outfit.")
        player:getPosition():sendMagicEffect(13)
        player:addOutfitAddon(169, 3)
        player:addOutfitAddon(168, 3)
    
    Item(item.uid):remove(1)
     return true
end
 
Solution
data/action/scripts/outfitbearpaw.lua
Lua:
local requirements = {
    {5896, 100}, -- Bear Paw
    {5897, 100} -- Wolf Paw
}

local addons = {169,168}

function onUse(player, item, fromPos, target, toPos, isHotkey)
    if player:hasOutfit(addons[1], 3) and player:hasOutfit(addons[2], 3) then
        player:sendCancelMessage("You already have this outfit.")
        return true
    end

    for _, req in pairs(requirements) do
        if player:getItemCount(req[1]) < req[2] then
            player:sendCancelMessage("Sorry, you need 100 bear paw and 100 wolf paw.")
            return true
        end
    end

    for _, req in pairs(requirements) do
        player:removeItem(req[1], req[2])
    end...
data/action/scripts/outfitbearpaw.lua
Lua:
local requirements = {
    {5896, 100}, -- Bear Paw
    {5897, 100} -- Wolf Paw
}

local addons = {169,168}

function onUse(player, item, fromPos, target, toPos, isHotkey)
    if player:hasOutfit(addons[1], 3) and player:hasOutfit(addons[2], 3) then
        player:sendCancelMessage("You already have this outfit.")
        return true
    end

    for _, req in pairs(requirements) do
        if player:getItemCount(req[1]) < req[2] then
            player:sendCancelMessage("Sorry, you need 100 bear paw and 100 wolf paw.")
            return true
        end
    end

    for _, req in pairs(requirements) do
        player:removeItem(req[1], req[2])
    end

    player:addOutfitAddon(addons[1], 3)
    player:addOutfitAddon(addons[2], 3)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You received the Bear Paw outfit.")
    item:remove(1)
    return true
end

Do not forget to configure the ItemId in actions.xml so that your item works when you click
 
Last edited:
Solution
data/scripts/outfitbearpaw.lua
Lua:
local requirements = {
    {5896, 100}, -- Bear Paw
    {5897, 100} -- Wolf Paw
}

local addons = {169,168}
local action = Action()

function action.onUse(player, item, fromPos, target, toPos, isHotkey)
    if player:hasOutfit(addons[1], 3) and player:hasOutfit(addons[2], 3) then
        player:sendCancelMessage("You already have this outfit.")
        return true
    end

    for _, req in pairs(requirements) do
        if player:getItemCount(req[1]) < req[2] then
            player:sendCancelMessage("Sorry, you need 100 bear paw and 100 wolf paw.")
            return true
        end
    end

    for _, req in pairs(requirements) do
        player:removeItem(req[1], req[2])
    end

    player:addOutfitAddon(addons[1], 3)
    player:addOutfitAddon(addons[2], 3)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You received the Bear Paw outfit.")
    item:remove(1)
    return true
end

action:id(0000) -- ItemID
action:register()

Do not forget to configure the ItemID of the Action so that your item works when you click



hi, thanks for answering, forget to say that it is tfs 1.2
 
data/action/scripts/outfitbearpaw.lua
Lua:
local requirements = {
    {5896, 100}, -- Bear Paw
    {5897, 100} -- Wolf Paw
}

local addons = {169,168}

function onUse(player, item, fromPos, target, toPos, isHotkey)
    if player:hasOutfit(addons[1], 3) and player:hasOutfit(addons[2], 3) then
        player:sendCancelMessage("You already have this outfit.")
        return true
    end

    for _, req in pairs(requirements) do
        if player:getItemCount(req[1]) < req[2] then
            player:sendCancelMessage("Sorry, you need 100 bear paw and 100 wolf paw.")
            return true
        end
    end

    for _, req in pairs(requirements) do
        player:removeItem(req[1], req[2])
    end

    player:addOutfitAddon(addons[1], 3)
    player:addOutfitAddon(addons[2], 3)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You received the Bear Paw outfit.")
    item:remove(1)
    return true
end

Do not forget to configure the ItemId in actions.xml so that your item works when you click


Hello how are you, I wanted to ask you for help, could you increase the number of items from 2 to 3 please
 
Back
Top