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

NPC Mission NPC 1.0 (With Configuration)

Acubens

Old Penguin
Joined
May 6, 2008
Messages
1,261
Solutions
13
Reaction score
184
Location
Venezuela
Mission NPC 2.0

Hello Otlanders, this is my first npc to otland, The idea is to give the required item to the npc and then give us a reward.

First Step: go to data/npcs and create new XML file and rename it with "Quest Maker.xml" or another name with you preference and put this into:

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Quest Maker" script="data/npc/scripts/questmaker.lua" walkinterval="5000" floorchange="0">
    <health now="100" max="100"/>
    <look type="266" head="1" body="1" legs="1" feet="1" addons="3"/>
    <parameters>
        <parameter key="message_greet" value="Welcome |PLAYERNAME| Are your ready for this {mission}?" />
     
     
     
    </parameters>
</npc>
Now in data/npc/scripts copy any file and rename it with "questmaker.lua"
and put this in the file:

PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() 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



--------------------------------
------- NPC MISION  2.0 --------
------ by Acubens - Otland.net -
--------------------------------


local first = {
-- Place true if you want to use the system of a gift for experience, false if you want to use items
useExpReward = false,
-- The experience that will get the player at the end of the mission
experience = 5000,
-- Id of the item that will be asking for the NPC to complete the mission
item = 2668,
-- Count of the item required
item_count = 1, 
-- id of the gift that going to obtain the player at finish the mission
reward = 2160,
-- count of the gift item
reward_count = 1,
-- storage
storage = 60307,
-- name of the quest
questname = "Acubens Quest"
}

local npc_message ={

-- Procced - message
"I need some item to complete this mission, procced?",
-- if you dont have items - message
"You dont have any items to this mission.",
-- thanks - message
"Thank You for Help me, {take it}.",
-- already done - message
"You have already done this mision.",
-- ready to go - message
"The Mission {"..first.questname.."} is, really serius, i need your help to complete it, if you help me then i will  give some items to you..",
-- congratulations - message
"Congratulations, you have finished the "..first.questname..""

}


if(msgcontains(msg, 'mission')) then
selfSay(npc_message[5], cid)
end

if(msgcontains(msg, first.questname)) then
    selfSay(npc_message[1], cid)
    talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
    if (getPlayerStorageValue(cid,first.storage) > 0) then
        selfSay(npc_message[4], cid)
    else
        if(doPlayerRemoveItem(cid,first.item,first.item_count)) then
            setPlayerStorageValue(cid,first.storage,1)
            if(useExpReward) then
                doPlayerAddExperience(cid,first.experience)
            else
                doPlayerAddItem(cid,first.reward,first.reward_count)
            end
            selfSay(npc_message[3], cid)
            doSendMagicEffect(getCreaturePosition(cid), 10)
            doCreatureSay(cid, npc_message[6], TALKTYPE_ORANGE_1)
        else
            selfSay(npc_message[2], cid)
        end
    end
return true
end

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


Rep++ me :thumbup:
 
Last edited:
Great npc!
All works, but I'm not good at .lua so what I must do to create a "second misson"?
 
I will update this npc to much features, only wait i havent time now ^.^
 
Will be cool if u the npc give u some exp, and then when u get it, the npc ask u for more items :3
anyway rep++
 
Could you adapt it to 0.2?

I test in the last version of Mystic Spirit and doesn't Work.
Exemple.


God: hi
Aveo: Welcome Gustavo Are your ready for this mission?
God: mission
Aveo: The Mission Acubens Quest is, really serius, i need your help to complete it, if you help me then i will give some items to you..
God: acubens quest
Aveo: I need some item to complete this mission, procced?
Gustavo [1000]: yes
Aveo: You dont have any items to this mission.

No errors in Console. Thanks.
 
It work on 0.2.10 perfectly! ;) No bugs, no errors in console. How to make Acubens Quest in quest logs? :)
 
I have a problem with the NPC for TFS 0.3 (TFS). Error in the console by typing hi, mission

SJM4E.png


Please help me :(
 
how do i add a second quest? I have 3 quests using this system once the first is completed my other 2 act as if they have already been done..?

---

EDITTTT

Sorry guys , i think i figured it out.. Ive been changing the last digit of the storage value for every individual NPC and quest and now they are all working independently.. Is this the proper way to do it? I plan on having 10 or more NPC's using this system. Will i run into problems by doing this later on?

Code:
 local first = {
-- Place true if you want to use the system of a gift for experience, false if you want to use items
useExpReward = true,
-- The experience that will get the player at the end of the mission
experience = 500000,
-- Id of the item that will be asking for the NPC to complete the mission
item = 8707, 
-- Count of the item required
item_count = 1,  
-- id of the gift that going to obtain the player at finish the mission 
reward = 2160,
-- count of the gift item
reward_count = 5, 
-- storage
storage = 60309, , <------- Default was 60307 i been changing the last digit for every new quest. Will this continue to work? 
-- name of the quest
questname = "Darkness prevails"
 
Last edited:
how do i add a second quest? I have 3 quests using this system once the first is completed my other 2 act as if they have already been done..?

---

EDITTTT

Sorry guys , i think i figured it out.. Ive been changing the last digit of the storage value for every individual NPC and quest and now they are all working independently.. Is this the proper way to do it? I plan on having 10 or more NPC's using this system. Will i run into problems by doing this later on?

Code:
 local first = {
-- Place true if you want to use the system of a gift for experience, false if you want to use items
useExpReward = true,
-- The experience that will get the player at the end of the mission
experience = 500000,
-- Id of the item that will be asking for the NPC to complete the mission
item = 8707, 
-- Count of the item required
item_count = 1,  
-- id of the gift that going to obtain the player at finish the mission 
reward = 2160,
-- count of the gift item
reward_count = 5, 
-- storage
storage = 60309, , <------- Default was 60307 i been changing the last digit for every new quest. Will this continue to work? 
-- name of the quest
questname = "Darkness prevails"

Yes you can do new npcs changing the storage value
 
[26/12/2011 14:18:17] Lua Script Error: [Npc interface]
[26/12/2011 14:18:17] data/npc/scripts/helver mission.lua
[26/12/2011 14:18:17] data/npc/scripts/helver mission.lua:3: attempt to index global 'KeywordHandler' (a nil value)
[26/12/2011 14:18:17] stack traceback:
[26/12/2011 14:18:17] [C]: in function '__index'
[26/12/2011 14:18:17] data/npc/scripts/helver mission.lua:3: in main chunk
[26/12/2011 14:18:17] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/helver mission.lua



D;!!?
 
Thanks for sharing this with us, I sure can use this kind of NPC's :D
 
Back
Top