VagosClubTM
Active Member
Hello friends I would like to know if you have or can modify this script so that I can trade objects for a specific currency that can be configured. I will leave the npc script.
thank you very much in advance <3
thank you very much in advance <3
Lua:
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
local voices = { {text = "Dime buy mana rune o mana vida!"} }
npcHandler:addModule(VoiceModule:new(voices))
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
keywordHandler:addKeyword({'stuff'}, StdModule.say, {npcHandler = npcHandler, text = 'Just ask me for a {trade} to see my offers.'})
keywordHandler:addAliasKeyword({'wares'})
keywordHandler:addAliasKeyword({'offer'})
shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook')
shopModule:addBuyableItem({'aol'}, 2173, 15000, 'aol')
shopModule:addBuyableItem({'magic lightwand'}, 2162, 400, 'magic lightwand')
shopModule:addBuyableItem({'mana rune'}, 2296, 5000, 70, 'mana rune')
shopModule:addBuyableItem({'mana vida'}, 2296, 5000, 70, 'mana vida')
shopModule:addBuyableItem({'sd'}, 2268, 3000, 100, 'sd')
shopModule:addBuyableItem({'transformacion'}, 2295, 10000, 20, 'transformacion')
shopModule:addSellableItem({'picoro legs', 'picoro leg'}, 5091, 150000, 'picoro legs')
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
local vocationId = player:getVocation():getId()
local items = {
[1] = 2190,
[2] = 2182,
[5] = 2190,
[6] = 2182
}
if msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand') then
if table.contains({1, 2, 5, 6}, vocationId) then
if player:getStorageValue(PlayerStorageKeys.firstRod) == -1 then
selfSay('So you ask me for a {' .. ItemType(items[vocationId]):getName() .. '} to begin your adventure?', cid)
npcHandler.topic[cid] = 1
else
selfSay('What? I have already gave you one {' .. ItemType(items[vocationId]):getName() .. '}!', cid)
end
else
selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
end
elseif msgcontains(msg, 'yes') then
if npcHandler.topic[cid] == 1 then
player:addItem(items[vocationId], 1)
selfSay('Here you are young adept, take care yourself.', cid)
player:setStorageValue(PlayerStorageKeys.firstRod, 1)
end
npcHandler.topic[cid] = 0
elseif msgcontains(msg, 'no') and npcHandler.topic[cid] == 1 then
selfSay('Ok then.', cid)
npcHandler.topic[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())