• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Remove sellable item from trade window but npc sell through dialog?

Jknot

Member
Joined
Feb 18, 2008
Messages
170
Solutions
1
Reaction score
13
Location
South Carolina
as in the title is there anyway i can remove a sellable item from trade window but have the npc still sell it through dialog with out removing the module system?

basically i want to remove the dwarven pick from the trade window yet have the npc sell it in the dialog still is this possible?
 

Attachments

Solution
LUA:
local item = 2435
local cost = 1000

local talkState = {}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

    if msg:lower() == "dwarven picks" then
        npcHandler:say("Do you want to buy a Dwarven Pick for " .. cost .. " gold...
What you mean by dialog?

You want to remove it from the trade window and make it only possible to get if you say "pickaxe" to the npc?
I don't understand
 
LUA:
local item = 2435
local cost = 1000

local talkState = {}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

    if msg:lower() == "dwarven picks" then
        npcHandler:say("Do you want to buy a Dwarven Pick for " .. cost .. " gold coins?", cid)
        talkState[cid] = 1

    elseif msg:lower() == "yes" and talkState[cid] == 1 then
        if player:removeMoney(cost) then
            player:addItem(item, 1)
            npcHandler:say("You have bought a Dwarven Pick.", cid)
        else
            npcHandler:say("You don't have enough money.", cid)
        end
        talkState[cid] = nil
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

XML:
<npc name="Refiner" script="refiner.lua" walkinterval="2000" floorchange="0" access="5" level="1" maglevel="1">
    <health now="150" max="150"/>
    <look type="66" head="79" body="118" legs="115" feet="114" corpse="2212"/>
    <parameters>
        <parameter key="module_shop" value="1" />
                <parameter key="message_greet" value="Hello |PLAYERNAME|. I buy ore's to refine into fine items. Might you have any for sell? Currently i am only intrested in Small Emeralds,Small Sapphires,Small Ruby's,Small Diamonds,Small Amethyst,Gold Nuggets,and iron ores,I Also sell {Dwarven Picks} and iron hammers For your Mining Needs." />
        <parameter key="shop_sellable" value="small sapphire,2146,50;White Pearl,2143,320;Black Pearl,2144,280;small ruby,2147,50;small amethyst,2150,50;small diamond,2145,50;small emerald,2149,50;iron ore,5880,200;gold nugget,2157,500" />
        <parameter key="shop_buyable" value="iron hammer,2422,20000;power bolt,2547,10000;burst arrow,2546,10000;poison arrow,2545,18;bolt,2543,3;arrow,2544,2dwarven pick,4874,150;" />
    </parameters>
</npc>
 
Last edited:
LUA:
local item = 2435
local cost = 1000

local talkState = {}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

    if msg:lower() == "dwarven picks" then
        npcHandler:say("Do you want to buy a Dwarven Pick for " .. cost .. " gold coins?", cid)
        talkState[cid] = 1

    elseif msg:lower() == "yes" and talkState[cid] == 1 then
        if player:removeMoney(cost) then
            player:addItem(item, 1)
            npcHandler:say("You have bought a Dwarven Pick.", cid)
        else
            npcHandler:say("You don't have enough money.", cid)
        end
        talkState[cid] = nil
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

XML:
<npc name="Refiner" script="refiner.lua" walkinterval="2000" floorchange="0" access="5" level="1" maglevel="1">
    <health now="150" max="150"/>
    <look type="66" head="79" body="118" legs="115" feet="114" corpse="2212"/>
    <parameters>
        <parameter key="module_shop" value="1" />
                <parameter key="message_greet" value="Hello |PLAYERNAME|. I buy ore's to refine into fine items. Might you have any for sell? Currently i am only intrested in Small Emeralds,Small Sapphires,Small Ruby's,Small Diamonds,Small Amethyst,Gold Nuggets,and iron ores,I Also sell {Dwarven Picks} and iron hammers For your Mining Needs." />
        <parameter key="shop_sellable" value="small sapphire,2146,50;White Pearl,2143,320;Black Pearl,2144,280;small ruby,2147,50;small amethyst,2150,50;small diamond,2145,50;small emerald,2149,50;iron ore,5880,200;gold nugget,2157,500" />
        <parameter key="shop_buyable" value="iron hammer,2422,20000;power bolt,2547,10000;burst arrow,2546,10000;poison arrow,2545,18;bolt,2543,3;arrow,2544,2dwarven pick,4874,150;" />
    </parameters>
</npc>
he is selling the pickaxe but it still shows in the trade window i also corrected the item id for my items.otbm and changed this
<parameter key="shop_buyable" value="iron hammer,2422,20000;power bolt,2547,10000;burst arrow,2546,10000;poison arrow,2545,18;bolt,2543,3;arrow,2544,2dwarven pick,4874,150;" />
to ;arrow,2544,2;dwarven pick,4874,150;
Post automatically merged:

Post automatically merged:

LUA:
local item = 2435
local cost = 1000

local talkState = {}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

    if msg:lower() == "dwarven picks" then
        npcHandler:say("Do you want to buy a Dwarven Pick for " .. cost .. " gold coins?", cid)
        talkState[cid] = 1

    elseif msg:lower() == "yes" and talkState[cid] == 1 then
        if player:removeMoney(cost) then
            player:addItem(item, 1)
            npcHandler:say("You have bought a Dwarven Pick.", cid)
        else
            npcHandler:say("You don't have enough money.", cid)
        end
        talkState[cid] = nil
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

XML:
<npc name="Refiner" script="refiner.lua" walkinterval="2000" floorchange="0" access="5" level="1" maglevel="1">
    <health now="150" max="150"/>
    <look type="66" head="79" body="118" legs="115" feet="114" corpse="2212"/>
    <parameters>
        <parameter key="module_shop" value="1" />
                <parameter key="message_greet" value="Hello |PLAYERNAME|. I buy ore's to refine into fine items. Might you have any for sell? Currently i am only intrested in Small Emeralds,Small Sapphires,Small Ruby's,Small Diamonds,Small Amethyst,Gold Nuggets,and iron ores,I Also sell {Dwarven Picks} and iron hammers For your Mining Needs." />
        <parameter key="shop_sellable" value="small sapphire,2146,50;White Pearl,2143,320;Black Pearl,2144,280;small ruby,2147,50;small amethyst,2150,50;small diamond,2145,50;small emerald,2149,50;iron ore,5880,200;gold nugget,2157,500" />
        <parameter key="shop_buyable" value="iron hammer,2422,20000;power bolt,2547,10000;burst arrow,2546,10000;poison arrow,2545,18;bolt,2543,3;arrow,2544,2dwarven pick,4874,150;" />
    </parameters>
</npc>
resolved with this solution
 

Attachments

Last edited:
Solution
Back
Top