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

[NPC] Simple Npc

Brad

Mapper
Joined
Aug 27, 2008
Messages
592
Reaction score
21
Location
Canada Eh?
As far as i know this sounds pretty simple, I just want a npc that takes 1 item and give you a prize. But only once.

Thanks~
 
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)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	--[[
	REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
	]]--
	local storage = 4902
	if(msgcontains(msg, 'quest') or msgcontains(msg, 'mission')) then
		if(getPlayerStorageValue(cid, storage) < 1) then
			npcHandler:say("Greetings |PLAYERNAME|! I lost a valuable charm up in the mountains here. Would you be able to find it for me?", cid)
			setPlayerStorageValue(cid, storage, 1)
		elseif(getPlayerStorageValue(cid, storage) == 2) then
			npcHandler:say("Did you find my charm?", cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, storage) == 3) then
			npcHandler:say("I have no more missions to offer you. Make sure you get blessed in the temple!", cid)
		end
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(doPlayerRemoveItem(cid, 11425, 1) == TRUE) then
			npcHandler:say("Oh, thats it! Thank you for bringing this back to me! You can now use the blue lever in the temple to be blessed, that way you will lose less experience and none of your items.", cid)
			npcHandler:say("Check the reward room under the temple, also.", cid)
			doPlayerAddItem(cid, 2160, 2)
			setPlayerStorageValue(cid, storage, 3)
			setPlayerStorageValue(cid, 4904)
			talkState[talkUser] = 0
		else
			npcHandler:say("You do not have the charm I asked for. It should be up in the mountain behind me somewhere.", cid)
			talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
		npcHandler:say("Ok.", cid)
		talkState[talkUser] = 0
	end
	return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Edit it as you need it
 
Back
Top