• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Collect Item Mission Npc

bybbzan

mapper
Joined
Aug 4, 2012
Messages
809
Solutions
2
Reaction score
136
Location
Sweden
Hello guys, i've been searching for a while but can't find the script im searching for.
Therefore im making this request.
I need a script like this.
^_^

Player: Hi
Npc: I cant find my acorn, will you help me?
Player: Yes <player recieves storage>
Npc: Great, Find the acorn and bring it back to me.

Player: Hi
Npc: I cant find my acorn, will you help me?
Player: Acorn <player has 1 acorn>
Npc: Have you found my acorn?
Player: Yes
Npc: Thank you, you brought back my lovely acorn! As a reward i will give you access to this door. <npc take the acorn and give door access>

Hope someone can make this for me.
Thanks in advance!
 
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Eekhoorn" script="eekhoorn.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="274" head="0" body="113" legs="78" feet="114" addons="3"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|, I can't find my {acorn}, will you help me?"/>
	</parameters>
</npc>

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 = 8592
	local doorstorage = 6732

	if(msgcontains(msg, 'yes')) and getPlayerStorageValue(cid, storage) == -1 then
		selfSay('Great, find the acorn and bring it back to me.', cid)
		setPlayerStorageValue(cid, storage, 1)
		return true
	end
	if(msgcontains(msg, 'acorn')) then			
		if getPlayerStorageValue(cid, storage) == 1 then
			selfSay('Have you found my acorn?', cid)
			talkState[talkUser] = 1
		elseif getPlayerStorageValue(cid, storage) >= 2 then
			selfSay('You already helped me before, I lost my acorn again, but I will ask someone else for help now.', cid)
		end
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
       		if getPlayerItemCount(cid, 11207) >= 1 then
                	doPlayerRemoveItem(cid, 11207, 1)
                	selfSay('Thank you, you brought back my lovely acorn! As reward I will give you acces to this door.', cid)
			setPlayerStorageValue(cid, storage, 2)
			setPlayerStorageValue(cid, doorstorage, 1)
			talkState[talkUser] = 0
		else
			selfSay('You don\'t have it.', cid)
			talkState[talkUser] = 0
		end

	elseif(msgcontains(msg, 'no')) then
		selfSay('Pfff!', cid)
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Eekhoorn" script="eekhoorn.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="274" head="0" body="113" legs="78" feet="114" addons="3"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|, I can't find my {acorn}, will you help me?"/>
	</parameters>
</npc>

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 = 8592
	local doorstorage = 6732

	if(msgcontains(msg, 'yes')) and getPlayerStorageValue(cid, storage) == -1 then
		selfSay('Great, find the acorn and bring it back to me.', cid)
		setPlayerStorageValue(cid, storage, 1)
		return true
	end
	if(msgcontains(msg, 'acorn')) then			
		if getPlayerStorageValue(cid, storage) == 1 then
			selfSay('Have you found my acorn?', cid)
			talkState[talkUser] = 1
		elseif getPlayerStorageValue(cid, storage) >= 2 then
			selfSay('You already helped me before, I lost my acorn again, but I will ask someone else for help now.', cid)
		end
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
       		if getPlayerItemCount(cid, 11207) >= 1 then
                	doPlayerRemoveItem(cid, 11207, 1)
                	selfSay('Thank you, you brought back my lovely acorn! As reward I will give you acces to this door.', cid)
			setPlayerStorageValue(cid, storage, 2)
			setPlayerStorageValue(cid, doorstorage, 1)
			talkState[talkUser] = 0
		else
			selfSay('You don\'t have it.', cid)
			talkState[talkUser] = 0
		end

	elseif(msgcontains(msg, 'no')) then
		selfSay('Pfff!', cid)
	end
	return true
end

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

Thank you very much Limos. Rep added :)
 
Back
Top