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

HELP WITH NPC, 20$ for working npc

Qbecky

New Member
Joined
Mar 11, 2023
Messages
29
Reaction score
1
GitHub
QbeckyX
Hi, i want to create npc with repeatable mission. Plaese someone for help
I will pay 20$ for working script.

A. hi
B. hello! I have a mission for you, I need talons for my wife, could you bring me 50 talons? I saw few near Dragon Lords. Are you interested?
A. yes
B. Okay, so bring me 50 talons and ill give you 100 Tibia Coins.
- after looting 50 talons, talking again to NPC

A. hi
B. do you already have all the talons?
A. Yes

Then remove from player 50 Talons
Then add player 100 Tibia Coins

Code:
local internalNpcName = "Missionary of Hellheim"
local npcType = Game.createNpcType(internalNpcName)
local npcConfig = {}

npcConfig.name = internalNpcName
npcConfig.description = internalNpcName

npcConfig.health = 100
npcConfig.maxHealth = npcConfig.health
npcConfig.walkInterval = 2000
npcConfig.walkRadius = 2

npcConfig.outfit = {
    lookType = 129,
    lookHead = 115,
    lookBody = 39,
    lookLegs = 96,
    lookFeet = 118,
    lookAddons = 3
}

npcConfig.flags = {
    floorchange = false
}

