Hello!
I'm working on a 7.6 server using OTX 2.9, I've been trying to add loot NPC, but none have worked. I have an NPC that sells amulet of loss and some rings, I'll post the script below. Could someone please help me modify it so instead of selling stuff, it buys them? I just need the function with one item, I'll add the rest of them. I try to edit it but it didn't work, I would really appreciate it!
I'm working on a 7.6 server using OTX 2.9, I've been trying to add loot NPC, but none have worked. I have an NPC that sells amulet of loss and some rings, I'll post the script below. Could someone please help me modify it so instead of selling stuff, it buys them? I just need the function with one item, I'll add the rest of them. I try to edit it but it didn't work, I would really appreciate it!
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
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
--------- AMULETS and RINGS ---------
if msgcontains(msg, 'rings') then
npcHandler:say('I sell Energy Ring, Life Ring, and Ring of Healing.')
talk_start = 1
end
if msgcontains(msg, 'aol') then
item = 2173
price = 10000
npcHandler:say('Do you want to buy an Amulet of Loss for 1 crystal coin?')
talk_start = 1
end
if msgcontains(msg, 'energy ring') then
item = 2167
price = 2000
npcHandler:say('Do you want to buy a Energy Ring for 20 platinum coins?')
talk_start = 1
end
if msgcontains(msg, 'life ring') then
item = 2205
price = 2500
npcHandler:say('Do you want to buy a Life Ring for 25 platinum coins?')
talk_start = 1
end
if msgcontains(msg, 'ring of healing') then
item = 2214
price = 5000
npcHandler:say('Do you want to buy a Ring of Healing for 50 platinum coins?')
talk_start = 1
end
if msgcontains(msg, 'yes') and getPlayerMoney(cid) >= price then
npcHandler:say('Here you go!')
doPlayerAddItem(cid, item, 1)
doPlayerRemoveMoney(cid, price)
talk_start = 0
elseif msgcontains(msg, 'yes') and getPlayerMoney(cid) < price then
npcHandler:say('You don\'t have enough money.')
talk_start = 0
end
if msgcontains(msg, 'no') and talk_start == 1 then
npcHandler:say('Okay, let me know if you would like to buy something else.')
talk_start = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())