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

Npc changer

pawlacz741

New Member
Joined
Jan 23, 2009
Messages
90
Reaction score
2
Hello

I need npc who changing 10 items witch id 8981 to one item witch id 2329

I need to talk witch npc

hi
change
yes
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

item = 'You do not have the required items.'
done = 'Here you are.'

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
		if msgcontains(msg, 'offer') then
		selfSay('You can here change some items for {item name}.', cid)

elseif msgcontains(msg, 'item name') then
				if getPlayerItemCount(cid,8981) >= 10 then
					selfSay('Did you bring me 10 xxx?', cid)
					talk_state = 4
				else
					selfSay('I need {10 xx}, to give you xxx. Come back when you have them.', cid)
					talk_state = 0
				end
		elseif msgcontains(msg, 'yes') and talk_state == 4 then
			talk_state = 0
			if getPlayerItemCount(cid,8981) >= 10 then
					if doPlayerRemoveItem(cid,8981,10) == TRUE then
						doPlayerAddItem(cid,2329,1)
						selfSay(done, cid)
					end
				else
				selfSay(item, cid)
				end
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('So Leave, LEAVE ME NOW!')
            talk_state = 0
        end
    return true
end

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

Change the xx to item names and "item name" to your item names.
 
Back
Top