npcConfig.voices = {
    interval = 15000,
    chance = 50,
    {text = 'Hey, you! Help me collect loot from monsters'}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

npcType.onThink = function(npc, interval)
    npcHandler:onThink(npc, interval)
end

npcType.onAppear = function(npc, creature)
    npcHandler:onAppear(npc, creature)
end

npcType.onDisappear = function(npc, creature)
    npcHandler:onDisappear(npc, creature)
end

npcType.onMove = function(npc, creature, fromPosition, toPosition)
    npcHandler:onMove(npc, creature, fromPosition, toPosition)
end

npcType.onSay = function(npc, creature, type, message)
    npcHandler:onSay(npc, creature, type, message)
end

npcType.onCloseChannel = function(npc, creature)
    npcHandler:onCloseChannel(npc, creature)
end

local function creatureSayCallback(npc, creature, type, message)
    local player = Player(creature)
    local playerId = player:getId()

    if not npcHandler:checkInteraction(npc, creature) then
        return false
    end
end

    -- Mission
    if MsgContains(message, 'mission') or MsgContains(message, 'quest') then
                npcHandler:say('I have a mission for you, I need talons for my wife, could you bring me 50 {talons}? I have heard its drops from Dragon Lords often', npc, creature)
            end
    if MsgContains(message, 'talons') or MsgContains(message, 'talons') or MsgContains(message, 'talony') then
                npcHandler:say('Are you interested?', npc, creature)
            npcHandler:setTopic(playerId, 2)
            end
    elseif npcHandler:getTopic(playerId) == 2 then
        if MsgContains(message, 'yes') then
            npcHandler:say('Alright then, if you bring me 50 pieces of Talons You probably have to kill really many dangerous monsters... so good luck! I will give you 10 Crystal Coins and 20 Dusts!', npc, creature)
            npcHandler:removeInteraction(npc, creature)
        else
            npcHandler:say('Yeah..my talons...', npc, creature)
        end
        npcHandler:setTopic(playerId, 0)
    elseif npcHandler:getTopic(playerId) == 3 then
        if MsgContains(message, 'mission') then
            if player:getItemCount(3034) < 50 then
                npcHandler:say('Sorry, but that\'s not enough talons yet to give you special items. Would you rather like to buy a normal backpack for 10 gold?', npc, creature)
            else
                npcHandler:say('Great! Here is your reward!', npc, creature)

                player:removeItem(3034, 50)
                player:addItem(3043, 10)
                player:addForgeDusts(20)
            end
        else
            npcHandler:say('I know, it\'s quite some work... don\'t lose heart, just keep killing monsters and you\'ll eventually get lucky. Would you rather like to buy a normal backpack for 10 gold?', npc, creature)
        end
        npcHandler:setTopic(playerId, 0)
    end

end

keywordHandler:addKeyword({'pet'}, StdModule.say, {npcHandler = npcHandler, text = 'There are some strange stories about a magicians pet names. Ask Hoggle about it.'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome, please help me with mission, |PLAYERNAME|! Ask me for {mission} and ill give you one!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye, |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)

-- On check npc shop message (look item)
npcType.onCheckItem = function(npc, player, clientId, subType)
end

npcType:register(npcConfig)
 
Last edited:
simple npc!!
doPlayerAddItem(cid, 6527, 100) << this line is add item in player
if(getPlayerItemCount(cid, 13685) >= 50) then
doPlayerRemoveItem(cid, 13685, 50) << remove item from player
just change id there ok


Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

        local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid


    if(msgcontains(msg, 'Talons') or msgcontains(msg, 'talons')) then
                selfSay('Okay, so bring me 50 talons and ill give you 100 Tibia Coins.', cid)
                talkState[talkUser] = 1

        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
            if(getPlayerItemCount(cid, 13685) >= 50) then
                doPlayerRemoveItem(cid, 13685, 50)
                doPlayerAddItem(cid, 6527, 100)
                doPlayerSendTextMessage(cid, 27,"you still have " .. getPlayerItemCount(cid,13685) .. " Talons.")
                selfSay('Thank you and come back often.', cid)
        else
                selfSay('You not have 50 talons', cid)
        end
            talkState[talkUser] = 0

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
         
         
elseif(msgcontains(msg, 'offer') or msgcontains(msg, 'trade') or msgcontains(msg, 'ofertas')) then
                selfSay('hello! I have a mission for you, I need talons for my wife, could you bring me 50 talons? I saw few near Dragon Lords. Are you interested?.', cid)
                selfSay('talons!.',cid)
        end
        return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
simple npc!!
doPlayerAddItem(cid, 6527, 100) << this line is add item in player
if(getPlayerItemCount(cid, 13685) >= 50) then
doPlayerRemoveItem(cid, 13685, 50) << remove item from player
just change id there ok


Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

        local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid


    if(msgcontains(msg, 'Talons') or msgcontains(msg, 'talons')) then
                selfSay('Okay, so bring me 50 talons and ill give you 100 Tibia Coins.', cid)
                talkState[talkUser] = 1

        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
            if(getPlayerItemCount(cid, 13685) >= 50) then
                doPlayerRemoveItem(cid, 13685, 50)
                doPlayerAddItem(cid, 6527, 100)
                doPlayerSendTextMessage(cid, 27,"you still have " .. getPlayerItemCount(cid,13685) .. " Talons.")
                selfSay('Thank you and come back often.', cid)
        else
                selfSay('You not have 50 talons', cid)
        end
            talkState[talkUser] = 0

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
        
        
elseif(msgcontains(msg, 'offer') or msgcontains(msg, 'trade') or msgcontains(msg, 'ofertas')) then
                selfSay('hello! I have a mission for you, I need talons for my wife, could you bring me 50 talons? I saw few near Dragon Lords. Are you interested?.', cid)
                selfSay('talons!.',cid)
        end
        return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Could u give me full code ?
 
Hello, I did not test this:


Lua:
local internalNpcName = "Missionary of Hellheim"
local npcType = Game.createNpcType(internalNpcName)
local npcConfig = {}

npcConfig.name = internalNpcName
npcConfig.description = internalNpcName

npcConfig.health = 100
npcConfig.maxHealth = npcConfig.health
npcConfig.walkInterval = 2000
npcConfig.walkRadius = 2

npcConfig.outfit = {
    lookType = 129,
    lookHead = 115,
    lookBody = 39,
    lookLegs = 96,
    lookFeet = 118,
    lookAddons = 3
}

npcConfig.flags = {
    floorchange = false
}

npcConfig.voices = {
    interval = 15000,
    chance = 50,
    {text = 'Hey, you! Help me collect loot from monsters'}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

npcType.onThink = function(npc, interval)
    npcHandler:onThink(npc, interval)
end

npcType.onAppear = function(npc, creature)
    npcHandler:onAppear(npc, creature)
end

npcType.onDisappear = function(npc, creature)
    npcHandler:onDisappear(npc, creature)
end

npcType.onMove = function(npc, creature, fromPosition, toPosition)
    npcHandler:onMove(npc, creature, fromPosition, toPosition)
end

npcType.onSay = function(npc, creature, type, message)
    npcHandler:onSay(npc, creature, type, message)
end

npcType.onCloseChannel = function(npc, creature)
    npcHandler:onCloseChannel(npc, creature)
end

local storageValue = 12345 -- The storage value used to keep track of the player's progress
local requiredItemCount = 50 -- The number of talons required to complete the quest
local talonItemId = 2154 -- The item ID of the talon
local rewardItemId = 2148 -- The item ID of the reward item
local rewardItemCount = 100 -- The amount of the reward item given to the player

local function creatureSayCallback(npc, creature, type, message)
    local player = Player(creature)
    local playerId = player:getId()

    if not npcHandler:checkInteraction(npc, creature) then
        return false
    end

    if MsgContains(message, 'hi') or MsgContains(message, 'hello') then
        if player:getStorageValue(storageValue) == 1 then
            npcHandler:say('Do you already have all '..requiredItemCount..' talons?', npc, creature)
            npcHandler:setTopic(playerId, 2)
        else
            npcHandler:say('Hello! I have a mission for you. I need '..requiredItemCount..' talons for my wife. Could you bring them to me? I saw a few near the Dragon Lords. Are you interested?', npc, creature)
            npcHandler:setTopic(playerId, 1)
        end
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 1 then
        npcHandler:say('Great! Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        npcHandler:setTopic(playerId, 0)
        player:setStorageValue(storageValue, 1) -- Set mission flag to indicate the player has started the mission
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 2 then
        if player:getItemCount(talonItemId) >= requiredItemCount then
            player:removeItem(talonItemId, requiredItemCount)
            player:addItem(rewardItemId, rewardItemCount) -- Reward the player with the specified item and amount
            player:setStorageValue(storageValue, 0) -- Reset mission flag
            npcHandler:say('Thank you for bringing me the talons. Here is your reward of '..rewardItemCount..' Tibia Coins.', npc, creature)
        else
            npcHandler:say('You do not have enough talons yet. Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        end
        npcHandler:setTopic(playerId, 0)
    end

    return true
end

keywordHandler:addKeyword({'pet'}, StdModule.say, {npcHandler = npcHandler, text = 'There are some strange stories about a magicians pet names. Ask Hoggle about it.'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome, please help me with mission, |PLAYERNAME|! Ask me for {mission} and ill give you one!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye, |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)

-- On check npc shop message (look item)
npcType.onCheckItem = function(npc, player, clientId, subType)
end

npcType:register(npcConfig)
 
Hello, I did not test this:


Lua:
local internalNpcName = "Missionary of Hellheim"
local npcType = Game.createNpcType(internalNpcName)
local npcConfig = {}

npcConfig.name = internalNpcName
npcConfig.description = internalNpcName

npcConfig.health = 100
npcConfig.maxHealth = npcConfig.health
npcConfig.walkInterval = 2000
npcConfig.walkRadius = 2

npcConfig.outfit = {
    lookType = 129,
    lookHead = 115,
    lookBody = 39,
    lookLegs = 96,
    lookFeet = 118,
    lookAddons = 3
}

npcConfig.flags = {
    floorchange = false
}

npcConfig.voices = {
    interval = 15000,
    chance = 50,
    {text = 'Hey, you! Help me collect loot from monsters'}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

npcType.onThink = function(npc, interval)
    npcHandler:onThink(npc, interval)
end

npcType.onAppear = function(npc, creature)
    npcHandler:onAppear(npc, creature)
end

npcType.onDisappear = function(npc, creature)
    npcHandler:onDisappear(npc, creature)
end

npcType.onMove = function(npc, creature, fromPosition, toPosition)
    npcHandler:onMove(npc, creature, fromPosition, toPosition)
end

npcType.onSay = function(npc, creature, type, message)
    npcHandler:onSay(npc, creature, type, message)
end

npcType.onCloseChannel = function(npc, creature)
    npcHandler:onCloseChannel(npc, creature)
end

local storageValue = 12345 -- The storage value used to keep track of the player's progress
local requiredItemCount = 50 -- The number of talons required to complete the quest
local talonItemId = 2154 -- The item ID of the talon
local rewardItemId = 2148 -- The item ID of the reward item
local rewardItemCount = 100 -- The amount of the reward item given to the player

local function creatureSayCallback(npc, creature, type, message)
    local player = Player(creature)
    local playerId = player:getId()

    if not npcHandler:checkInteraction(npc, creature) then
        return false
    end

    if MsgContains(message, 'hi') or MsgContains(message, 'hello') then
        if player:getStorageValue(storageValue) == 1 then
            npcHandler:say('Do you already have all '..requiredItemCount..' talons?', npc, creature)
            npcHandler:setTopic(playerId, 2)
        else
            npcHandler:say('Hello! I have a mission for you. I need '..requiredItemCount..' talons for my wife. Could you bring them to me? I saw a few near the Dragon Lords. Are you interested?', npc, creature)
            npcHandler:setTopic(playerId, 1)
        end
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 1 then
        npcHandler:say('Great! Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        npcHandler:setTopic(playerId, 0)
        player:setStorageValue(storageValue, 1) -- Set mission flag to indicate the player has started the mission
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 2 then
        if player:getItemCount(talonItemId) >= requiredItemCount then
            player:removeItem(talonItemId, requiredItemCount)
            player:addItem(rewardItemId, rewardItemCount) -- Reward the player with the specified item and amount
            player:setStorageValue(storageValue, 0) -- Reset mission flag
            npcHandler:say('Thank you for bringing me the talons. Here is your reward of '..rewardItemCount..' Tibia Coins.', npc, creature)
        else
            npcHandler:say('You do not have enough talons yet. Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        end
        npcHandler:setTopic(playerId, 0)
    end

    return true
end

keywordHandler:addKeyword({'pet'}, StdModule.say, {npcHandler = npcHandler, text = 'There are some strange stories about a magicians pet names. Ask Hoggle about it.'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome, please help me with mission, |PLAYERNAME|! Ask me for {mission} and ill give you one!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye, |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)

-- On check npc shop message (look item)
npcType.onCheckItem = function(npc, player, clientId, subType)
end

npcType:register(npcConfig)
He doesnt react for "mission"
 
Try this:


Lua:
local internalNpcName = "Missionary of Hellheim"
local npcType = Game.createNpcType(internalNpcName)
local npcConfig = {}

npcConfig.name = internalNpcName
npcConfig.description = internalNpcName

npcConfig.health = 100
npcConfig.maxHealth = npcConfig.health
npcConfig.walkInterval = 2000
npcConfig.walkRadius = 2

npcConfig.outfit = {
    lookType = 129,
    lookHead = 115,
    lookBody = 39,
    lookLegs = 96,
    lookFeet = 118,
    lookAddons = 3
}

npcConfig.flags = {
    floorchange = false
}

npcConfig.voices = {
    interval = 15000,
    chance = 50,
    {text = 'Hey, you! Help me collect loot from monsters'}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

npcType.onThink = function(npc, interval)
    npcHandler:onThink(npc, interval)
end

npcType.onAppear = function(npc, creature)
    npcHandler:onAppear(npc, creature)
end

npcType.onDisappear = function(npc, creature)
    npcHandler:onDisappear(npc, creature)
end

npcType.onMove = function(npc, creature, fromPosition, toPosition)
    npcHandler:onMove(npc, creature, fromPosition, toPosition)
end

npcType.onSay = function(npc, creature, type, message)
    npcHandler:onSay(npc, creature, type, message)
end

npcType.onCloseChannel = function(npc, creature)
    npcHandler:onCloseChannel(npc, creature)
end

local storageValue = 12345 -- The storage value used to keep track of the player's progress
local requiredItemCount = 50 -- The number of talons required to complete the quest
local talonItemId = 2154 -- The item ID of the talon
local rewardItemId = 2148 -- The item ID of the reward item
local rewardItemCount = 100 -- The amount of the reward item given to the player

local function creatureSayCallback(npc, creature, type, message)
    local player = Player(creature)
    local playerId = player:getId()

    if not npcHandler:checkInteraction(npc, creature) then
        return false
    end

    if MsgContains(message, 'hi') or MsgContains(message, 'hello') then
        npcHandler:say('Hello! How can I assist you today?', npc, creature)
        npcHandler:setTopic(playerId, 0)
    elseif MsgContains(message, 'mission') then
        if player:getStorageValue(storageValue) == 1 then
            npcHandler:say('Do you already have all '..requiredItemCount..' talons?', npc, creature)
            npcHandler:setTopic(playerId, 2)
        else
            npcHandler:say('Hello! I have a mission for you. I need '..requiredItemCount..' talons for my wife. Could you bring them to me? I saw a few near the Dragon Lords. Are you interested?', npc, creature)
            npcHandler:setTopic(playerId, 1)
        end
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 1 then
        npcHandler:say('Great! Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        npcHandler:setTopic(playerId, 0)
        player:setStorageValue(storageValue, 1) -- Set mission flag to indicate the player has started the mission
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 2 then
        if player:getItemCount(talonItemId) >= requiredItemCount then
            player:removeItem(talonItemId, requiredItemCount)
            player:addItem(rewardItemId, rewardItemCount) -- Reward the player with the specified item and amount
            player:setStorageValue(storageValue, 0) -- Reset mission flag
            npcHandler:say('Thank you for bringing me the talons. Here is your reward of '..rewardItemCount..' Tibia Coins.', npc, creature)
        else
            npcHandler:say('You do not have enough talons yet. Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        end
        npcHandler:setTopic(playerId, 0)
    end

    return true
end

keywordHandler:addKeyword({'pet'}, StdModule.say, {npcHandler = npcHandler, text = 'There are some strange stories about a magicians pet names. Ask Hoggle about it.'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome, please help me with mission, |PLAYERNAME|! Ask me for {mission} and ill give you one!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye, |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)

-- On check npc shop message (look item)
npcType.onCheckItem = function(npc, player, clientId, subType)
end

npcType:register(npcConfig)
 
Try this:


Lua:
local internalNpcName = "Missionary of Hellheim"
local npcType = Game.createNpcType(internalNpcName)
local npcConfig = {}

npcConfig.name = internalNpcName
npcConfig.description = internalNpcName

npcConfig.health = 100
npcConfig.maxHealth = npcConfig.health
npcConfig.walkInterval = 2000
npcConfig.walkRadius = 2

npcConfig.outfit = {
    lookType = 129,
    lookHead = 115,
    lookBody = 39,
    lookLegs = 96,
    lookFeet = 118,
    lookAddons = 3
}

npcConfig.flags = {
    floorchange = false
}

npcConfig.voices = {
    interval = 15000,
    chance = 50,
    {text = 'Hey, you! Help me collect loot from monsters'}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

npcType.onThink = function(npc, interval)
    npcHandler:onThink(npc, interval)
end

npcType.onAppear = function(npc, creature)
    npcHandler:onAppear(npc, creature)
end

npcType.onDisappear = function(npc, creature)
    npcHandler:onDisappear(npc, creature)
end

npcType.onMove = function(npc, creature, fromPosition, toPosition)
    npcHandler:onMove(npc, creature, fromPosition, toPosition)
end

npcType.onSay = function(npc, creature, type, message)
    npcHandler:onSay(npc, creature, type, message)
end

npcType.onCloseChannel = function(npc, creature)
    npcHandler:onCloseChannel(npc, creature)
end

local storageValue = 12345 -- The storage value used to keep track of the player's progress
local requiredItemCount = 50 -- The number of talons required to complete the quest
local talonItemId = 2154 -- The item ID of the talon
local rewardItemId = 2148 -- The item ID of the reward item
local rewardItemCount = 100 -- The amount of the reward item given to the player

local function creatureSayCallback(npc, creature, type, message)
    local player = Player(creature)
    local playerId = player:getId()

    if not npcHandler:checkInteraction(npc, creature) then
        return false
    end

    if MsgContains(message, 'hi') or MsgContains(message, 'hello') then
        npcHandler:say('Hello! How can I assist you today?', npc, creature)
        npcHandler:setTopic(playerId, 0)
    elseif MsgContains(message, 'mission') then
        if player:getStorageValue(storageValue) == 1 then
            npcHandler:say('Do you already have all '..requiredItemCount..' talons?', npc, creature)
            npcHandler:setTopic(playerId, 2)
        else
            npcHandler:say('Hello! I have a mission for you. I need '..requiredItemCount..' talons for my wife. Could you bring them to me? I saw a few near the Dragon Lords. Are you interested?', npc, creature)
            npcHandler:setTopic(playerId, 1)
        end
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 1 then
        npcHandler:say('Great! Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        npcHandler:setTopic(playerId, 0)
        player:setStorageValue(storageValue, 1) -- Set mission flag to indicate the player has started the mission
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 2 then
        if player:getItemCount(talonItemId) >= requiredItemCount then
            player:removeItem(talonItemId, requiredItemCount)
            player:addItem(rewardItemId, rewardItemCount) -- Reward the player with the specified item and amount
            player:setStorageValue(storageValue, 0) -- Reset mission flag
            npcHandler:say('Thank you for bringing me the talons. Here is your reward of '..rewardItemCount..' Tibia Coins.', npc, creature)
        else
            npcHandler:say('You do not have enough talons yet. Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        end
        npcHandler:setTopic(playerId, 0)
    end

    return true
end

keywordHandler:addKeyword({'pet'}, StdModule.say, {npcHandler = npcHandler, text = 'There are some strange stories about a magicians pet names. Ask Hoggle about it.'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome, please help me with mission, |PLAYERNAME|! Ask me for {mission} and ill give you one!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye, |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)

-- On check npc shop message (look item)
npcType.onCheckItem = function(npc, player, clientId, subType)
end

npcType:register(npcConfig)
Its working good, but how to make Tibia Coins as reward which aren't physicaly item? They are assigned to the account
 
Try this @Qbecky :


Lua:
local internalNpcName = "Missionary of Hellheim"
local npcType = Game.createNpcType(internalNpcName)
local npcConfig = {}

npcConfig.name = internalNpcName
npcConfig.description = internalNpcName

npcConfig.health = 100
npcConfig.maxHealth = npcConfig.health
npcConfig.walkInterval = 2000
npcConfig.walkRadius = 2

npcConfig.outfit = {
    lookType = 129,
    lookHead = 115,
    lookBody = 39,
    lookLegs = 96,
    lookFeet = 118,
    lookAddons = 3
}

npcConfig.flags = {
    floorchange = false
}

npcConfig.voices = {
    interval = 15000,
    chance = 50,
    {text = 'Hey, you! Help me collect loot from monsters'}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

npcType.onThink = function(npc, interval)
    npcHandler:onThink(npc, interval)
end

npcType.onAppear = function(npc, creature)
    npcHandler:onAppear(npc, creature)
end

npcType.onDisappear = function(npc, creature)
    npcHandler:onDisappear(npc, creature)
end

npcType.onMove = function(npc, creature, fromPosition, toPosition)
    npcHandler:onMove(npc, creature, fromPosition, toPosition)
end

npcType.onSay = function(npc, creature, type, message)
    npcHandler:onSay(npc, creature, type, message)
end

npcType.onCloseChannel = function(npc, creature)
    npcHandler:onCloseChannel(npc, creature)
end

local storageValue = 12345 -- The storage value used to keep track of the player's progress
local requiredItemCount = 50 -- The number of talons required to complete the quest
local talonItemId = 2154 -- The item ID of the talon
local rewardCoinCount = 100 -- The amount of Tibia Coins given to the player as a reward

local function creatureSayCallback(npc, creature, type, message)
    local player = Player(creature)
    local playerId = player:getId()

    if not npcHandler:checkInteraction(npc, creature) then
        return false
    end

    if MsgContains(message, 'hi') or MsgContains(message, 'hello') then
        npcHandler:say('Hello! Can I help you with anything?', npc, creature)
    elseif MsgContains(message, 'mission') then
        if player:getStorageValue(storageValue) == 1 then
            npcHandler:say('Do you already have all '..requiredItemCount..' talons?', npc, creature)
            npcHandler:setTopic(playerId, 2)
        else
            npcHandler:say('Hello! I have a mission for you. I need '..requiredItemCount..' talons for my wife. Could you bring them to me? I saw a few near the Dragon Lords. Are you interested?', npc, creature)
            npcHandler:setTopic(playerId, 1)
        end
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 1 then
        npcHandler:say('Great! Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        npcHandler:setTopic(playerId, 0)
        player:setStorageValue(storageValue, 1) -- Set mission flag to indicate the player has started the mission
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 2 then
        if player:getItemCount(talonItemId) >= requiredItemCount then
            player:removeItem(talonItemId, requiredItemCount)
            player:addTibiaCoins(rewardCoinCount) -- Reward the player with the specified amount of Tibia Coins
            player:setStorageValue(storageValue, 0) -- Reset mission flag
            npcHandler:say('Thank you for bringing me the talons. Here is your reward of '..rewardCoinCount..' Tibia Coins.', npc, creature)
        else
            npcHandler:say('You do not have enough talons yet. Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        end
        npcHandler:setTopic(playerId, 0)
    end

    return true
end

keywordHandler:addKeyword({'pet'}, StdModule.say, {npcHandler = npcHandler, text = 'There are some strange stories about a magicians pet names. Ask Hoggle about it.'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome, please help me with mission, |PLAYERNAME|! Ask me for {mission} and ill give you one!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye, |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)

-- On check npc shop message (look item)
npcType.onCheckItem = function(npc, player, clientId, subType)
end

npcType:register(npcConfig)
 
Try this @Qbecky :


Lua:
local internalNpcName = "Missionary of Hellheim"
local npcType = Game.createNpcType(internalNpcName)
local npcConfig = {}

npcConfig.name = internalNpcName
npcConfig.description = internalNpcName

npcConfig.health = 100
npcConfig.maxHealth = npcConfig.health
npcConfig.walkInterval = 2000
npcConfig.walkRadius = 2

npcConfig.outfit = {
    lookType = 129,
    lookHead = 115,
    lookBody = 39,
    lookLegs = 96,
    lookFeet = 118,
    lookAddons = 3
}

npcConfig.flags = {
    floorchange = false
}

npcConfig.voices = {
    interval = 15000,
    chance = 50,
    {text = 'Hey, you! Help me collect loot from monsters'}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

npcType.onThink = function(npc, interval)
    npcHandler:onThink(npc, interval)
end

npcType.onAppear = function(npc, creature)
    npcHandler:onAppear(npc, creature)
end

npcType.onDisappear = function(npc, creature)
    npcHandler:onDisappear(npc, creature)
end

npcType.onMove = function(npc, creature, fromPosition, toPosition)
    npcHandler:onMove(npc, creature, fromPosition, toPosition)
end

npcType.onSay = function(npc, creature, type, message)
    npcHandler:onSay(npc, creature, type, message)
end

npcType.onCloseChannel = function(npc, creature)
    npcHandler:onCloseChannel(npc, creature)
end

local storageValue = 12345 -- The storage value used to keep track of the player's progress
local requiredItemCount = 50 -- The number of talons required to complete the quest
local talonItemId = 2154 -- The item ID of the talon
local rewardCoinCount = 100 -- The amount of Tibia Coins given to the player as a reward

local function creatureSayCallback(npc, creature, type, message)
    local player = Player(creature)
    local playerId = player:getId()

    if not npcHandler:checkInteraction(npc, creature) then
        return false
    end

    if MsgContains(message, 'hi') or MsgContains(message, 'hello') then
        npcHandler:say('Hello! Can I help you with anything?', npc, creature)
    elseif MsgContains(message, 'mission') then
        if player:getStorageValue(storageValue) == 1 then
            npcHandler:say('Do you already have all '..requiredItemCount..' talons?', npc, creature)
            npcHandler:setTopic(playerId, 2)
        else
            npcHandler:say('Hello! I have a mission for you. I need '..requiredItemCount..' talons for my wife. Could you bring them to me? I saw a few near the Dragon Lords. Are you interested?', npc, creature)
            npcHandler:setTopic(playerId, 1)
        end
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 1 then
        npcHandler:say('Great! Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        npcHandler:setTopic(playerId, 0)
        player:setStorageValue(storageValue, 1) -- Set mission flag to indicate the player has started the mission
    elseif MsgContains(message, 'yes') and npcHandler:getTopic(playerId) == 2 then
        if player:getItemCount(talonItemId) >= requiredItemCount then
            player:removeItem(talonItemId, requiredItemCount)
            player:addTibiaCoins(rewardCoinCount) -- Reward the player with the specified amount of Tibia Coins
            player:setStorageValue(storageValue, 0) -- Reset mission flag
            npcHandler:say('Thank you for bringing me the talons. Here is your reward of '..rewardCoinCount..' Tibia Coins.', npc, creature)
        else
            npcHandler:say('You do not have enough talons yet. Please come back to me when you have all '..requiredItemCount..' talons.', npc, creature)
        end
        npcHandler:setTopic(playerId, 0)
    end

    return true
end

keywordHandler:addKeyword({'pet'}, StdModule.say, {npcHandler = npcHandler, text = 'There are some strange stories about a magicians pet names. Ask Hoggle about it.'})

npcHandler:setMessage(MESSAGE_GREET, 'Welcome, please help me with mission, |PLAYERNAME|! Ask me for {mission} and ill give you one!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye, |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Good bye.')

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true)

-- On check npc shop message (look item)
npcType.onCheckItem = function(npc, player, clientId, subType)
end

npcType:register(npcConfig)
Its working, nice! Read dm from me
 
As far as I know, this system is only functional in the Canary version. I haven't seen any NPC system like this in TFS 1.5, so maybe this is the answer you were looking for!
I like how rev works, looking foward for the day that it(npc rev) comes to tfs
 
I like how rev works, looking foward for the day that it(npc rev) comes to tfs

I'm glad you like RevScript! Just to clarify, TFS 1.5 currently uses RevScript for some features, but not for NPCs. I totally understand why you're excited for it to be used for NPCs though, as it can simplify the process of creating them compared to using XML and Lua.
 
Back
Top