• 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 that changes 4 items for one

Sir MoX

New Member
Joined
Jan 14, 2009
Messages
285
Reaction score
1
Hi, I need a NPC that can talk to you about four misterious objets( id: 11337, 12426, 12424 and 11076) that he have look everywhere and hasn't found them, so he ask you to look for them and he will reward you with the item (10124)

I will repp, Im using tfs 0.2.11 please I need it tested to dont have errors
 
can you test this:

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- 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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'help') then
selfSay('Here, you can change some items with me.')
elseif msgcontains(msg, 'misterious') then
if getPlayerItemCount(cid,11337) >= 1 and getPlayerItemCount(cid,12426) >= 1 and getPlayerItemCount(cid,11076) >= 1 and getPlayerItemCount(cid,12424) >= 1 then
selfSay('Did you bring me the four misterious item ?')
talk_state = 2
else
selfSay('I need the four misterious item !')
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerItemCount(cid,11337) >= 1 and getPlayerItemCount(cid,12426) >= 1 and getPlayerItemCount(cid,11076) >= 1 and getPlayerItemCount(cid,12424) >= 1 then
if doPlayerRemoveItem(cid,11337,1) == 1 and doPlayerRemoveItem(cid,12426,1) == 1 and doPlayerRemoveItem(cid,11076,1) == 1 and doPlayerRemoveItem(cid,12424,1) == 1 then
selfSay(addon_give)
doPlayerAddItem(cid,10124,1)
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
return true
end

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

EDIT: I've test and fix the lua
EDIT: This script is a fast modification of the sweaty cyclops, if anyone want said a more good npc said this =)
 
Last edited:
its doesnt working because when I say "yes" the npc only removes me the item 11337 and nothing more happens =/
 
Lua:
local config = {
	takeItems = {11337, 12426, 12424, 11076},
	addItem = 10124
}
for i = 1, 4 do
	if(getPlayerItemCount(cid, config.takeItems[i]) < 1) then
		npcHandler:say("You don't have required items.", cid)
		return true
	end
end
for i = 1, 4 do
	doPlayerRemoveItem(cid, config.takeItems[i], 1)
end
npcHandler:say("Here you are.", cid)
doPlayerAddItem(cid, config.addItem, 1)
 
Last edited:
@up

that one absolutely isnt working!!! please someone could do it fine please, its not hard but I dont know how FOR TFS 0.2.11
 
Back
Top