Competitibia
Pain & Glory WHole
- Joined
- Apr 1, 2021
- Messages
- 545
- Solutions
- 3
- Reaction score
- 210
Hi so I have been rebuilding the datapack and have problem with 1 npc that just becomes stubborn eventually xD
basically problem is that when you want to pay he goes with else instead of actually letting you pay i cant see the mistake but it must be something simple would be great to have another pair of eyes to look at it xD
Lua:
dofile(getDataDir() .. 'global/greeting.lua')
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm m ol' Captain Jack."})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I work as a kind of ferryman. I transport wares and travellers for the monks."})
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I work as a kind of ferryman. I transport wares and travellers for the monks."})
keywordHandler:addKeyword({'capt'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I work as a kind of ferryman. I transport wares and travellers for the monks."})
keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "All right she's small. But she's a real beauty, don't you think?"})
keywordHandler:addKeyword({'ferry'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "All right she's small. But she's a real beauty, don't you think?"})
keywordHandler:addKeyword({'wares'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "They always need provisions from the cities, and they sell their wine there."})
keywordHandler:addKeyword({'traveller'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Sometimes pilgrims come to this place. And now and then a monk leaves the monastery for some time."})
keywordHandler:addKeyword({'trip'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go today?"})
keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "For some obscure political reason the monks never sail to Carlin or Thais directly."})
keywordHandler:addKeyword({'island'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "This is the isle of the kings. All the great Tibian leaders have found their final rest here under the monastery."})
keywordHandler:addKeyword({'monastery'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The white raven monastery is a place of wisdom and contemplation, or so the monks say. Sounds like a pretty boring place to me! HAR HAR!"})
keywordHandler:addKeyword({'monk'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The order of the white raven."})
keywordHandler:addKeyword({'white rav'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I prefer parrots. And monkeys! And snakes! HAR! HAR!"})
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
function NpcHandler:greet(cid)
if getCreatureStorage(cid, 24622) == 1 then
--if getPlayerLevel(cid) == 8 then
--if getPlayerLevel(cid) == 8 then
npcHandler:say("By the gods! You must be that intruder the good brothers were talking about! Begone!", 1)
self:changeFocus(cid)
TalkState(cid, 19)
else
npcHandler:say("Welcome, ".. getPlayerName(cid) .."! Feel free to tell me what brings you here.!", 1)
self:changeFocus(cid)
end
end
function creatureSayCallback(cid, type, msg) msg = string.lower(msg)
if(npcHandler.focus ~= cid) then
return false
end
pos = getPlayerPosition(cid)
if getCreatureStorage(cid, 24622) == 1 and GetTalkState(cid) == 19 and msgcontains(msg, 'crime') or msgcontains(msg, 'absolution') and npcHandler.focus == cid then
if getPlayerLevel(cid) < 20 then
npcHandler:say("The only way to redeem such an offense is the sacrifice of 500 gold pieces! Are you willing to pay that sum?", 1)
Talkstate(cid, 20)
if GetTalkState(cid) == 20 and msgcontains(msg, 'yes') and npcHandler.focus == cid then
if doPlayerRemoveMoney(cid, 500) == TRUE then
npcHandler:say("So receive your absolution! And never do such a thing again!", 1)
setPlayerStorageValue(cid, 24622, -1)
doSendMagicEffect(cid, 13)
Talkstate(cid, 0)
else
npcHandler:say("Begone! You do not have enough money!", 1)
Talkstate(cid, 0)
end
else
npcHandler:say("Then be gone!", 1)
end
elseif getPlayerLevel(cid) < 40 then
npcHandler:say("The only way to redeem such an offense is the sacrifice of 1000 gold pieces! Are you willing to pay that sum?", 1)
Talkstate(cid, 40)
if GetTalkState(cid) == 40 and msgcontains(msg, 'yes') and npcHandler.focus == cid then
if doPlayerRemoveMoney(cid, 1000) == TRUE then
npcHandler:say("So receive your absolution! And never do such a thing again!", 1)
setPlayerStorageValue(cid, 24622, -1)
doSendMagicEffect(cid, 13)
Talkstate(cid, 0)
else
npcHandler:say("Begone! You do not have enough money!", 1)
Talkstate(cid, 0)
end
else
npcHandler:say("Then be gone!", 1)
end
elseif getPlayerLevel(cid) < 60 then
npcHandler:say("The only way to redeem such an offense is the sacrifice of 5000 gold pieces! Are you willing to pay that sum?", 1)
Talkstate(cid, 60)
if GetTalkState(cid) == 60 and msgcontains(msg, 'yes') and npcHandler.focus == cid then
if doPlayerRemoveMoney(cid, 5000) == TRUE then
npcHandler:say("So receive your absolution! And never do such a thing again!", 1)
setPlayerStorageValue(cid, 24622, -1)
doSendMagicEffect(cid, 13)
Talkstate(cid, 0)
else
npcHandler:say("Begone! You do not have enough money!", 1)
Talkstate(cid, 0)
end
else
npcHandler:say("Then be gone!", 1)
end
elseif getPlayerLevel(cid) > 59 then
npcHandler:say("The only way to redeem such an offense is the sacrifice of 10000 gold pieces! Are you willing to pay that sum?", 1)
Talkstate(cid, 59)
if GetTalkState(cid) == 59 and msgcontains(msg, 'yes') and npcHandler.focus == cid then
if doPlayerRemoveMoney(cid, 10000) == TRUE then
npcHandler:say("So receive your absolution! And never do such a thing again!", 1)
setPlayerStorageValue(cid, 24622, -1)
doSendMagicEffect(cid, 13)
Talkstate(cid, 0)
else
npcHandler:say("Begone! You do not have enough money!", 1)
Talkstate(cid, 0)
end
else
npcHandler:say("Then be gone!", 1)
end
end
end
if msgcontains(msg, 'fugio') and npcHandler.focus == cid then
npcHandler:say("To be honest, I fear the omen in my dreams may be true. Perhaps Fugio is unable to see the danger down there. Perhaps ... you are willing to investigate this matter?", 1)
TalkState(cid, 444)
elseif GetTalkState(cid) == 444 and msgcontains(msg, 'yes') and npcHandler.focus == cid then
npcHandler:say("Thank you very much! From now on you may open the warded doors to the catacombs.", 1)
setPlayerStorageValue(cid, 45466, 1)
TalkState(cid, 0)
elseif GetTalkState(cid) == 444 and msgcontains(msg, 'no') and npcHandler.focus == cid then
npcHandler:say("Well, i really needed your help. But its your own choice.", 1)
TalkState(cid, 0)
end
return 1
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
basically problem is that when you want to pay he goes with else instead of actually letting you pay i cant see the mistake but it must be something simple would be great to have another pair of eyes to look at it xD
Last edited: