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

Quest npc

Clorens

New Member
Joined
Oct 5, 2011
Messages
89
Reaction score
0
Hi for some reason this script is not working..
I want the npc to first ask the player to bring her a red apple, when he does she should give him 10% of his exp for the next level.
After that he can keep going by saying adventure, and she'll tell him to bring her a her old tibia doll.
When he brings it to her, she should reward him with 75% exp.

Atm she just keep asking for more red apples...
And you can't get to the part when she asks you for her old tibia doll...

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
 
local storage = 89899
local endstorage = 3918323
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
 
    if(msgcontains(msg, 'adventure')) then
		if getPlayerStorageValue(cid, storage) == -1 then
				selfSay('First go get me a red apple, I need to eat some I am starving. Could you do that?', cid)
				setPlayerStorageValue(cid, storage, 5)
				talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 5) then 
                selfSay('You\'ve got my red apple?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 5) then 
                selfSay('Go get my old tibia doll!', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, endstorage) == 1) then 
                selfSay('Thanks alot, this bring back memories. I don\'t need any help anymore.', cid) 
                talkState[talkUser] = 1 
		elseif (getPlayerStorageValue(cid, storage) == 4) and doPlayerRemoveItem(cid, 6579, 1) then 
                selfSay('Oh my god! you did it, I can\'t believe it. Here are you reward!', cid) 
				doPlayerAddPercentLevel(cid, 75)
				setPlayerStorageValue(cid, endstorage, 1)
                talkState[talkUser] = 1 
        end
        --------------------------------------- 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and (getPlayerStorageValue(cid,storage) == 5)) then 
        if doPlayerRemoveItem(cid, 2674, 1) then 
            setPlayerStorageValue(cid,storage,5) 
            doPlayerAddPercentLevel(cid, 1)  
            selfSay('Thank you. Talk to me again to continue the quest.', cid) 
            talkState[talkUser] = 0 
        else 
            selfSay('Go and bring me the red apple.', cid) 
        end 
        --------------------------------------- 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser]) == 1 then
		if(getPlayerStorageValue(cid,storage) == 2) then
            setPlayerStorageValue(cid,storage,3)
            selfSay('Good luck, and follow my map!', cid) 
            talkState[talkUser] = 0 
        else 
            return false
	end
end
        ------------------------------------------ 
	end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Try it now

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
 
local storage = 89899
local endstorage = 3918323
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
 
    if(msgcontains(msg, 'adventure')) then
        if getPlayerStorageValue(cid, storage) == -1 then
                selfSay('First go get me a red apple, I need to eat some I am starving. Could you do that?', cid)
                setPlayerStorageValue(cid, storage, 5)
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 5) then 
                selfSay('You\'ve got my red apple?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 6) then 
                selfSay('Go get my old tibia doll!', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, endstorage) == 1) then 
                selfSay('Thanks alot, this bring back memories. I don\'t need any help anymore.', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 4) and doPlayerRemoveItem(cid, 6579, 1) then 
                selfSay('Oh my god! you did it, I can\'t believe it. Here are you reward!', cid) 
                doPlayerAddPercentLevel(cid, 75)
                setPlayerStorageValue(cid, endstorage, 1)
                talkState[talkUser] = 1 
        end
        --------------------------------------- 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and (getPlayerStorageValue(cid,storage) == 5)) then 
        if doPlayerRemoveItem(cid, 2674, 1) then 
            setPlayerStorageValue(cid,storage,6) 
            doPlayerAddPercentLevel(cid, 1)  
            selfSay('Thank you. Talk to me again to continue the quest.', cid) 
            talkState[talkUser] = 0 
        else 
            selfSay('Go and bring me the red apple.', cid) 
        end 
        --------------------------------------- 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser]) == 1 then
        if(getPlayerStorageValue(cid,storage) == 2) then
            setPlayerStorageValue(cid,storage,3)
            selfSay('Good luck, and follow my map!', cid) 
            talkState[talkUser] = 0 
        else 
            return false
    end
end
        ------------------------------------------ 
    end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
