local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandlernCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandlernCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandlernCreatureSay(cid, type, msg) end
function onThink() npcHandlernThink() 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(?)
He won't look back at this post again, nice 3 year bump.
No it is not, you have to edit the sources.
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())