• 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 Trade Itens Request ! :) (O.B)

jpkulik

New Member
Joined
Mar 15, 2008
Messages
208
Reaction score
2
Hello all!
Some one can borow me the NPC to trade itens?
Because, i want to make a NPC for a obsidian knife, like:
Player:Obsidian Knife
NPC: I can provide you a obsidian knife, but you need to give me a dragon shield and 10000 gold coins.Do you have it?
Player:Yes
NPC: There is it!

Conclusion: Player give 10k and a dragon shield and trade it for a obsidian knife.
I hope some one have it.
Tanks all!
Cya
 
Code:
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

function trade(cid, message, keywords, parameters, node)
	if(cid ~= npcHandler.focus) then
		return false
	end
	
	local cost = parameters.cost
	id = parameters.id
		      if doPlayerRemoveMoney(cid, cost) == TRUE then
			doPlayerRemoveItem(cid, 2516)
			doPlayerAddItem(cid, 5908) 
			npcHandler:say('Great!')
	else
		npcHandler:say('Sorry. Do you not have that items !')
      end

	keywordHandler:moveUp(1)
	return true
end

local node = keywordHandler:addKeyword({'obsidian knife'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can provide you a obsidian knife, but you need to give me a dragon shield and 10000 gold coins.Do you have it?'})
	node:addChildKeyword({'yes'}, trade, {cost = 10000, })
	node:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Maybe next time...'})

npcHandler:addModule(FocusModule:new())
 
Code:
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

function trade(cid, message, keywords, parameters, node)
	if(cid ~= npcHandler.focus) then
		return false
	end
	
	local cost = parameters.cost
	id = parameters.id
		      if doPlayerRemoveMoney(cid, cost) == TRUE then
			doPlayerRemoveItem(cid, 2516)
			doPlayerAddItem(cid, 5908) 
			npcHandler:say('Great!')
	else
		npcHandler:say('Sorry. Do you not have that items !')
      end

	keywordHandler:moveUp(1)
	return true
end

local node = keywordHandler:addKeyword({'obsidian knife'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can provide you a obsidian knife, but you need to give me a dragon shield and 10000 gold coins.Do you have it?'})
	node:addChildKeyword({'yes'}, trade, {cost = 10000, })
	node:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Maybe next time...'})

npcHandler:addModule(FocusModule:new())

Humm :(
Dont work very well, the Npc Get the 10k, but dont get dragon shield.
 
Last edited:
Sorry I have repaired it
Code:
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

function trade(cid, message, keywords, parameters, node)
	if(cid ~= npcHandler.focus) then
		return false
	end
	
	local cost = parameters.cost
		      if doPlayerRemoveMoney(cid, cost) == TRUE then
			if doPlayerRemoveItem(cid, 2516, 1) == TRUE then
			doPlayerAddItem(cid, 5908) 
			npcHandler:say('Great!')
	else
		npcHandler:say('Sorry. Do you not have that items !')
      end
	end

	keywordHandler:moveUp(1)
	return true
end

local node = keywordHandler:addKeyword({'obsidian knife'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can provide you a obsidian knife, but you need to give me a dragon shield and 10000 gold coins.Do you have it?'})
	node:addChildKeyword({'yes'}, trade, {cost = 10000, })
	node:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Maybe next time...'})

npcHandler:addModule(FocusModule:new())
 
Last edited:
Sorry I have repaired it
Code:
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

function trade(cid, message, keywords, parameters, node)
	if(cid ~= npcHandler.focus) then
		return false
	end
	
	local cost = parameters.cost
		      if doPlayerRemoveMoney(cid, cost) == TRUE then
			if doPlayerRemoveItem(cid, 2516, 1) == TRUE then
			doPlayerAddItem(cid, 5908) 
			npcHandler:say('Great!')
	else
		npcHandler:say('Sorry. Do you not have that items !')
      end
	end

	keywordHandler:moveUp(1)
	return true
end

local node = keywordHandler:addKeyword({'obsidian knife'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can provide you a obsidian knife, but you need to give me a dragon shield and 10000 gold coins.Do you have it?'})
	node:addChildKeyword({'yes'}, trade, {cost = 10000, })
	node:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Maybe next time...'})

npcHandler:addModule(FocusModule:new())

Ok! I will try it and i edit the post
 
Back
Top