• 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!

Request: Npc 'Trade' but not for gp.

ryan868

New Member
Joined
Dec 29, 2008
Messages
73
Reaction score
1
I need a script where i can still say Trade to an NPC but instead of items costing gold, I want them costing x amount of a certain item.

this possible?
 
It is possible, think about npc soft boots recharger you need to give the soft used and the money, get this as exemple

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

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

function rechargeSoft(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
local playermoney = getPlayerMoney(cid)
if playermoney >= 100000 then
if doPlayerRemoveItem(cid,6530,1) == 1 then
doPlayerAddItem(cid, 6132, 1)
doPlayerRemoveMoney(cid, 100000)
npcHandler:say("Here are your new soft boots!", cid)
else
npcHandler:say("You don't have worn soft boots.", cid)
end
else
npcHandler:say("You don't have enough money.", cid)
end
keywordHandler:moveUp(1)
return true
end

local node1 = keywordHandler:addKeyword({'repair'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to repair your soft boots for 100000 gold coins?'})
node1:addChildKeyword({'yes'}, rechargeSoft, {blessing = 1})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Then not.'})

keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can repair a pair of worn soft boots for 100000 gold coins."})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can repair a pair of worn soft boots for 100000 gold coins."})

npcHandler:addModule(FocusModule:new())
 
It is possible, think about npc soft boots recharger you need to give the soft used and the money, get this as exemple

That script you mentioned is a /npc/scripts, trade is only placed in /npc folder...

I'm also wondring if it's possible to make trade with items instead of GPs without source edit(?)
 
That script you mentioned is a /npc/scripts, trade is only placed in /npc folder...

I'm also wondring if it's possible to make trade with items instead of GPs without source edit(?)

He won't look back at this post again, nice 3 year bump.
No it is not, you have to edit the sources.
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local shopWindow = {}
local moeda = 9020 -- ID certain item
local t = {
          [2195] = {price = 15}, -- [ITEMID TO SELL] = {HOW TO COST}
          [2493] = {price = 25},
          [2361] = {price = 30},
          [8851] = {price = 20},
          [8925] = {price = 30},
          [2640] = {price = 50},
          [2494] = {price = 100},
          [9932] = {price = 50},
          [2472] = {price = 70},
          [8931] = {price = 100}
          }
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
        if  t[item] and not doPlayerRemoveItem(cid, moeda, t[item].price) then
                  selfSay("you dont have"..t[item].price.." "..getItemNameById(moeda), cid)
                         else
                doPlayerAddItem(cid, item)
                selfSay("Here your item!", cid)
           end
        return true
end
if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
                        for var, ret in pairs(t) do
                                        table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
                                end
                        openShopWindow(cid, shopWindow, onBuy, onSell)
                end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top