• 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 Mission NPC not working

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
Heres the npc

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
-- OTServ event handling functions start
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 onPlayerEndTrade(cid)				npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid)			npcHandler:onPlayerCloseChannel(cid) end
-- OTServ event handling functions 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
 
 
	--------------------------------
	------- NPC MISION  2.5 --------
	---by Acubens, great scripter---
	-----modified by Ziggy46802-----
		   -- Otland.net --
	--------------------------------
 
	local first = {
	-- Place true if you want experience to be part of the quest reward, false if only an item. Place true if you want both
	useExpReward = true,
	-- The experience, if above is set to true, that the player will receive as a reward for the quest
	experience = 40000,
	-- Item ID of the "quest item", or the item that the npc takes from you for you to complete the quest
	item = 4848,
	-- Item ID of the second quest item, just leave alone if you only want one item
	itemtwo = 10610,
	-- The quanity, or how many, of the item needed to complete the quest
	item_count = 1,
	-- The quantity, or how many, of the second quest item needed to complete the quest
	itemtwo_count = 10,  
	-- Item ID of the quest reward if the first option is set to false, but an item can be used with true for exp as reward as well 
	reward = 2407,
	-- Item ID of the quest reward if the first option is set to false, this is the second item that can be "not used"
	rewardtwo = 3962,
	rewardthree = 7387,
	rewardthree_count = 1,
	-- The quantity, or how many, of the quest reward that the player will receive for the second item upon completion of the quest, can be "not used"
	rewardtwo_count = 1,
	-- The quanity, or how many, of the quest reward that the player will receive upon completion of the quest
	reward_count = 1, 
	-- The storage value that the quest will use (advised would be between 1000 and 10000)
	storage = 1020, 
	--this is the value of the storage value above that is set when the quest is completed, most people use -1 (non existant) for starting the quest and 1 for ending, but I use 2
	last = 2,
	-- The name of the quest which will pop up upon completion of the quest as "You have completed the quest 'quest name'"
	questname = "Sludge Factory"
	}
 
	local npc_message ={
 
	--the number at the front just shows you what number message it is so when you see "npc_message[4]" in the script you know which line of code it refers to
 
	-- 1Message asking if you have the required items, should be something like "Do you have the 10 antennas?" no highlighting is needed
	"Did you get your hands on some sludge for me? Tell you what, if you did, just tell me if you want a {sword}, an {axe}, or a {club} as a reward.",
	-- 2if you dont have items - message
	"That's not sludge man!", 
	-- 3thanks - message
	"You have no idea what I'm gonna do with this sludge.",
	-- 4Message that the npc says if you have already done the quest
	"You already gave me a ton of sludge.",
	-- 5First message for the quest, should be like "Please go collect 10 chicken feathers for me" and do {} around a word like I did, antennas
	"Actually, maybe some {sludge} would do me better. Got any? Remember to confirm with me that you have it before I give you your reward.",
	-- 6Message given upon completion of the quest, the npc does not say it, it is another type of text
	"Congratulations, you have finished the quest "..first.questname..""
 
	}
 
 
	if(msgcontains(msg, 'icicle')) then 
		selfSay(npc_message[5], cid)
		talkState[talkUser] = 1
	end

if(msgcontains(msg, 'sludge')) then
		selfSay(npc_message[1], cid)
		if(doPlayerRemoveItem(cid,first.item,first.item_count)) then
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then

if (getPlayerStorageValue(cid,first.storage) == first.last) then 
		selfSay(npc_message[4], cid) 
	else

		if(doPlayerRemoveItem(cid,first.item,first.item_count)) then

if(msgcontains(msg, 'sword')) then
				doPlayerAddItem(cid,first.reward,first.reward_count)
				doPlayerAddExperience(cid,first.experience)
setPlayerStorageValue(cid,first.storage,first.last)

			selfSay(npc_message[3], cid) 
			doSendMagicEffect(getCreaturePosition(cid), 10)
			doCreatureSay(cid, npc_message[6], TALKTYPE_ORANGE_1)
end
if(msgcontains(msg, 'axe')) then
				doPlayerAddItem(cid,first.rewardtwo,first.rewardtwo_count)
				doPlayerAddExperience(cid,first.experience)
setPlayerStorageValue(cid,first.storage,first.last)

			selfSay(npc_message[3], cid) 
			doSendMagicEffect(getCreaturePosition(cid), 10)
			doCreatureSay(cid, npc_message[6], TALKTYPE_ORANGE_1)
end
if(msgcontains(msg, 'club')) then
				doPlayerAddItem(cid,first.rewardthree,first.rewardthree_count)
				doPlayerAddExperience(cid,first.experience)
setPlayerStorageValue(cid,first.storage,first.last)

			selfSay(npc_message[3], cid) 
			doSendMagicEffect(getCreaturePosition(cid), 10)
			doCreatureSay(cid, npc_message[6], TALKTYPE_ORANGE_1)
end
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then 
		selfSay(npc_message[4], cid) 
end
end
end
end
	end
return true
end
 
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I'm not the hoster so I don't know the error it's popping up but he's not showing up on the map.
 
Back
Top