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

Lua Costello NPC

hotdog1337

Banned User
Joined
Apr 1, 2021
Messages
308
Solutions
3
Reaction score
127
Hi so I have been rebuilding the datapack and have problem with 1 npc that just becomes stubborn eventually 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:
Solution
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


keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is Costello."})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler =...

Terotrificy

Well-Known Member
Joined
Oct 18, 2020
Messages
239
Solutions
9
Reaction score
78
Location
Santiago, Chile.
Hi so I have been rebuilding the datapack and have problem with 1 npc that just becomes stubborn eventually 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)
    npcHandlerfocus = 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 msgcontains(msg, 'crime') or msgcontains(msg, 'absolution') and npcHandlerfocus == 19 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)
        npcHandlerfocus = 20
        if msgcontains(msg, 'yes') and npcHandler.focus == 20 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)
                npcHandlerfocus = 0
            else
            npcHandler:say("Begone! You do not have enough money!", 1)
            npcHandlerfocus = 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)
        npcHandlerfocus = 40
        if msgcontains(msg, 'yes') and npcHandler.focus == 40 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)
                npcHandlerfocus = 0
            else
            npcHandler:say("Begone! You do not have enough money!", 1)
            npcHandlerfocus = 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)
        npcHandlerfocus = 60
        if msgcontains(msg, 'yes') and npcHandler.focus == 60 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)
                npcHandlerfocus = 0
            else
            npcHandler:say("Begone! You do not have enough money!", 1)
            npcHandlerfocus = 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)
        npcHandlerfocus = 61
        print("FOCUS:" ..npcHandlerfocus.. " TO")
        if msgcontains(msg, 'yes') and npcHandler.focus == 61 then
           -- print("NIC") this if check is not going through for whatever reason
            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)
                npcHandlerfocus = 0
            else
            npcHandler:say("Begone! You do not have enough money!", 1)
            npcHandlerfocus = 0
            end
        else
        npcHandler:say("Then be gone!", 1)
        --print("FOCUS:" ..npcHandlerfocus.. " TO") shows correct id focus
        end
    end
end
--npcHandlerfocus = 13


if msgcontains(msg, 'fugio') and getCreatureStorage(cid, 45466) == -1 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)
    npcHandlerfocus = 13
elseif npcHandlerfocus == 13 and msgcontains(msg, 'yes') then
    npcHandler:say("Thank you very much! From now on you may open the warded doors to the catacombs.", 1)
    setPlayerStorageValue(cid, 45466, 1)
    npcHandlerfocus = 0
elseif npcHandlerfocus == 13 and msgcontains(msg, 'no') then
    npcHandler:say("Well, i really needed your help. But its your own choice.", 1)
    npcHandlerfocus = 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
I don't know what distro are you using, but i did my own costello on Othire 1.0, this is my npc script (working 100%):


Lua:
-- NPC Converter System - developed by Utroz <[email protected]>
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 greetCallback(cid)
if getPlayerStorageValue(cid, 501) == 1 then
    npcHandler:setMessage(MESSAGE_GREET, "WHAT? You have to be that trespasser my brothers told me about! Entering the restricted area is a horrible crime!")
    return true
    else
    npcHandler:setMessage(MESSAGE_GREET, "Welcome," .. getCreatureName(cid) .."! Feel free to tell me what brings you here.")
    end
