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

TFS 0.X NPC that buys and sells if you have Storage

willks123

New Member
Joined
Dec 31, 2012
Messages
65
Reaction score
2
I created a script from npc Alesar to put the Djinn quest 100% on my server, but I can't make it sell only if I have the Storage of the complete quest.
Could someone help me to make it only negotiate with those who have Storage 1038 = 1?

My server is OTX 2 - 0.7
 

Attachments

Look at existing npc files for djinns and see how they work. Be default they should only speak to people with the quest completed. Just do the same thing .
 
Look at existing npc files for djinns and see how they work. Be default they should only speak to people with the quest completed. Just do the same thing .
I already looked, but for version 7.72 I can't find it anywhere. but I imagine you have to adjust something in the modules. if you know of any help me.
 
I already looked, but for version 7.72 I can't find it anywhere. but I imagine you have to adjust something in the modules. if you know of any help me.
Instead to put in npc, cant u create a door (with storage) and put NPC inside this locked room? In a different floor.
 
Try this:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
local npcHandlerfocus = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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

-- OTServ event handling functions end
local function creatureSayCallback(cid, type, msg)
    if (getPlayerStorageValue(cid, 1029) ~= 1) then
        return 0
    end

    if (msgcontains(msg:lower(), "djanni'hah")) then
        npcHandler:say('What do you want from me, ' .. getPlayerName(cid) .. '?')
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (msgcontains(msg:lower(), "mission") and npcHandlerfocus == 0 and getPlayerStorageValue(cid, 8131) ~= 1) then
        npcHandler:say("So Baa'leal thinks you are up to do a mission for us? ...")
        npcHandler:say("I think he is getting old, entrusting human scum such as you are with an important mission like that. ..."
            , cid, 3000)
        npcHandler:say("Personally, I don't understand why you haven't been slaughtered right at the gates. ...", cid, 5000)
        npcHandler:say("Anyway. Are you prepared to embark on a dangerous mission for us?", cid, 7000)
        npcHandlerfocus = 1
    elseif (msgcontains(msg:lower(), "yes") and npcHandlerfocus == 1) then
        setPlayerStorageValue(cid, 8131, 1)
        npcHandler:say("All right then, human. Have you ever heard of the 'Tears of Daraman'? ...")
        npcHandler:say("They are precious gemstones made of some unknown blue mineral and possess enormous magical power. ..."
            , cid, 3000)
        npcHandler:say("If you want to learn more about these gemstones don't forget to visit our library. ...", cid, 5000)
        npcHandler:say("Anyway, one of them is enough to create thousands of our mighty djinn blades. ...", cid, 7000)
        npcHandler:say("Unfortunately my last gemstone broke and therefore I'm not able to create new blades anymore. ...", cid
            , 9000)
        npcHandler:say("To my knowledge there is only one place where you can find these gemstones - I know for a fact that the Marid have at least one of them. ..."
            , cid, 11000)
        npcHandler:say("Well... to cut a long story short, your mission is to sneak into Ashta'daramai and to steal it. ...",
            cid, 13000)
        npcHandler:say("Needless to say, the Marid won't be too eager to part with it. Try not to get killed until you have delivered the stone to me."
            , cid, 15000)
        npcHandler.focus = cid
        npcHandlerfocus = 4
    elseif (msgcontains(msg:lower(), "no") and npcHandlerfocus == 1) then
        npcHandler:say("I wouldn't expect anything different from a human.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 8131) == 1 and
            getPlayerStorageValue(cid, 10229) ~= 1) then
        npcHandler:say("You still haven't gotten the item I asked for. Go to the blue djinn fortress and bring her back.")
        npcHandler.focus = cid
        npcHandlerfocus = 0

    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 10229) == 1 and
            getPlayerStorageValue(cid, 10230) ~= 1) then
        npcHandler:say('Did you find the tear of Daraman?')
        npcHandler.focus = cid
        npcHandlerfocus = 2
    elseif (msgcontains(msg:lower(), "yes") and npcHandlerfocus == 2) then
        if getPlayerItemCount(cid, 2346) >= 1 then
            npcHandler:say("So you have made it? You have really managed to steal a Tear of Daraman? ...")
            npcHandler:say("Amazing how you humans are just impossible to get rid of. Incidentally, you have this character trait in common with many insects and with other vermin. ..."
                , cid, 2000)
            npcHandler:say("Nevermind. I hate to say it, but it you have done us a favour, human. That gemstone will serve us well. ..."
                , cid, 4000)
            npcHandler:say("Baa'leal, wants you to talk to Malor concerning some new mission. ...", cid, 6000)
            npcHandler:say("Looks like you have managed to extended your life expectancy - for just a bit longer.", cid, 8000)
            setPlayerStorageValue(cid, 1032, 1)
            setPlayerStorageValue(cid, 10230, 1)
            doPlayerRemoveItem(cid, 2346, 1)
            npcHandler.focus = cid
            npcHandlerfocus = 3
        elseif (msgcontains(msg:lower(), "no") and npcHandlerfocus == 2) then
            npcHandler:say("You do not have the Tear of Daraman.")
            npcHandler.focus = cid
            npcHandlerfocus = 0
        end
    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 1032) == 1 and
            getPlayerStorageValue(cid, 10230) == 1) then
        npcHandler:say("I have no more missions for you. See if Malor has something for you, he's at the top of the tower.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (msgcontains(msg:lower(), "sell") or msgcontains(msg:lower(), "buy")) and getPlayerStorageValue(cid, 1038) ~= 1 then
        npcHandler:say("I don't do business with humans.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    end
    return 1
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
npcHandler:addModule(ShopModule:new({ 'scimitar' }, 2419, 150, 'scimitar'))
addSellableItem({ 'giant sword' }, 2393, 17000, 'giant sword')
addSellableItem({ 'serpent sword' }, 2409, 900, 'serpent sword')
addSellableItem({ 'poison dagger' }, 2411, 50, 'poison dagger')
addSellableItem({ 'knight axe' }, 2430, 2000, 'knight axe')
addSellableItem({ 'dragon hammer' }, 2434, 2000, 'dragon hammer')
addSellableItem({ 'skull staff' }, 2436, 6000, 'skull staff')
addSellableItem({ 'dark armor' }, 2489, 400, 'dark armor')
addSellableItem({ 'knight armor' }, 2476, 5000, 'knight armor')
addSellableItem({ 'dark helmet' }, 2490, 250, 'dark helmet')
addSellableItem({ 'warrior helmet' }, 2475, 5000, 'warrior helmet')
addSellableItem({ 'strange helmet' }, 2479, 500, 'strange helmet')
addSellableItem({ 'mystic turban' }, 2663, 150, 'mystic turban')
addSellableItem({ 'knight legs' }, 2477, 5000, 'knight legs')
addSellableItem({ 'tower shield' }, 2528, 8000, 'tower shield')
addSellableItem({ 'black shield' }, 2529, 800, 'black shield')
addSellableItem({ 'ancient shield' }, 2532, 900, 'ancient shield')
addSellableItem({ 'vampire shield' }, 2534, 15000, 'vampire shield')
addBuyableItem({ 'ice rapier' }, 2396, 5000, 'ice rapier')
addBuyableItem({ 'serpent sword' }, 2409, 6000, 'serpent sword')
addBuyableItem({ 'dark armor' }, 2489, 1500, 'dark armor')
addBuyableItem({ 'dark helmet' }, 2490, 1000, 'dark helmet')
addBuyableItem({ 'ancient shield' }, 2532, 5000, 'ancient shield')

npcHandler:setMessage(MESSAGE_GREET, "What do you want from me, |PLAYERNAME|?")
npcHandler:setMessage(MESSAGE_PLACEDINQUEUE,
    "It might have escaped your limited human perception, but I am already talking to somebody else.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, human.")
npcHandler:setMessage(MESSAGE_FAREWELL,
    "Farewell, human. When I have taken my rightful place I shall remember those who served me well. Even if they are only humans.")

local function onTradeRequest(cid)
    if Player(cid):getStorageValue(1038) ~= 1 then
        npcHandler:say('Sorry, you need to complete the mission.', cid)
        return false
    end

    return true
end

npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Try this:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
local npcHandlerfocus = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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

-- OTServ event handling functions end
local function creatureSayCallback(cid, type, msg)
    if (getPlayerStorageValue(cid, 1029) ~= 1) then
        return 0
    end

    if (msgcontains(msg:lower(), "djanni'hah")) then
        npcHandler:say('What do you want from me, ' .. getPlayerName(cid) .. '?')
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (msgcontains(msg:lower(), "mission") and npcHandlerfocus == 0 and getPlayerStorageValue(cid, 8131) ~= 1) then
        npcHandler:say("So Baa'leal thinks you are up to do a mission for us? ...")
        npcHandler:say("I think he is getting old, entrusting human scum such as you are with an important mission like that. ..."
            , cid, 3000)
        npcHandler:say("Personally, I don't understand why you haven't been slaughtered right at the gates. ...", cid, 5000)
        npcHandler:say("Anyway. Are you prepared to embark on a dangerous mission for us?", cid, 7000)
        npcHandlerfocus = 1
    elseif (msgcontains(msg:lower(), "yes") and npcHandlerfocus == 1) then
        setPlayerStorageValue(cid, 8131, 1)
        npcHandler:say("All right then, human. Have you ever heard of the 'Tears of Daraman'? ...")
        npcHandler:say("They are precious gemstones made of some unknown blue mineral and possess enormous magical power. ..."
            , cid, 3000)
        npcHandler:say("If you want to learn more about these gemstones don't forget to visit our library. ...", cid, 5000)
        npcHandler:say("Anyway, one of them is enough to create thousands of our mighty djinn blades. ...", cid, 7000)
        npcHandler:say("Unfortunately my last gemstone broke and therefore I'm not able to create new blades anymore. ...", cid
            , 9000)
        npcHandler:say("To my knowledge there is only one place where you can find these gemstones - I know for a fact that the Marid have at least one of them. ..."
            , cid, 11000)
        npcHandler:say("Well... to cut a long story short, your mission is to sneak into Ashta'daramai and to steal it. ...",
            cid, 13000)
        npcHandler:say("Needless to say, the Marid won't be too eager to part with it. Try not to get killed until you have delivered the stone to me."
            , cid, 15000)
        npcHandler.focus = cid
        npcHandlerfocus = 4
    elseif (msgcontains(msg:lower(), "no") and npcHandlerfocus == 1) then
        npcHandler:say("I wouldn't expect anything different from a human.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 8131) == 1 and
            getPlayerStorageValue(cid, 10229) ~= 1) then
        npcHandler:say("You still haven't gotten the item I asked for. Go to the blue djinn fortress and bring her back.")
        npcHandler.focus = cid
        npcHandlerfocus = 0

    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 10229) == 1 and
            getPlayerStorageValue(cid, 10230) ~= 1) then
        npcHandler:say('Did you find the tear of Daraman?')
        npcHandler.focus = cid
        npcHandlerfocus = 2
    elseif (msgcontains(msg:lower(), "yes") and npcHandlerfocus == 2) then
        if getPlayerItemCount(cid, 2346) >= 1 then
            npcHandler:say("So you have made it? You have really managed to steal a Tear of Daraman? ...")
            npcHandler:say("Amazing how you humans are just impossible to get rid of. Incidentally, you have this character trait in common with many insects and with other vermin. ..."
                , cid, 2000)
            npcHandler:say("Nevermind. I hate to say it, but it you have done us a favour, human. That gemstone will serve us well. ..."
                , cid, 4000)
            npcHandler:say("Baa'leal, wants you to talk to Malor concerning some new mission. ...", cid, 6000)
            npcHandler:say("Looks like you have managed to extended your life expectancy - for just a bit longer.", cid, 8000)
            setPlayerStorageValue(cid, 1032, 1)
            setPlayerStorageValue(cid, 10230, 1)
            doPlayerRemoveItem(cid, 2346, 1)
            npcHandler.focus = cid
            npcHandlerfocus = 3
        elseif (msgcontains(msg:lower(), "no") and npcHandlerfocus == 2) then
            npcHandler:say("You do not have the Tear of Daraman.")
            npcHandler.focus = cid
            npcHandlerfocus = 0
        end
    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 1032) == 1 and
            getPlayerStorageValue(cid, 10230) == 1) then
        npcHandler:say("I have no more missions for you. See if Malor has something for you, he's at the top of the tower.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (msgcontains(msg:lower(), "sell") or msgcontains(msg:lower(), "buy")) and getPlayerStorageValue(cid, 1038) ~= 1 then
        npcHandler:say("I don't do business with humans.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    end
    return 1
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
npcHandler:addModule(ShopModule:new({ 'scimitar' }, 2419, 150, 'scimitar'))
addSellableItem({ 'giant sword' }, 2393, 17000, 'giant sword')
addSellableItem({ 'serpent sword' }, 2409, 900, 'serpent sword')
addSellableItem({ 'poison dagger' }, 2411, 50, 'poison dagger')
addSellableItem({ 'knight axe' }, 2430, 2000, 'knight axe')
addSellableItem({ 'dragon hammer' }, 2434, 2000, 'dragon hammer')
addSellableItem({ 'skull staff' }, 2436, 6000, 'skull staff')
addSellableItem({ 'dark armor' }, 2489, 400, 'dark armor')
addSellableItem({ 'knight armor' }, 2476, 5000, 'knight armor')
addSellableItem({ 'dark helmet' }, 2490, 250, 'dark helmet')
addSellableItem({ 'warrior helmet' }, 2475, 5000, 'warrior helmet')
addSellableItem({ 'strange helmet' }, 2479, 500, 'strange helmet')
addSellableItem({ 'mystic turban' }, 2663, 150, 'mystic turban')
addSellableItem({ 'knight legs' }, 2477, 5000, 'knight legs')
addSellableItem({ 'tower shield' }, 2528, 8000, 'tower shield')
addSellableItem({ 'black shield' }, 2529, 800, 'black shield')
addSellableItem({ 'ancient shield' }, 2532, 900, 'ancient shield')
addSellableItem({ 'vampire shield' }, 2534, 15000, 'vampire shield')
addBuyableItem({ 'ice rapier' }, 2396, 5000, 'ice rapier')
addBuyableItem({ 'serpent sword' }, 2409, 6000, 'serpent sword')
addBuyableItem({ 'dark armor' }, 2489, 1500, 'dark armor')
addBuyableItem({ 'dark helmet' }, 2490, 1000, 'dark helmet')
addBuyableItem({ 'ancient shield' }, 2532, 5000, 'ancient shield')

npcHandler:setMessage(MESSAGE_GREET, "What do you want from me, |PLAYERNAME|?")
npcHandler:setMessage(MESSAGE_PLACEDINQUEUE,
    "It might have escaped your limited human perception, but I am already talking to somebody else.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, human.")
npcHandler:setMessage(MESSAGE_FAREWELL,
    "Farewell, human. When I have taken my rightful place I shall remember those who served me well. Even if they are only humans.")

local function onTradeRequest(cid)
    if Player(cid):getStorageValue(1038) ~= 1 then
        npcHandler:say('Sorry, you need to complete the mission.', cid)
        return false
    end

    return true
end

npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
cool, I'm at work now. As soon as I get home I will test it. thanks
 
Try this:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
local npcHandlerfocus = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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

-- OTServ event handling functions end
local function creatureSayCallback(cid, type, msg)
    if (getPlayerStorageValue(cid, 1029) ~= 1) then
        return 0
    end

    if (msgcontains(msg:lower(), "djanni'hah")) then
        npcHandler:say('What do you want from me, ' .. getPlayerName(cid) .. '?')
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (msgcontains(msg:lower(), "mission") and npcHandlerfocus == 0 and getPlayerStorageValue(cid, 8131) ~= 1) then
        npcHandler:say("So Baa'leal thinks you are up to do a mission for us? ...")
        npcHandler:say("I think he is getting old, entrusting human scum such as you are with an important mission like that. ..."
            , cid, 3000)
        npcHandler:say("Personally, I don't understand why you haven't been slaughtered right at the gates. ...", cid, 5000)
        npcHandler:say("Anyway. Are you prepared to embark on a dangerous mission for us?", cid, 7000)
        npcHandlerfocus = 1
    elseif (msgcontains(msg:lower(), "yes") and npcHandlerfocus == 1) then
        setPlayerStorageValue(cid, 8131, 1)
        npcHandler:say("All right then, human. Have you ever heard of the 'Tears of Daraman'? ...")
        npcHandler:say("They are precious gemstones made of some unknown blue mineral and possess enormous magical power. ..."
            , cid, 3000)
        npcHandler:say("If you want to learn more about these gemstones don't forget to visit our library. ...", cid, 5000)
        npcHandler:say("Anyway, one of them is enough to create thousands of our mighty djinn blades. ...", cid, 7000)
        npcHandler:say("Unfortunately my last gemstone broke and therefore I'm not able to create new blades anymore. ...", cid
            , 9000)
        npcHandler:say("To my knowledge there is only one place where you can find these gemstones - I know for a fact that the Marid have at least one of them. ..."
            , cid, 11000)
        npcHandler:say("Well... to cut a long story short, your mission is to sneak into Ashta'daramai and to steal it. ...",
            cid, 13000)
        npcHandler:say("Needless to say, the Marid won't be too eager to part with it. Try not to get killed until you have delivered the stone to me."
            , cid, 15000)
        npcHandler.focus = cid
        npcHandlerfocus = 4
    elseif (msgcontains(msg:lower(), "no") and npcHandlerfocus == 1) then
        npcHandler:say("I wouldn't expect anything different from a human.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 8131) == 1 and
            getPlayerStorageValue(cid, 10229) ~= 1) then
        npcHandler:say("You still haven't gotten the item I asked for. Go to the blue djinn fortress and bring her back.")
        npcHandler.focus = cid
        npcHandlerfocus = 0

    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 10229) == 1 and
            getPlayerStorageValue(cid, 10230) ~= 1) then
        npcHandler:say('Did you find the tear of Daraman?')
        npcHandler.focus = cid
        npcHandlerfocus = 2
    elseif (msgcontains(msg:lower(), "yes") and npcHandlerfocus == 2) then
        if getPlayerItemCount(cid, 2346) >= 1 then
            npcHandler:say("So you have made it? You have really managed to steal a Tear of Daraman? ...")
            npcHandler:say("Amazing how you humans are just impossible to get rid of. Incidentally, you have this character trait in common with many insects and with other vermin. ..."
                , cid, 2000)
            npcHandler:say("Nevermind. I hate to say it, but it you have done us a favour, human. That gemstone will serve us well. ..."
                , cid, 4000)
            npcHandler:say("Baa'leal, wants you to talk to Malor concerning some new mission. ...", cid, 6000)
            npcHandler:say("Looks like you have managed to extended your life expectancy - for just a bit longer.", cid, 8000)
            setPlayerStorageValue(cid, 1032, 1)
            setPlayerStorageValue(cid, 10230, 1)
            doPlayerRemoveItem(cid, 2346, 1)
            npcHandler.focus = cid
            npcHandlerfocus = 3
        elseif (msgcontains(msg:lower(), "no") and npcHandlerfocus == 2) then
            npcHandler:say("You do not have the Tear of Daraman.")
            npcHandler.focus = cid
            npcHandlerfocus = 0
        end
    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 1032) == 1 and
            getPlayerStorageValue(cid, 10230) == 1) then
        npcHandler:say("I have no more missions for you. See if Malor has something for you, he's at the top of the tower.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (msgcontains(msg:lower(), "sell") or msgcontains(msg:lower(), "buy")) and getPlayerStorageValue(cid, 1038) ~= 1 then
        npcHandler:say("I don't do business with humans.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    end
    return 1
end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
npcHandler:addModule(ShopModule:new({ 'scimitar' }, 2419, 150, 'scimitar'))
addSellableItem({ 'giant sword' }, 2393, 17000, 'giant sword')
addSellableItem({ 'serpent sword' }, 2409, 900, 'serpent sword')
addSellableItem({ 'poison dagger' }, 2411, 50, 'poison dagger')
addSellableItem({ 'knight axe' }, 2430, 2000, 'knight axe')
addSellableItem({ 'dragon hammer' }, 2434, 2000, 'dragon hammer')
addSellableItem({ 'skull staff' }, 2436, 6000, 'skull staff')
addSellableItem({ 'dark armor' }, 2489, 400, 'dark armor')
addSellableItem({ 'knight armor' }, 2476, 5000, 'knight armor')
addSellableItem({ 'dark helmet' }, 2490, 250, 'dark helmet')
addSellableItem({ 'warrior helmet' }, 2475, 5000, 'warrior helmet')
addSellableItem({ 'strange helmet' }, 2479, 500, 'strange helmet')
addSellableItem({ 'mystic turban' }, 2663, 150, 'mystic turban')
addSellableItem({ 'knight legs' }, 2477, 5000, 'knight legs')
addSellableItem({ 'tower shield' }, 2528, 8000, 'tower shield')
addSellableItem({ 'black shield' }, 2529, 800, 'black shield')
addSellableItem({ 'ancient shield' }, 2532, 900, 'ancient shield')
addSellableItem({ 'vampire shield' }, 2534, 15000, 'vampire shield')
addBuyableItem({ 'ice rapier' }, 2396, 5000, 'ice rapier')
addBuyableItem({ 'serpent sword' }, 2409, 6000, 'serpent sword')
addBuyableItem({ 'dark armor' }, 2489, 1500, 'dark armor')
addBuyableItem({ 'dark helmet' }, 2490, 1000, 'dark helmet')
addBuyableItem({ 'ancient shield' }, 2532, 5000, 'ancient shield')

npcHandler:setMessage(MESSAGE_GREET, "What do you want from me, |PLAYERNAME|?")
npcHandler:setMessage(MESSAGE_PLACEDINQUEUE,
    "It might have escaped your limited human perception, but I am already talking to somebody else.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, human.")
npcHandler:setMessage(MESSAGE_FAREWELL,
    "Farewell, human. When I have taken my rightful place I shall remember those who served me well. Even if they are only humans.")

local function onTradeRequest(cid)
    if Player(cid):getStorageValue(1038) ~= 1 then
        npcHandler:say('Sorry, you need to complete the mission.', cid)
        return false
    end

    return true
end

npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I tested it here, but now it gives me another error. Can you help me to resolve? Only one detail on my server does not have the function to speak TRADE the purchase and sale system is the old one from 7.4.

Captura de tela 2022-12-01 002658.png
 
Lua:
local itemList = {
    [1] = { name = "scimitar", id = 2419, price = 150 },
    [2] = { name = "giant sword", id = 2393, price = 17000 },
    [3] = { name = "serpent sword", id = 2409, price = 900 },
}

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

    if getPlayerStorageValue(cid, 1029) ~= 1 then
        return false
    end

    if (msgcontains(msg:lower(), "djanni'hah")) then
        npcHandler:say('What do you want from me, ' .. getPlayerName(cid) .. '?')
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (msgcontains(msg:lower(), "mission") and npcHandlerfocus == 0 and getPlayerStorageValue(cid, 8131) ~= 1) then
        npcHandler:say("So Baa'leal thinks you are up to do a mission for us? ...")
        npcHandler:say("I think he is getting old, entrusting human scum such as you are with an important mission like that. ..."
            , cid, 3000)
        npcHandler:say("Personally, I don't understand why you haven't been slaughtered right at the gates. ...", cid,
            5000)
        npcHandler:say("Anyway. Are you prepared to embark on a dangerous mission for us?", cid, 7000)
        npcHandlerfocus = 1
    elseif (msgcontains(msg:lower(), "yes") and npcHandlerfocus == 1) then
        setPlayerStorageValue(cid, 8131, 1)
        npcHandler:say("All right then, human. Have you ever heard of the 'Tears of Daraman'? ...")
        npcHandler:say("They are precious gemstones made of some unknown blue mineral and possess enormous magical power. ..."
            , cid, 3000)
        npcHandler:say("If you want to learn more about these gemstones don't forget to visit our library. ...", cid,
            5000)
        npcHandler:say("Anyway, one of them is enough to create thousands of our mighty djinn blades. ...", cid, 7000)
        npcHandler:say("Unfortunately my last gemstone broke and therefore I'm not able to create new blades anymore. ..."
            , cid
            , 9000)
        npcHandler:say("To my knowledge there is only one place where you can find these gemstones - I know for a fact that the Marid have at least one of them. ..."
            , cid, 11000)
        npcHandler:say("Well... to cut a long story short, your mission is to sneak into Ashta'daramai and to steal it. ..."
            ,
            cid, 13000)
        npcHandler:say("Needless to say, the Marid won't be too eager to part with it. Try not to get killed until you have delivered the stone to me."
            , cid, 15000)
        npcHandler.focus = cid
        npcHandlerfocus = 4
    elseif (msgcontains(msg:lower(), "no") and npcHandlerfocus == 1) then
        npcHandler:say("I wouldn't expect anything different from a human.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 8131) == 1 and
            getPlayerStorageValue(cid, 10229) ~= 1) then
        npcHandler:say("You still haven't gotten the item I asked for. Go to the blue djinn fortress and bring her back.")
        npcHandler.focus = cid
        npcHandlerfocus = 0

    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 10229) == 1 and
            getPlayerStorageValue(cid, 10230) ~= 1) then
        npcHandler:say('Did you find the tear of Daraman?')
        npcHandler.focus = cid
        npcHandlerfocus = 2
    elseif (msgcontains(msg:lower(), "yes") and npcHandlerfocus == 2) then
        if getPlayerItemCount(cid, 2346) >= 1 then
            npcHandler:say("So you have made it? You have really managed to steal a Tear of Daraman? ...")
            npcHandler:say("Amazing how you humans are just impossible to get rid of. Incidentally, you have this character trait in common with many insects and with other vermin. ..."
                , cid, 2000)
            npcHandler:say("Nevermind. I hate to say it, but it you have done us a favour, human. That gemstone will serve us well. ..."
                , cid, 4000)
            npcHandler:say("Baa'leal, wants you to talk to Malor concerning some new mission. ...", cid, 6000)
            npcHandler:say("Looks like you have managed to extended your life expectancy - for just a bit longer.", cid,
                8000)
            setPlayerStorageValue(cid, 1032, 1)
            setPlayerStorageValue(cid, 10230, 1)
            doPlayerRemoveItem(cid, 2346, 1)
            npcHandler.focus = cid
            npcHandlerfocus = 3
        elseif (msgcontains(msg:lower(), "no") and npcHandlerfocus == 2) then
            npcHandler:say("You do not have the Tear of Daraman.")
            npcHandler.focus = cid
            npcHandlerfocus = 0
        end
    elseif (
        msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 1032) == 1 and
            getPlayerStorageValue(cid, 10230) == 1) then
        npcHandler:say("I have no more missions for you. See if Malor has something for you, he's at the top of the tower.")
        npcHandler.focus = cid
        npcHandlerfocus = 0
    end

    for i = 1, #itemList, 1 do
        if msgcontains(msg, itemList[i].name) then
            if getPlayerStorageValue(cid, 1038) >= 1 then
                npcHandler:say("Want to buy '" .. itemList[i].name .. "' for " .. itemList[i].price .. " gold coins?",
                    cid)
                npcHandler.topic[cid] = 1
            else
                npcHandler:say("You have not completed the mission.", cid)
            end
        elseif msgcontains(msg, "yes") then
            if npcHandler.topic[cid] == 1 then
                if getPlayerMoney(cid) >= itemList[i].price then
                    doPlayerAddItem(cid, itemList[i].id, 1)
                    doPlayerRemoveMoney(cid, itemList[i].price)
                    npcHandler:say("Here is your '" .. itemList[i].name .. "'.", cid)
                else
                    npcHandler:say("You need " .. itemList[i].price .. " gold coins to buy '" .. itemList[i].name .. "'."
                        ,
                        cid)
                end
            end
            npcHandler.topic[cid] = 0
        elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 1 then
            npcHandler:say("No problems. Have a great day!", cid)
            npcHandler.topic[cid] = 0
        end
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, "What do you want from me, |PLAYERNAME|?")
npcHandler:setMessage(MESSAGE_PLACEDINQUEUE,
    "It might have escaped your limited human perception, but I am already talking to somebody else.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, human.")
npcHandler:setMessage(MESSAGE_FAREWELL,
    "Farewell, human. When I have taken my rightful place I shall remember those who served me well. Even if they are only humans.")

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