• 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 Simple multi-item quest npc wont respond

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
Here is my script

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 first = {
-- Place true if you want to use the system of experience as a reward, false if you want to use items as a reward
useExpReward = true,
-- The experience that will get the player at the end of the mission
experience = 1000,
-- Id of the item that will be asking for the NPC to complete the mission
item = 2159, 
-- Count of the item required
item_count = 1,  
-- id of the gift that going to obtain the player at finish the mission 
reward = 7620,
-- count of the gift item
reward_count = 1,
-- storage
storage = 1060, 
-- name of the quest
questname = "Scarab Collection"
}
 
local npc_message ={
 
-- health potion
"Do you really want to trade 1 scarab coin for a health potion?",
-- message if you lie (dont have it)
"You don't have enough scarab coins for that potion.", 
-- message for reward
"Yay more coins to add to my collection, how many now.... 528 I think.",
-- message already done
"an error occured",
-- message from first keyword
"Yeah I collect those little things, if you have some I'll trade any type of potion you want for one, just say the name of the potion like {strong mana potion} or {great spirit potion} or even {ultimate health potion}, but those are only examples, I am willing to trade basic, strong, great, and the ultimate potions.",
-- message popup quest name
"Congratulations, you have finished the quest: Scarab Collection.",
-- message 7 mana potion 2
"Do you really want to trade 1 scarab coin for a mana potion?.",
-- message 8 strong health potion 3
"Do you really want to trade 3 scarab coins for a strong health potion?.",
-- message 9 strong mana potion 4
"Do you really want to trade 3 scarab coins for a strong mana potion?.",
-- message 10 great health potion 5
"Do you really want to trade 5 scarab coins for a great health potion?.",
--message 11 great mana potion 6
"Do you really want to trade 5 scarab coins for a great mana potion?.",
--message 12 great spirit potion 7
"Do you really want to trade 5 scarab coins for a great spirit potion?.",
-- message 13 ultimate health potion 8
"Do you really want to trade 10 scarab coins for an ultimate health potion?."
}
 
 
if(msgcontains(msg, 'scarab coins')) then --keyword from npc
selfSay(npc_message[5], cid)
end
 
if(msgcontains(msg, 'health potion')) then --potion name

	selfSay(npc_message[1], cid) --number of message for that potion
		talkState[talkUser] = 1 --put 1-8
		
			elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then --USELESS
				if (getPlayerStorageValue(cid,1060) == 3) then --USELESS
					selfSay(npc_message[4], cid) --USELESS
	else
	
		if(doPlayerRemoveItem(cid,2159,1)) then --scarab coin
		if getPlayerStorageValue(cid, 1060) == 1 then
			doCreatureSay(cid, npc_message[6], TALKTYPE_ORANGE_1)		
			setPlayerStorageValue(cid,1060,2) --middle storage value
			if(useExpReward) then
				doPlayerAddExp(cid,1000)       --rewards
				doPlayerAddItem(cid,7618,1)     --rewards
			else
				doPlayerAddItem(cid,7618,1)     --rewards
				doPlayerAddExp(cid, 1000)      --rewards DONE
			end
			selfSay(npc_message[3], cid)
			doSendMagicEffect(getCreaturePosition(cid), 10)
		else
			selfSay(npc_message[2], cid)
		end
	end
	end
return true
end
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, 'mana health')) then --potion name

	selfSay(npc_message[7], cid) --number of message for that potion
		talkState[talkUser] = 2 --put 1-8
		
			elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then --USELESS
				if (getPlayerStorageValue(cid,1060) == 3) then --USELESS
					selfSay(npc_message[4], cid) --USELESS
	else
	
		if(doPlayerRemoveItem(cid,2159,1)) then --scarab coin
		if getPlayerStorageValue(cid, 1060) == 1 then
			doCreatureSay(cid, npc_message[6], TALKTYPE_ORANGE_1)		
			setPlayerStorageValue(cid,1060,2) --middle storage value
			if(useExpReward) then
				doPlayerAddExp(cid,1000)       --rewards
				doPlayerAddItem(cid,7620,1)     --rewards
			else
				doPlayerAddItem(cid,7620,1)     --rewards
				doPlayerAddExp(cid, 1000)      --rewards DONE
			end
			selfSay(npc_message[3], cid)
			doSendMagicEffect(getCreaturePosition(cid), 10)
		else
			selfSay(npc_message[2], cid)
		end
	end
	end
return true
	end
end
	
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


----------------------------------------------------

npcHandler:addModule(FocusModule:new())

I don't get why he wont even respond to "scarab coins" and tell you that he trades potions.

Also, how do I shorten him up so I can make him trade scarab coins for all 8 of the potions (2 basic, 2 strong, 3 great, 1 ultimate) without making like an 1000 line script?

by the way, I only put "Useless" in that one part because the quest will be repeatable and you will never obtain value 3 in storage value 1060, I just left it in there so nothing would go wrong with the code.
 
Back
Top Bottom