return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am the abbot of the white raven monastery on the isle of the kings.'})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My name is Costello.'})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'That is the name of our world and its major continent.'})
keywordHandler:addKeyword({'god'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'They created Tibia and all life on it.'})
keywordHandler:addKeyword({'life'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'On Tibia there are many forms of life. Plants, the citizens, and monsters.'})
keywordHandler:addKeyword({'plant'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Just walk around, you will see grass, trees, and bushes.'})
keywordHandler:addKeyword({'white raven'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The legends tell us of a white raven which lead the ship of the first monk of our order here. He discovered this isle and the caves beneath it.'})
keywordHandler:addKeyword({'caves'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Anselm, the first of our order, discovered them while looking for a suitable burial place for his king.'})
keywordHandler:addKeyword({'anselm'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'He was a humble and pious man, and he was chosen by the royal family of thais to find a resting place for their dead.'})
keywordHandler:addKeyword({'isle'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'We founded our monastery to guard the royal tombs and to gather wisdom and knowledge.'})
keywordHandler:addKeyword({'wisdom'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You are allowed to enter the library upstairs. Stay there and don\'t go upstairs, because that area is reserved for members of our order.'})
keywordHandler:addKeyword({'tibianus'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'One day every Tibianus ends up here.'})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The bygone leaders of the Thaian empire rest beneath this monastery in tombs and crypts.'})
keywordHandler:addKeyword({'tomb QuestValue(63)<1'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The tombs and crypts of the Thaian lineage are well protected deep beneath our abbey, although ... but surely this will not interest you.'})
keywordHandler:addKeyword({'although QuestValue(63)<1'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'In my dreams the dead are talking to me about torment and disturbance. But I might be imagining things.'})
keywordHandler:addKeyword({'imagining QuestValue(63)<1'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Brother Fugio, the only one of our order who is allowed to enter the crypts, assures me everything is all right.'})
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Oh of course, I will order Jack and the fisher Windtrouser to give you transportation if needed.'})
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You should not be here at all and I won\'t allow anyone to transport you from or to this isle.'})
keywordHandler:addKeyword({'ferumbras'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Don\'t mention this servant of evil here.'})
keywordHandler:addKeyword({'excalibug'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Sadly we have only little knowledge on this topic.'})
keywordHandler:addKeyword({'news'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Sorry, we rarely hear anything new here.'})
keywordHandler:addKeyword({'monster'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'There are really too many of them in Tibia. But who are we to question the wisdom of the gods?'})



function creatureSayCallback(cid, type, msg)
    if(cid ~= npcHandler.focus) then
        return false
    end
    if (msgcontains(msg, 'absolution') or msgcontains(msg, 'crime')) and getPlayerStorageValue(cid, 501) == 1 and getPlayerLevel(cid) < 20 then
            price = 500
            npcHandler:say('The only way to redeem such an offence is the sacrifice of 500 gold pieces! Are you willing to pay that sum?')
            talk_state = 1
        elseif (msgcontains(msg, 'absolution') or msgcontains(msg, 'crime')) and getPlayerStorageValue(cid, 501) == 1 and getPlayerLevel(cid) < 40 and getPlayerLevel(cid) >= 20 then
            npcHandler:say('The only way to redeem such an offence is the sacrifice of 1000 gold pieces! Are you willing to pay that sum?')
            talk_state = 1
            price = 1000
        elseif (msgcontains(msg, 'absolution') or msgcontains(msg, 'crime')) and getPlayerStorageValue(cid, 501) == 1 and getPlayerLevel(cid) <= 60 and getPlayerLevel(cid) >= 40 then
            npcHandler:say('The only way to redeem such an offence is the sacrifice of 5000 gold pieces! Are you willing to pay that sum?')
            talk_state = 1
            price = 5000
        elseif (msgcontains(msg, 'absolution') or msgcontains(msg, 'crime')) and getPlayerStorageValue(cid, 501) == 1 and getPlayerLevel(cid) > 60 then
            npcHandler:say('The only way to redeem such an offence is the sacrifice of 10000 gold pieces! Are you willing to pay that sum?')
            talk_state = 1
            price = 10000
        elseif talk_state == 1 and msgcontains(msg, 'yes') and doPlayerRemoveMoney(cid, price) == true then
            npcHandler:say('So receive your absolution! And never do such a thing again!')
                setPlayerStorageValue(cid,501,0)
        elseif talk_state == 1 and msgcontains(msg, 'yes') and doPlayerRemoveMoney(cid, price) == false then
            npcHandler:say('Oh. You do not have enough money.')
        elseif talk_state == 1 and msgcontains(msg, 'no') then
            npcHandler:say('Then stay here.')
        return true
        end

    if msgcontains(msg, 'fugio') and getPlayerStorageValue(cid, 503) < 1 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?')
            talk_state = 10
        elseif talk_state == 10 and msgcontains(msg, 'yes') then
            npcHandler:say('Thank you very much! From now on you may open the warded doors to the catacombs.')
            setPlayerStorageValue(cid,503,1)
            setPlayerStorageValue(cid,504,1)
        elseif msgcontains(msg, 'diary') and getPlayerStorageValue(cid, 504) == 1 then
            npcHandler:say('Do you want me to inspect a diary?')
            talk_state = 11
        elseif msgcontains(msg, 'diary') and getPlayerStorageValue(cid, 504) == 2 then
            npcHandler:say('Thank you again for handing me that diary.')
        elseif talk_state == 11 and msgcontains(msg, 'yes') and getPlayerItemCount(cid, 1972) < 1 then
        npcHandler:say("What a pity.")
        elseif talk_state == 11 and msgcontains(msg, 'yes') and getPlayerItemCount(cid, 1972) == 1 and getPlayerStorageValue(cid, 504) == 1 then
            npcHandler:say("By the gods! This is brother Fugio's handwriting and what I read is horrible indeed! You have done our order a great favour by giving this diary to me! Take this blessed Ankh. May it protect you in even your darkest hours.")
            doPlayerAddItem(cid,2193,1)
            doPlayerRemoveItem(cid,1972,1)
            setPlayerStorageValue(cid,504,2)
        return true
        end

    if msgcontains(msg, 'heal') then
        if hasCondition(cid, CONDITION_FIRE) == true then
            npcHandler:say('You are burning. I will help you.')
            doRemoveCondition(cid, CONDITION_FIRE)
            doSendMagicEffect(getCreaturePosition(cid), 14)
        elseif hasCondition(cid, CONDITION_POISON) == true then
            npcHandler:say('You are poisoned. I will help you.')
            doRemoveCondition(cid, CONDITION_POISON)
            doSendMagicEffect(getCreaturePosition(cid), 13)
        elseif getCreatureHealth(cid) < 65 then
            npcHandler:say('You are looking really bad. Let me heal your wounds.')
            doCreatureAddHealth(cid, 65 - getCreatureHealth(cid))
            doSendMagicEffect(getCreaturePosition(cid), 12)
        else
            npcHandler:say('You aren\'t looking really bad, ' .. getCreatureName(cid) .. '. I can only help in cases of real emergencies. Raise your health simply by eating food.')
        end
        return true
    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

You can use mine and adapt it to your distro if you want.
 
OP
OP
hotdog1337

hotdog1337

Banned User
Joined
Apr 1, 2021
Messages
308
Solutions
3
Reaction score
127
yeah i should have just done multiple checks and keep it less this makes sense now xD

only thing that does not work is :
Lua:
function greetCallback(cid)
if getPlayerStorageValue(cid, 24622) == 1 then
   npcHandler:say("WHAT? You have to be that trespasser my brothers told me about! Entering the restricted area is a horrible crime!", 1)
    return true
    else
    npcHandler:setMessage(MESSAGE_GREET, "Welcome," .. getCreatureName(cid) .."! Feel free to tell me what brings you here.")
    end
return true
end
 
Last edited:

Terotrificy

Well-Known Member
Joined
Oct 18, 2020
Messages
239
Solutions
9
Reaction score
78
Location
Santiago, Chile.
yeah i should have just done multiple checks and keep it less this makes sense now xD

only thing that does not work is :
Lua:
function greetCallback(cid)
if getPlayerStorageValue(cid, 24622) == 1 then
   npcHandler:say("WHAT? You have to be that trespasser my brothers told me about! Entering the restricted area is a horrible crime!", 1)
    return true
    else
    npcHandler:setMessage(MESSAGE_GREET, "Welcome," .. getCreatureName(cid) .."! Feel free to tell me what brings you here.")
    end
return true
end
That is working on mine. You must check in your distribution how to handle the greetings. Probably you can check Markwin (minotaurs king) or Orc King, i remember they have different ways to greeting depending in your storage. Costello have different greetings depending in the storage you get when you go to the upper floor.
 
OP
OP
hotdog1337

hotdog1337

Banned User
Joined
Apr 1, 2021
Messages
308
Solutions
3
Reaction score
127
That is working on mine. You must check in your distribution how to handle the greetings. Probably you can check Markwin (minotaurs king) or Orc King, i remember they have different ways to greeting depending in your storage. Costello have different greetings depending in the storage you get when you go to the upper floor.
problem is markwin and alike make you say goodbye immediately so it works if there is return false but not with return true i tried overloading the actual npc operation in the original pasted code but it seems like it makes every npc greet wrong then.
 

Terotrificy

Well-Known Member
Joined
Oct 18, 2020
Messages
239
Solutions
9
Reaction score
78
Location
Santiago, Chile.
There are NPC's that depending on your sex, they greetings different, like Captain Bluebear:


Lua:
function greetCallback(cid)
    if getPlayerSex(cid) == 1 then
        npcHandler:setMessage(MESSAGE_GREET, "Welcome on board, Sir ".. getPlayerName(cid) ..".")
        return true
    else
        npcHandler:setMessage(MESSAGE_GREET, "Welcome on board, Madam ".. getPlayerName(cid) ..".")
        return true
    end
end

Find that NPC, or some other NPC that does it in your distro and use that code :p
 
OP
OP
hotdog1337

hotdog1337

Banned User
Joined
Apr 1, 2021
Messages
308
Solutions
3
Reaction score
127
There are NPC's that depending on your sex, they greetings different, like Captain Bluebear:


Lua:
function greetCallback(cid)
    if getPlayerSex(cid) == 1 then
        npcHandler:setMessage(MESSAGE_GREET, "Welcome on board, Sir ".. getPlayerName(cid) ..".")
        return true
    else
        npcHandler:setMessage(MESSAGE_GREET, "Welcome on board, Madam ".. getPlayerName(cid) ..".")
        return true
    end
end

Find that NPC, or some other NPC that does it in your distro and use that code :p
problem is that i can use that greet function but only when it makes the player F off basically if i put return false it then says what i want xd its weird. eh whatever as long as crime and absolution works its fine i guess
 
OP
OP
hotdog1337

hotdog1337

Banned User
Joined
Apr 1, 2021
Messages
308
Solutions
3
Reaction score
127
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


keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is Costello."})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm the abbot of the White Raven Monastery on the Isle of the Kings."})
keywordHandler:addKeyword({'isle'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "We founded our monastery to guard the royal tombs and to gather wisdom and knowledge."})
keywordHandler:addKeyword({'order'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "We founded our monastery to guard the royal tombs and to gather wisdom and knowledge."})
keywordHandler:addKeyword({'wisdom'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "You may enter the library upstairs. Don't go any further upstairs, though, as this area is reserved for members of our order."})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The deceased leaders of the Thaian empire rest beneath this monastery in tombs and crypts."})
keywordHandler:addKeyword({'caves'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Anselm, the first monk of our order, discovered them while looking for a suitable burial place for his king."})
keywordHandler:addKeyword({'anselm'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "He was a humble and pious man, and he was chosen by the royal family of Thais to find a resting place for their dead."})



function greetCallback(cid)
    if getCreatureStorage(cid, 24622) == 1 then
    --if getPlayerLevel(cid) == 8 then
    --if getPlayerLevel(cid) == 8 then
    npcHandler:setMessage(MESSAGE_GREET, "By the gods! You must be that intruder the good brothers were talking about! Begone!")
    return true

    else
    npcHandler:setMessage(MESSAGE_GREET, "Welcome," .. getCreatureName(cid) .."! Feel free to tell me what brings you here.")
    return true
    end   
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)




function creatureSayCallback(cid, type, msg) msg = string.lower(msg)
    if(npcHandler.focus ~= cid) then
        return false
    end
    
    


if (msgcontains(msg, 'absolution') or msgcontains(msg, 'crime')) and getPlayerStorageValue(cid, 24622) == 1 and getPlayerLevel(cid) < 20 then
            price = 500
            npcHandler:say('The only way to redeem such an offence is the sacrifice of 500 gold pieces! Are you willing to pay that sum?')
            talk_state = 1
        elseif (msgcontains(msg, 'absolution') or msgcontains(msg, 'crime')) and getPlayerStorageValue(cid, 24622) == 1 and getPlayerLevel(cid) < 40 and getPlayerLevel(cid) >= 20 then
            npcHandler:say('The only way to redeem such an offence is the sacrifice of 1000 gold pieces! Are you willing to pay that sum?')
            talk_state = 1
            price = 1000
        elseif (msgcontains(msg, 'absolution') or msgcontains(msg, 'crime')) and getPlayerStorageValue(cid, 24622) == 1 and getPlayerLevel(cid) <= 60 and getPlayerLevel(cid) >= 40 then
            npcHandler:say('The only way to redeem such an offence is the sacrifice of 5000 gold pieces! Are you willing to pay that sum?')
            talk_state = 1
            price = 5000
        elseif (msgcontains(msg, 'absolution') or msgcontains(msg, 'crime')) and getPlayerStorageValue(cid, 24622) == 1 and getPlayerLevel(cid) > 60 then
            npcHandler:say('The only way to redeem such an offence is the sacrifice of 10000 gold pieces! Are you willing to pay that sum?')
            talk_state = 1
            price = 10000
        elseif talk_state == 1 and msgcontains(msg, 'yes') and doPlayerRemoveMoney(cid, price) == true then
            npcHandler:say('So receive your absolution! And never do such a thing again!')
                setPlayerStorageValue(cid,24622,0)
        elseif talk_state == 1 and msgcontains(msg, 'yes') and doPlayerRemoveMoney(cid, price) == false then
            npcHandler:say('Oh. You do not have enough money.')
        elseif talk_state == 1 and msgcontains(msg, 'no') then
            npcHandler:say('Then stay here.')
        return true
        end
        
        if msgcontains(msg, 'heal') then
        if hasCondition(cid, CONDITION_FIRE) == true then
            npcHandler:say('You are burning. I will help you.')
            doRemoveCondition(cid, CONDITION_FIRE)
            doSendMagicEffect(getCreaturePosition(cid), 14)
        elseif hasCondition(cid, CONDITION_POISON) == true then
            npcHandler:say('You are poisoned. I will help you.')
            doRemoveCondition(cid, CONDITION_POISON)
            doSendMagicEffect(getCreaturePosition(cid), 13)
        elseif getCreatureHealth(cid) < 65 then
            npcHandler:say('You are looking really bad. Let me heal your wounds.')
            doCreatureAddHealth(cid, 65 - getCreatureHealth(cid))
            doSendMagicEffect(getCreaturePosition(cid), 12)
        else
            npcHandler:say('You aren\'t looking really bad, ' .. getCreatureName(cid) .. '. I can only help in cases of real emergencies. Raise your health simply by eating food.')
        end
        return true
    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())
 
Solution
Top