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

Solved NPC script not working!

simse

New Member
Joined
Jan 22, 2009
Messages
29
Reaction score
0
Hi, I'm having trouble trying to get an npc script to work,
when i say for example "mission", he says
"NO? Well, I knew you didn\'t had the guts anyway!" when he should say "So you have come this far, have you? ...', 'Still, the biggest challenge lies before you. ...', 'Are you ready for the hardest fight of your life?"
I'm not assigning any storagevalue cuz it will not be possible to visit this NPC again after done the quest

this is the script

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

if msgcontains(msg, "mission") or msgcontains(msg, "wrath") or msgcontains(msg, "emperor") or msgcontains(msg, "quest") then
npcHandler:say({'So you have come this far, have you? ...', 'Still, the biggest challenge lies before you. ...', 'Are you ready for the hardest fight of your life?'}, cid)
if msgcontains(msg, "yes") then
npcHandler:say({'So be it!'}, cid)
doSummonCreature("Snake God Essence", {x=33066, y=31153, z=15})

else
npcHandler:say({'NO? Well, I knew you didn\'t had the guts anyway!'}, cid)

end
end

return true


end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Well, there is actually no error, it just doesn't work
17:23 Awareness Of The Emperor: Welcome, Owner! I have been expecting you.
17:23 Owner [1337]: mission
17:23 Awareness Of The Emperor: NO? Well, I knew you didn't had the guts anyway!
What the hell is up with that?? xd
 
Last edited:
Well, I do not know what the error is, but try this one to see if it's right.

Code:
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, "mission") or msgcontains(msg, "wrath") or msgcontains(msg, "emperor") or msgcontains(msg, "quest") and (getPlayerStorageValue(cid, 600) == -1)  then
       npcHandler:say("So you have come this far, have you? ...', 'Still, the biggest challenge lies before you. ...', 'Are you ready for the hardest fight of your life?", cid)
       talkState[talkUser] = 1
   elseif(msgcontains(msg, "yes") and talkState[talkUser] == 1) and (getPlayerStorageValue(cid, 600) == -1) then
       npcHandler:say("So be it!", cid)
       setPlayerStorageValue(cid, 600, 1)
       doSummonCreature("Snake God Essence", {x=33066, y=31153, z=15})
     end
   end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Well, I do not know what the error is, but try this one to see if it's right.

Code:
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, "mission") or msgcontains(msg, "wrath") or msgcontains(msg, "emperor") or msgcontains(msg, "quest") and (getPlayerStorageValue(cid, 600) == -1)  then
       npcHandler:say("So you have come this far, have you? ...', 'Still, the biggest challenge lies before you. ...', 'Are you ready for the hardest fight of your life?", cid)
       talkState[talkUser] = 1
   elseif(msgcontains(msg, "yes") and talkState[talkUser] == 1) and (getPlayerStorageValue(cid, 600) == -1) then
       npcHandler:say("So be it!", cid)
       setPlayerStorageValue(cid, 600, 1)
       doSummonCreature("Snake God Essence", {x=33066, y=31153, z=15})
     end
   end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Yes , it works! thanks!

Now i just have the problem that it can't find the monster "Snake God Essence". I have it in Data/monster but it say: failed to load external entity "data/npc/Snake God Essence.xml
<luaDoCreateNpc> Npc with name "Snake God Essence" not found

Why is it looking for npc?
Also is there a way to copy the error directly from server prompt instead of writing here?
Thanks
 
Back
Top