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

Lua Npc

dinhus2jaque

New Member
Joined
Oct 5, 2008
Messages
35
Reaction score
0
I want to create an NPC to trade HOTA for all the components that are needed for the quest (eg: damaged helmet, helmet adornment, helmet piece, etc)
Can anyone explain me how to do? or if anyone can make it for me?

helmet adornment - 2341
helmet piece - 2340
left horn - 2338
right horn - 2337
gem holder - 2336
helmet ornament - 2335
damaged helmet - 2339

Hota - 2342

Ty ^^
 
Im not sure what do you want, here is a simple seller ;s

Code:
<?xml version="1.0" encoding="UTF-8"?>

<npc name="Tools" script="data/npc/scripts/tools.lua" walkinterval="1" floorchange="0">

	<health now="100" max="100"/>

	<look type="138" head="57" body="59" legs="40" feet="76" addons="0"/>

	<parameters>

		<parameter key="module_shop" value="1"/>

		<parameter key="shop_buyable" value="hereNameOfItem,itemIdOfItem,priceOfItem;anotherItemName,anotherItemId,anoTherPrice"/>

	</parameters>

</npc>

Take this tool seller npc as example, i modified this line so it may be easier for you to understand now:

Code:
<parameter key="shop_buyable" value="hereNameOfItem,itemIdOfItem,priceOfItem;anotherItemName,anotherItemId,anoTherPrice"/>

A real example, would be something like:

Code:
<parameter key="shop_buyable" value="backpack,1988,20;pick,2553,10"/>

Keep adding as many items as you want, separate them using ';', dont use that symbol for the last item.
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

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 greetCallback(cid)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	Topic[talkUser] = 0
	return true
end

function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	elseif Topic[talkUser] == 1 then
		if msgcontains(msg, "yes") then
			local v = true
			for i = 2335, 2341 do
				if(getPlayerItemCount(cid, i) < 1) then
					v = false
					break
				end
			end
			if(v) then
				for i = 2335, 2341 do
					doPlayerRemoveItem(cid, i, 1)
				end
				npcHandler:say("Thank you. Here it is.", cid)
				doPlayerAddItem(cid, 2342, 1)
			else
				npcHandler:say("You don't have them all.", cid)
			end
		else
			npcHandler:say("Then not.", cid)
		end
		Topic[talkUser] = 0
	elseif msgcontains(msg, "trade") or msgcontains(msg, "helmet") or msgcontains(msg, "piece") then
		npcHandler:say("Have you brought me all 7 pieces of the helmet?", cid)
		Topic[talkUser] = 1
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

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 greetCallback(cid)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	Topic[talkUser] = 0
	return true
end

function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	elseif Topic[talkUser] == 1 then
		if msgcontains(msg, "yes") then
			local v = true
			for i = 2335, 2341 do
				if(getPlayerItemCount(cid, i) < 1) then
					v = false
					break
				end
			end
			if(v) then
				for i = 2335, 2341 do
					doPlayerRemoveItem(cid, i, 1)
				end
				npcHandler:say("Thank you. Here it is.", cid)
				doPlayerAddItem(cid, 2342, 1)
			else
				npcHandler:say("You don't have them all.", cid)
			end
		else
			npcHandler:say("Then not.", cid)
		end
		Topic[talkUser] = 0
	elseif msgcontains(msg, "trade") or msgcontains(msg, "helmet") or msgcontains(msg, "piece") then
		npcHandler:say("Have you brought me all 7 pieces of the helmet?", cid)
		Topic[talkUser] = 1
	end
	return TRUE
end

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

Thx
Cykotitan

I already gave rep++
it worked perfectly
 
Back
Top