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

Lua NPC Mission script problem!

Zorenia

Hoster of Zorenia
Joined
Jan 21, 2009
Messages
579
Reaction score
56
Location
The Netherlands
Hello guys!
I working on this script for few weeks of trying. I already asked some help on this but I try to fix it by myself to learn something.. but I can't find out this problem!

The script is working.. but there is only 1 problem.
When I start a mission, he tell me he need to have fishing baits... blalb.. then I can say yes to resive the task.
But if I say bye before fully resive the task. and I say HI again.. I already got another storage number and I can not go furder.. because I didn't resive the task and I already got another storage number so I could not resive the fully task.

Could someone take a look on it!! so it still work.. but when I break contact with npc.. the npc knows where I'm so he can still give me the quest.
well I hope you guys know what I mean!
I really hope someone could help me out fast as possible so I could work on! I want to launch the rook beta this weekend XD hehe

My script:
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
 
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. I am the local Fisherman. Are you looking for some work? ask me for a {mission} or do you want to {report} to me?") 
 
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')) then 
        if(getPlayerStorageValue(cid,300) < 1) then 
            selfSay('You look like a strapping young adventurer, yes? Could you help an Elderly man out with a quick {favor?}', cid) 
            talkState[talkUser] = 1 
			setPlayerStorageValue(cid,300,1)
		elseif (getPlayerStorageValue(cid,302) == 1) then 
                selfSay('Good job, now that i`ve got the bait, we`ll need one more thing before we can get to the waters were Ol` Salty is! In the back of my fishing shack is my trusty fishing rod. I need you to grab the for me, this old man cant walk as quick as he used to be able to! Can you grab it for me quick? ', cid) 
                talkState[talkUser] = 1 
				setPlayerStorageValue(cid,302,2)
		elseif (getPlayerStorageValue(cid,303) == 1) then 
                selfSay('You did your last job great! Now we can go after Ol` Salty!. Are you {ready}?', cid) 
				setPlayerStorageValue(cid,303,2)
                talkState[talkUser] = 1 
						elseif (getPlayerStorageValue(cid,303) == 0) then 
                selfSay('Your next mission will be to get 400 {green dragon scales}.', cid) 
                talkState[talkUser] = 1 
                               
                 
                 
        elseif (getPlayerStorageValue(cid,303) == 6) then --zmieniac w zaleznosci od ostatniego storage!! 
                selfSay('You have done all missions.', cid) 
                talkState[talkUser] = 1 
			end 
        --------------------------------------- 

		
		elseif(msgcontains(msg, 'report') 	and (getPlayerStorageValue(cid,301) == 1)) then 
		selfSay('Great! did you found my fishing baits?', cid)
		elseif(msgcontains(msg, 'yes') 	and (getPlayerStorageValue(cid,301) == 1)) then 
		if(doPlayerRemoveItem(cid, 11389, 5) == TRUE) then
			doPlayerAddExperience(cid,150)
			selfSay('Thank you! (you received 150 points of experience) If you still looking for work ask me for a {mission}', cid)
			setPlayerStorageValue(cid,300,5)		
			setPlayerStorageValue(cid,301,2)
			setPlayerStorageValue(cid,302,1)
        else 
            selfSay('You need more fishing bait.', cid) 
        end 
		---------------------------------------
	    elseif(msgcontains(msg, 'favor') and talkState[talkUser] == 1 and (getPlayerStorageValue(cid,300) == 1)) then 
            selfSay('Good! See, I`ve been chasing a fish, a big one! It`s eluded me for some time now...Nearly had him once i did! Anyways, i need you to gather up eight pieces of bait for me. I heard the trolls to the south have been stealing bait from the local stores. Can you get me some?', cid) 		
		setPlayerStorageValue(cid,300,2)
		elseif(msgcontains(msg, 'yes') and (getPlayerStorageValue(cid,300) == 2)) then 
            selfSay('Okaj, good luck. Kill the trolls to get the pieces back! {Report} when you gather the pieces.', cid) 	
		setPlayerStorageValue(cid,300,1)	
		setPlayerStorageValue(cid,301,1)
		setPlayerStorageValue(cid,302,1)
        --------------------------------------- 
 		elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1  and (getPlayerStorageValue(cid,301) == 2) and (getPlayerStorageValue(cid,302) == 2)) then 
			selfSay(' Excellent! You`ll find my fishing shack if you follow the shore to the east about twenty paces. Be careful though, last time I was in there, a bear had snuck into the shack for the fish!. {report} if you got my rod! ', cid)
			setPlayerStorageValue(cid,302,3)
		elseif(msgcontains(msg, 'report') and (getPlayerStorageValue(cid,302) == 3)) then 
			selfSay('Did ya find the rod?', cid)
		elseif(msgcontains(msg, 'yes') and (getPlayerStorageValue(cid,302) == 3)) then 
		if(doPlayerRemoveItem(cid, 10223, 1) == TRUE) then
			doPlayerAddExperience(cid,180)
			selfSay('I heard the rustling from here! Looks like you gave that old bear a run for it`s money! Good Job! Now we can go after Ol` Salty!', cid)
			selfSay('Thank you! (you received 180 points of experience) If you still looking for work ask me for a {mission}', cid)
			setPlayerStorageValue(cid,302,4)
			setPlayerStorageValue(cid,303,1)
			 else 
            selfSay('You don`t have my fishing rod.', cid) 
        end 
		---------------------------------------		
        elseif(msgcontains(msg, 'ready') and talkState[talkUser] == 1  and (getPlayerStorageValue(cid,302) == 4) and (getPlayerStorageValue(cid,303) == 2)) then 
        	selfSay('Great! Now, we`re going to go out to sea, I`ll need you to dive into the water and kill Ol` Salty for me, and bring me his heart. I`m far too old to do any diving! Are you ready to go out to sea? I can bring you there, you will get it for me?', cid)
			setPlayerStorageValue(cid,303,3) 
		elseif(msgcontains(msg, 'yes') and (getPlayerStorageValue(cid,303) == 3)) then 
		local boss = {x=1092,y=1508,z=7}
		    doTeleportThing(cid, boss)
		  	selfSay('Great! good luck!', cid)
			setPlayerStorageValue(cid,303,4) 
		 elseif(msgcontains(msg, 'report') and (getPlayerStorageValue(cid,303) == 4)) then 
        	selfSay('So, have you finally done it? Were you able to avenge me and kill Ol` salty?', cid)
			setPlayerStorageValue(cid,303,5) 
		 elseif(msgcontains(msg, 'yes') and (getPlayerStorageValue(cid,303) == 5)) then 
		 		if(doPlayerRemoveItem(cid, 10553, 1) == TRUE) then
			doPlayerAddExperience(cid,250)
			selfSay('Thank you! My entire life`s work, finally complete thanks to you. Here, take this as a token of my appreciation. An old man like me won`t be needing it for much anymore! ', cid)
			setPlayerStorageValue(cid,303,6)
        	end		
			
         
    end 
