• 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] My npc, need a little help.

Knight God

Member
Joined
Oct 19, 2008
Messages
1,180
Reaction score
21
Hello otlanders.
Well let me know if can help with a script of my npc.
My npc is mission to report if I have not the items should say that I need items to complete the mission, but the npc ignores me, if someone can you tell me or help me I'd appreciate it.

Script

HTML:
local story = {}
local function cancelStory(cid)
    if not(story[cid]) then return true end
    for _, eventId in pairs(story[cid]) do
        stopEvent(eventId)
    end
    story[cid] = {}
end

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

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    if msgcontains(msg, "ruddy's message") and getPlayerStorageValue(cid, 11234) == 1 then
            cancelStory(cid)
            setPlayerStorageValue(cid, 11234, 2)
            setPlayerStorageValue(cid, 11235, 1)
            story[cid] = selfStory({"Adventurer was waiting for you, so you have interest in traveling through time eh?, Ruddy has already sent me the translated copy of the plans for the time machine, but unfortunately I need a few items to create the time machine...", "Therefore it is necessary that you bring to me, you will find the following items in various parts of the map and you have to giving them to me all one by one in order...", "Collect the following items: [01 - {Blood Crystal}, from Stone Golems cave, located on the eastern of the city, under the mountains of Wyverns], [02 -  {Energy Spark}, You'll find one on the mountain that is in the northeast of the city, in the abandoned laboratory of dwarfs]...", "[03 - {Raw Crystal (Positive and Negative)}, these both are in the laboratory of the Bonelords, on northern to the outskirts of the city]...", "[04 - {Mighty Helm Of Green Sparks}, Combine one steel helmet with ten small emeralds in the armory]...", "[05 - {Twenty Golem Heads}, collect them killing Overcharged War Golems on the Bonelord Laboratory in the northern of the city]...", "[06 - {One hundred Gear Wheels}, Collect this killing Worker Golems], [07 - {One hundred Energy Soils}, Collect this killing Charged Energy Elemental or Overcharged Energy Elemental]...", "[08 - {One hundred Nails}, Collect this killing War Golem or Worker Golem], [09 - {One Enchanted Staff}, Use the Sorcerer Spell ''Exeta Vis'' on a normal Staff to get enchanted staff temporarily...", "Collect all the items and when you're ready, come and bring them to me, good luck..."}, cid, 10000)
            doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE, "Your questlog has been updated.")
            return false
        end
--------------------------------------------HERE-------------------------------------------------------------
    if msgcontains(msg, "mission") or msgcontains(msg, "report") then
        if(getPlayerStorageValue(cid, 11235) == 13) then
            selfSay('Greetings adventurer, really you\'ve finished the order that I gave you?', cid)
        talkState[talkUser] = 1
              else
                      selfSay('You\'re not ready to advance on the next mission.', cid)
                            end
    elseif(msgcontains(msg, 'yes')) then
          if(talkState[talkUser] == 1) then
                if(getPlayerItemCount(cid,9141) >= 1 and getPlayerItemCount(cid,10069) >= 1 and getPlayerItemCount(cid,9743) >= 1 and getPlayerItemCount(cid,9744) >= 1 and getPlayerItemCount(cid,10316) >= 1 and getPlayerItemCount(cid,10173) >= 20 and getPlayerItemCount(cid,9690) >= 100 and getPlayerItemCount(cid,8303) >= 100 and getPlayerItemCount(cid,8309) >= 100 and getPlayerItemCount(cid,2433) >= 1) then
                    if doPlayerRemoveItem(cid,9141,1) and doPlayerRemoveItem(cid,10069,1) and doPlayerRemoveItem(cid,9743,1) and doPlayerRemoveItem(cid,9744,1) and doPlayerRemoveItem(cid,10316,1) and doPlayerRemoveItem(cid,10173,20) and doPlayerRemoveItem(cid,9690,100) and doPlayerRemoveItem(cid,8303,100) and doPlayerRemoveItem(cid,8309,100) and doPlayerRemoveItem(cid,2433,1) then
          selfSay('The creation of the time machine is already a fact, if you want to travel back in the time, then let\'s talk about your next {mission}.', cid)
            setPlayerStorageValue(cid, 11235, 14)
              doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE, "Your questlog has been updated.")
        else
        selfSay('What are you talking about?, Still you do not have all the items I\'ve ordered. Come back when you have: a blood crystal, an energy spark, the raw crystal positive / negative, a mighty helm of green sparks, twenty golem heads, one hundred gear wheels / energy soils / nails, and a enchanted staff.', cid)
                end
                end
    elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
        selfSay('Alright then. Come back when you have: a blood crystal, an energy spark, the raw crystal positive/negative, a mighty helm of green sparks, twenty golem heads, one hundred gear wheels/energy soils/nails, and a enchanted staff.', cid)
        talkState[talkUser] = 0
    end
    return true
end
--------------------------------------------HERE-------------------------------------------------------------

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
npcHandler:setCallback(CALLBACK_FAREWELL, creatureFarewell)
npcHandler:setCallback(CALLBACK_CREATURE_DISAPPEAR, creatureFarewell)
 
Add an end after doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE, "Your questlog has been updated.").

It should look like this:

Code:
if msgcontains(msg, "mission") or msgcontains(msg, "report") then
    if(getPlayerStorageValue(cid, 11235) == 13) then
        selfSay('Greetings adventurer, really you\'ve finished the order that I gave you?', cid)
        talkState[talkUser] = 1
    else
        selfSay('You\'re not ready to advance on the next mission.', cid)
    end
elseif(msgcontains(msg, 'yes')) then
    if(talkState[talkUser] == 1) then
        if(getPlayerItemCount(cid,9141) >= 1 and getPlayerItemCount(cid,10069) >= 1 and getPlayerItemCount(cid,9743) >= 1 and getPlayerItemCount(cid,9744) >= 1 and getPlayerItemCount(cid,10316) >= 1 and getPlayerItemCount(cid,10173) >= 20 and getPlayerItemCount(cid,9690) >= 100 and getPlayerItemCount(cid,8303) >= 100 and getPlayerItemCount(cid,8309) >= 100 and getPlayerItemCount(cid,2433) >= 1) then
            if doPlayerRemoveItem(cid,9141,1) and doPlayerRemoveItem(cid,10069,1) and doPlayerRemoveItem(cid,9743,1) and doPlayerRemoveItem(cid,9744,1) and doPlayerRemoveItem(cid,10316,1) and doPlayerRemoveItem(cid,10173,20) and doPlayerRemoveItem(cid,9690,100) and doPlayerRemoveItem(cid,8303,100) and doPlayerRemoveItem(cid,8309,100) and doPlayerRemoveItem(cid,2433,1) then
                selfSay('The creation of the time machine is already a fact, if you want to travel back in the time, then let\'s talk about your next {mission}.', cid)
                setPlayerStorageValue(cid, 11235, 14)
                doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE, "Your questlog has been updated.")
            end
        else
            selfSay('What are you talking about?, Still you do not have all the items I\'ve ordered. Come back when you have: a blood crystal, an energy spark, the raw crystal positive / negative, a mighty helm of green sparks, twenty golem heads, one hundred gear wheels / energy soils / nails, and a enchanted staff.', cid)
        end
    end
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
    selfSay('Alright then. Come back when you have: a blood crystal, an energy spark, the raw crystal positive/negative, a mighty helm of green sparks, twenty golem heads, one hundred gear wheels/energy soils/nails, and a enchanted staff.', cid)
    talkState[talkUser] = 0
end
return true
end
 
Back
Top