It must be full working now.

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
 
local storage = 89899
local endstorage = 3918323
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
 
    if(msgcontains(msg, 'adventure')) then
        if getPlayerStorageValue(cid, storage) == -1 then
                selfSay('First go get me a red apple, I need to eat some I am starving. Could you do that?', cid)
                setPlayerStorageValue(cid, storage, 5)
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 5) then 
                selfSay('You\'ve got my red apple?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 6) then 
                selfSay('Go get my old tibia doll!', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, endstorage) == 1) then 
                selfSay('Thanks alot, this bring back memories. I don\'t need any help anymore.', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 6) and doPlayerRemoveItem(cid, 6579, 1) then 
                selfSay('Oh my god! you did it, I can\'t believe it. Here are you reward!', cid) 
                doPlayerAddPercentLevel(cid, 75)
                setPlayerStorageValue(cid, endstorage, 1)
                talkState[talkUser] = 1 
        end
        --------------------------------------- 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and (getPlayerStorageValue(cid,storage) == 5)) then 
        if doPlayerRemoveItem(cid, 2674, 1) then 
            setPlayerStorageValue(cid,storage,6) 
            doPlayerAddPercentLevel(cid, 1)  
            selfSay('Thank you. Talk to me again to continue the quest.', cid) 
            talkState[talkUser] = 0 
        else 
            selfSay('Go and bring me the red apple.', cid) 
        end 
        --------------------------------------- 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser]) == 1 then
        if(getPlayerStorageValue(cid,storage) == 2) then
            setPlayerStorageValue(cid,storage,3)
            selfSay('Good luck, and follow my map!', cid) 
            talkState[talkUser] = 0 
        else 
            return false
    end
end
        ------------------------------------------ 
    end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Lol once again she told me (go get my old tibia doll", then I tried saying yes, adventure old tillba dool and so on no reactions again >.>
 
ofc it wont work, you are doing it wrong... the npc wont work as you want :) you need to do the file again and use the storages and the talkstates as well bro
 
I made a remake of your npc. This one should be working. Just change the firstM and so on to the values you like! and the msgs to!
Tell me if there is any errors!

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
 