end     
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Here
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
 
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 storage = 300
function creatureSayCallback(cid, type, msg)
g = getPlayerStorageValue(cid,storage)
s = setPlayerStorageValue  
if msgcontains(msg, 'mission') then
   if isInArray({1,3,5},g) then
      npcHandler:say('You are currently doing a mission!', cid)
   end
   if g < 1 then 
      npcHandler:say('You look like a strapping young adventurer, yes? Could you help an Elderly man out with a quick {favor}?', cid) 
      Topic[cid] = 1
   end
   if g == 2 then
      npcHandler:say('Good job, now that i`ve got the bait, we`ll need one more thing before we can get to the waters were Ol` Salty is! In the back of my fishing shack is my trusty fishing rod. I need you to grab the for me, this old man cant walk as quick as he used to be able to! Can you grab it for me quick? ', cid)
      Topic[cid] = 4
   end
   if g == 4 then
      npcHandler:say('You did your last job great! Now we can go after Ol` Salty!. Are you {ready}?', cid)
      Topic[cid] = 6
   end
   if g > 5 then
      npcHandler:say('You have done all missions.', cid) 
      Topic[cid] = 0
   end
end 

if msgcontains(msg, 'report') then
   if isInArray({2,4},g) then
      npcHandler:say('There are no missions to report at the moment', cid)
   end
   if g == 1 then
      npcHandler:say('Great! did you found my fishing baits?', cid)
      Topic[cid] = 3
   end
   if g == 3 then
      npcHandler:say('Did ya find the rod?', cid)
      Topic[cid] = 5
   end
   if g == 5 then
      npcHandler:say('So, have you finally done it? Were you able to avenge me and kill Ol` salty?', cid)
      Topic[cid] = 8
   end
end
   
   
   

if Topic[cid] == 1 then
   if msgcontains(msg, 'favor') then
      npcHandler:say('Good! See, I`ve been chasing a fish, a big one! It`s eluded me for some time now...Nearly had him once i did! Anyways, i need you to gather up eight pieces of bait for me. I heard the trolls to the south have been stealing bait from the local stores. Can you get me some?', cid) 		
      Topic[cid] = 2
   end
end

if Topic[cid] == 2 then
   if msgcontains(msg, 'yes') then
      npcHandler:say('Okaj, good luck. Kill the trolls to get the pieces back! {report} when you gather the pieces.', cid)
      s(cid,storage,1)
   else
       if msgcontains(msg, 'no') then
          npcHandler:say('Too bad! Next time maybe', cid)
       end
    end
end

if Topic[cid] == 3 then
   if msgcontains(msg, 'yes') then
      if doPlayerRemoveItem(cid, 11389, 5) then
         npcHandler:say('Thank you! (you received 150 points of experience) If you still looking for work ask me for a {mission}', cid)
         doPlayerAddExp(cid, 150)
         s(cid,storage,2)
      else
          npcHandler:say('You need more fishing baits', cid)
      end
   else
       if msgcontains(msg, 'no') then
          npcHandler:say('Go find them then!', cid)
       end
   end
end

if Topic[cid] == 4 then
   if msgcontains(msg, 'yes') then
      npcHandler:say('Excellent! You`ll find my fishing shack if you follow the shore to the east about twenty paces. Be careful though, last time I was in there, a bear had snuck into the shack for the fish!. {report} if you got my rod!',cid)
      s(cid,storage,3)
      Topic[cid] = 0
   else
       if msgcontains(msg, 'no') then
          npcHandler:say('Too bad', cid)
          Topic[cid] = 0
       end
   end
end

if Topic[cid] == 5 then
   if msgcontains(msg, 'yes') then
      if doPlayerRemoveItem(cid, 10233, 1) then
         npcHandler:say('I heard the rustling from here! Looks like you gave that old bear a run for it`s money! Good Job! Now we can go after Ol` Salty!', cid)
         npcHandler:say('Thank you! (you received 180 points of experience) If you still looking for work ask me for a {mission}', cid)
         doPlayerAddExp(cid, 180)
         s(cid,storage,4)
      else
          npcHandler:say('You havent bring me my fishing rod!', cid)
      end
   else
       if msgcontains(msg, 'no') then
          npcHandler:say('Go find it then!', cid)
       end
   end
end

if Topic[cid] == 6 then
   if msgcontains(msg, 'ready') then
      npcHandler:say('Great! Now, we`re going to go out to sea, I`ll need you to dive into the water and kill Ol` Salty for me, and bring me his heart. I`m far too old to do any diving! Are you ready to go out to sea? I can bring you there, you will get it for me?',cid)
      Topic[cid] = 7
   else
       if msgcontains(msg, 'no') then
          npcHandler:say('Too bad', cid)
          Topic[cid] = 0
       end
   end
end

if Topic[cid] == 7 then
   if msgcontains(msg, 'yes') then
      npcHandler:say('Great! good luck!',cid)
      doTeleportThing(cid, {x=1092,y=1508,z=7})
      s(cid,storage,5)
      Topic[cid] = 0
   else
       if msgcontains(msg, 'no') then
          npcHandler:say('Too bad', cid)
          Topic[cid] = 0
       end
   end
end

if Topic[cid] == 8 then
   if msgcontains(msg, 'yes') then
      if doPlayerRemoveItem(cid, 10553, 1) then
         npcHandler:say('Thank you! My entire life`s work, finally complete thanks to you. Here, take this as a token of my appreciation. An old man like me won`t be needing it for much anymore! ', cid)
         doPlayerAddExp(cid, 250)
         s(cid,storage,6)
      else
          npcHandler:say('Bring me his heart!', cid)
      end
   else
       if msgcontains(msg, 'no') then
          npcHandler:say('Go kill him then!', cid)
       end
   end
end
return true
end
   
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Put the greeting and farewell message at the XML
 
Back
Top