local storage = 89899
local endstorage = 3918323
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
-- Storage Value numbers.
local firstM = 1 
local secondM = 2    
local thirdM = 3
local fourthM = 4
 
    if(msgcontains(msg, 'adventure')) then
        if getPlayerStorageValue(cid, storage) == -1 then
                selfSay('First go get me a red apple, I need to eat some I am starving. Could you do that?', cid)
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == firstM) then 
                selfSay('You\'ve got my red apple?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == secondM) then 
                selfSay('Could you please go and get my tibia doll?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, endstorage) == thirdM) then 
                selfSay('Did you bring the doll?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == fourthM) then 
                selfSay('I don\'t need your help anymore!', cid) 
                talkState[talkUser] = 0 
        end
-- Yes Msgs.		
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
		if (getPlayerStorageValue(cid,storage) == -1) then 
		    selfSay('Go and get it please!', cid)
		    setPlayerStorageValue(cid, storage, firstM)
  		    talkState[talkUser] = 0 			
        elseif (getPlayerStorageValue(cid,storage) == firstM) then				
            if doPlayerRemoveItem(cid, 2674, 1) then 
    		    setPlayerStorageValue(cid,storage,secondM) 
    		    doPlayerAddPercentLevel(cid, 1)  
     		    selfSay('Thank you. Talk to me again to continue the quest.', cid) 
    		    talkState[talkUser] = 0 
            else 
    		    selfSay('Go and bring me the red apple.', cid)
  		        talkState[talkUser] = 0 				
            end 
		elseif (getPlayerStorageValue(cid,storage) == secondM) then
		    selfSay('Go and get it please!', cid)
		    setPlayerStorageValue(cid, storage, thirdM)
			talkState[talkUser] = 0 
		elseif (getPlayerStorageValue(cid,storage) == thirdM) then
			if doPlayerRemoveItem(cid, 6579, 1) then
			    selfSay('Thank you! here take your reward!', cid)
			    setPlayerStorageValue(cid, storage, fourthM)
			    doPlayerAddPercentLevel(cid, 75)
			    setPlayerStorageValue(cid, endstorage, 1)
				 talkState[talkUser] = 0 
			else
			    selfSay('Please bring the doll!!', cid)
  		        talkState[talkUser] = 0 				
            end
        end
-- no msgs	
    elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1 then
		if (getPlayerStorageValue(cid,storage) == -1) then 
		    selfSay('Thats to bad!!', cid)
  		    talkState[talkUser] = 0 			
        elseif (getPlayerStorageValue(cid,storage) == firstM) then				
     		selfSay('Go and get it then?', cid) 
    		 talkState[talkUser] = 0 
		elseif (getPlayerStorageValue(cid,storage) == secondM) then
		    selfSay('Then don\'t!', cid)
			talkState[talkUser] = 0 
		elseif (getPlayerStorageValue(cid,storage) == thirdM) then
			selfSay('Please go and get my doll!!!', cid)
    		alkState[talkUser] = 0 
        end
    end	
    return true	
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

Regards Anteyz
 
I made a remake of your npc. This one should be working. Just change the firstM and so on to the values you like! and the msgs to!
Tell me if there is any errors!

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
 
local storage = 89899
local endstorage = 3918323
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
-- Storage Value numbers.
local firstM = 1 
local secondM = 2    
local thirdM = 3
local fourthM = 4
 
    if(msgcontains(msg, 'adventure')) then
        if getPlayerStorageValue(cid, storage) == -1 then
                selfSay('First go get me a red apple, I need to eat some I am starving. Could you do that?', cid)
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == firstM) then 
                selfSay('You\'ve got my red apple?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == secondM) then 
                selfSay('Could you please go and get my tibia doll?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, endstorage) == thirdM) then 
                selfSay('Did you bring the doll?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == fourthM) then 
                selfSay('I don\'t need your help anymore!', cid) 
                talkState[talkUser] = 0 
        end
-- Yes Msgs.        
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if (getPlayerStorageValue(cid,storage) == -1) then 
            selfSay('Go and get it please!', cid)
            setPlayerStorageValue(cid, storage, firstM)
              talkState[talkUser] = 0             
        elseif (getPlayerStorageValue(cid,storage) == firstM) then                
            if doPlayerRemoveItem(cid, 2674, 1) then 
                setPlayerStorageValue(cid,storage,secondM) 
                doPlayerAddPercentLevel(cid, 1)  
                 selfSay('Thank you. Talk to me again to continue the quest.', cid) 
                talkState[talkUser] = 0 
            else 
                selfSay('Go and bring me the red apple.', cid)
                  talkState[talkUser] = 0                 
            end 
        elseif (getPlayerStorageValue(cid,storage) == secondM) then
            selfSay('Go and get it please!', cid)
            setPlayerStorageValue(cid, storage, thirdM)
            talkState[talkUser] = 0 
        elseif (getPlayerStorageValue(cid,storage) == thirdM) then
            if doPlayerRemoveItem(cid, 6579, 1) then
                selfSay('Thank you! here take your reward!', cid)
                setPlayerStorageValue(cid, storage, fourthM)
                doPlayerAddPercentLevel(cid, 75)
                setPlayerStorageValue(cid, endstorage, 1)
                 talkState[talkUser] = 0 
            else
                selfSay('Please bring the doll!!', cid)
                  talkState[talkUser] = 0                 
            end
        end
-- no msgs    
    elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1 then
        if (getPlayerStorageValue(cid,storage) == -1) then 
            selfSay('Thats to bad!!', cid)
              talkState[talkUser] = 0             
        elseif (getPlayerStorageValue(cid,storage) == firstM) then                
             selfSay('Go and get it then?', cid) 
             talkState[talkUser] = 0 
        elseif (getPlayerStorageValue(cid,storage) == secondM) then
            selfSay('Then don\'t!', cid)
            talkState[talkUser] = 0 
        elseif (getPlayerStorageValue(cid,storage) == thirdM) then
            selfSay('Please go and get my doll!!!', cid)
            alkState[talkUser] = 0 
        end
    end    
    return true    
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

Regards Anteyz


thats what i say, a total remake of the npc should work :)
 
I made a remake of your npc. This one should be working. Just change the firstM and so on to the values you like! and the msgs to!
Tell me if there is any errors!

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
 
local storage = 89899
local endstorage = 3918323
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
-- Storage Value numbers.
local firstM = 1 
local secondM = 2    
local thirdM = 3
local fourthM = 4
 
    if(msgcontains(msg, 'adventure')) then
        if getPlayerStorageValue(cid, storage) == -1 then
                selfSay('First go get me a red apple, I need to eat some I am starving. Could you do that?', cid)
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == firstM) then 
                selfSay('You\'ve got my red apple?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == secondM) then 
                selfSay('Could you please go and get my tibia doll?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, endstorage) == thirdM) then 
                selfSay('Did you bring the doll?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == fourthM) then 
                selfSay('I don\'t need your help anymore!', cid) 
                talkState[talkUser] = 0 
        end
-- Yes Msgs.		
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
		if (getPlayerStorageValue(cid,storage) == -1) then 
		    selfSay('Go and get it please!', cid)
		    setPlayerStorageValue(cid, storage, firstM)
  		    talkState[talkUser] = 0 			
        elseif (getPlayerStorageValue(cid,storage) == firstM) then				
            if doPlayerRemoveItem(cid, 2674, 1) then 
    		    setPlayerStorageValue(cid,storage,secondM) 
    		    doPlayerAddPercentLevel(cid, 1)  
     		    selfSay('Thank you. Talk to me again to continue the quest.', cid) 
    		    talkState[talkUser] = 0 
            else 
    		    selfSay('Go and bring me the red apple.', cid)
  		        talkState[talkUser] = 0 				
            end 
		elseif (getPlayerStorageValue(cid,storage) == secondM) then
		    selfSay('Go and get it please!', cid)
		    setPlayerStorageValue(cid, storage, thirdM)
			talkState[talkUser] = 0 
		elseif (getPlayerStorageValue(cid,storage) == thirdM) then
			if doPlayerRemoveItem(cid, 6579, 1) then
			    selfSay('Thank you! here take your reward!', cid)
			    setPlayerStorageValue(cid, storage, fourthM)
			    doPlayerAddPercentLevel(cid, 75)
			    setPlayerStorageValue(cid, endstorage, 1)
				 talkState[talkUser] = 0 
			else
			    selfSay('Please bring the doll!!', cid)
  		        talkState[talkUser] = 0 				
            end
        end
-- no msgs	
    elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1 then
		if (getPlayerStorageValue(cid,storage) == -1) then 
		    selfSay('Thats to bad!!', cid)
  		    talkState[talkUser] = 0 			
        elseif (getPlayerStorageValue(cid,storage) == firstM) then				
     		selfSay('Go and get it then?', cid) 
    		 talkState[talkUser] = 0 
		elseif (getPlayerStorageValue(cid,storage) == secondM) then
		    selfSay('Then don\'t!', cid)
			talkState[talkUser] = 0 
		elseif (getPlayerStorageValue(cid,storage) == thirdM) then
			selfSay('Please go and get my doll!!!', cid)
    		alkState[talkUser] = 0 
        end
    end	
    return true	
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

Regards Anteyz


Used excatly the same script as you provided me with but I got this o_O
Tried your script with out even changing it too..

Code:
[08/04/2013 20:20:03] [Error - LuaScriptInterface::loadFile] data/npc/scripts/Veronica.lua:42: ')' expected near 'then'
[08/04/2013 20:20:03] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Veronica.lua
[08/04/2013 20:20:03] data/npc/scripts/Veronica.lua:42: ')' expected near 'then'
 
Used excatly the same script as you provided me with but I got this o_O
Tried your script with out even changing it too..

Code:
[08/04/2013 20:20:03] [Error - LuaScriptInterface::loadFile] data/npc/scripts/Veronica.lua:42: ')' expected near 'then'
[08/04/2013 20:20:03] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Veronica.lua
[08/04/2013 20:20:03] data/npc/scripts/Veronica.lua:42: ')' expected near 'then'


try to read the error?
go to line 42 and add a ")" :eek: ITS MAGIC!
the same error line 74 also

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
 
local storage = 89899
local endstorage = 3918323
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
-- Storage Value numbers.
local firstM = 1 
local secondM = 2    
local thirdM = 3
local fourthM = 4
 
    if(msgcontains(msg, 'adventure')) then
        if getPlayerStorageValue(cid, storage) == -1 then
                selfSay('First go get me a red apple, I need to eat some I am starving. Could you do that?', cid)
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == firstM) then 
                selfSay('You\'ve got my red apple?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == secondM) then 
                selfSay('Could you please go and get my tibia doll?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, endstorage) == thirdM) then 
                selfSay('Did you bring the doll?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == fourthM) then 
                selfSay('I don\'t need your help anymore!', cid) 
                talkState[talkUser] = 0 
        end
-- Yes Msgs.		
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if (getPlayerStorageValue(cid,storage) == -1) then 
		    selfSay('Go and get it please!', cid)
		    setPlayerStorageValue(cid, storage, firstM)
  		    talkState[talkUser] = 0 			
        elseif (getPlayerStorageValue(cid,storage) == firstM) then				
            if doPlayerRemoveItem(cid, 2674, 1) then 
    		    setPlayerStorageValue(cid,storage,secondM) 
    		    doPlayerAddPercentLevel(cid, 1)  
     		    selfSay('Thank you. Talk to me again to continue the quest.', cid) 
    		    talkState[talkUser] = 0 
            else 
    		    selfSay('Go and bring me the red apple.', cid)
  		        talkState[talkUser] = 0 				
            end 
		elseif (getPlayerStorageValue(cid,storage) == secondM) then
		    selfSay('Go and get it please!', cid)
		    setPlayerStorageValue(cid, storage, thirdM)
			talkState[talkUser] = 0 
		elseif (getPlayerStorageValue(cid,storage) == thirdM) then
			if doPlayerRemoveItem(cid, 6579, 1) then
			    selfSay('Thank you! here take your reward!', cid)
			    setPlayerStorageValue(cid, storage, fourthM)
			    doPlayerAddPercentLevel(cid, 75)
			    setPlayerStorageValue(cid, endstorage, 1)
				 talkState[talkUser] = 0 
			else
			    selfSay('Please bring the doll!!', cid)
  		        talkState[talkUser] = 0 				
            end
        end
-- no msgs	
    elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1 )then
		if (getPlayerStorageValue(cid,storage) == -1) then 
		    selfSay('Thats to bad!!', cid)
  		    talkState[talkUser] = 0 			
        elseif (getPlayerStorageValue(cid,storage) == firstM) then				
     		selfSay('Go and get it then?', cid) 
    		 talkState[talkUser] = 0 
		elseif (getPlayerStorageValue(cid,storage) == secondM) then
		    selfSay('Then don\'t!', cid)
			talkState[talkUser] = 0 
		elseif (getPlayerStorageValue(cid,storage) == thirdM) then
			selfSay('Please go and get my doll!!!', cid)
    		alkState[talkUser] = 0 
        end
    end	
    return true	
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
I did read it and went to that line but I couldn't find anything which was obviously wrong I'm not good at lua scripting at all..
 
Used excatly the same script as you provided me with but I got this o_O
Tried your script with out even changing it too..

Code:
[08/04/2013 20:20:03] [Error - LuaScriptInterface::loadFile] data/npc/scripts/Veronica.lua:42: ')' expected near 'then'
[08/04/2013 20:20:03] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Veronica.lua
[08/04/2013 20:20:03] data/npc/scripts/Veronica.lua:42: ')' expected near 'then'


Update---
Didn't see that you already fixed it anyways hope it works!
Regards Anteyz
 
Back
Top