Currently sells: Big table, red and green cushioned chairs, red/green/blue/white/yellow/purple tapestry.
Required items are Wood (5901) and pieces of cloth matching the tapestry or chair.
in \npc add Bob the builder.xml
in npc\scripts add BUILDER.LUA
Required items are Wood (5901) and pieces of cloth matching the tapestry or chair.
in \npc add Bob the builder.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Bob the builder" script="builder.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="128" body="113" feet="120" head="3" legs="105" addons="1" corpse="7349"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|, I have some {furniture} for trade!"/>
</parameters>
</npc>
in npc\scripts add BUILDER.LUA
Code:
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
if(msgcontains(msg, "furn")) then
npcHandler:say("I can build you a {big table}, {red cushioned chair}, {green cushioned chair}, any color {tapestry} ", cid)
talkState[talkUser] = 1
end
if(msgcontains(msg, "red cush")) then
npcHandler:say("A red cushioned chair requires 15x wood and 3x red piece of cloth. Do you have these supplies?", cid)
talkState[talkUser] = 2
end
if(msgcontains(msg, "green cush")) then
npcHandler:say("A green cushioned chair requires 15x wood and 3x green piece of cloth. Do you have these supplies?", cid)
talkState[talkUser] = 3
end
if(msgcontains(msg, "big table")) then
npcHandler:say("A big table requires 25x wood. Do you have these supplies?", cid)
talkState[talkUser] = 4
end
if(msgcontains(msg, "tapestry")) then
npcHandler:say("I can make you a {blue tapestry}, {red tapestry}, {orange tapestry}, {green tapestry}, {white tapestry}, {yellow tapestry} or {purple tapestry}.", cid)
talkState[talkUser] = 5
end
if(msgcontains(msg, "blue tap")) then
npcHandler:say("A blue tapestry requires 15x blue piece of cloth. Do you have these supplies?", cid)
talkState[talkUser] = 6
end
if(msgcontains(msg, "red tap")) then
npcHandler:say("A red tapestry requires 15x red piece of cloth. Do you have these supplies?", cid)
talkState[talkUser] = 7
end
if(msgcontains(msg, "orange tap")) then
npcHandler:say("An orange tapestry requires 10x red piece of cloth and 5x white piece of cloth. Do you have these supplies?", cid)
talkState[talkUser] = 8
end
if(msgcontains(msg, "green tap")) then
npcHandler:say("A green tapestry requires 15x green piece of cloth. Do you have these supplies?", cid)
talkState[talkUser] = 9
end
if(msgcontains(msg, "white tap")) then
npcHandler:say("A white tapestry requires 15x white piece of cloth. Do you have these supplies?", cid)
talkState[talkUser] = 10
end
if(msgcontains(msg, "yellow tap")) then
npcHandler:say("A yellow tapestry requires 15x yellow piece of cloth. Do you have these supplies?", cid)
talkState[talkUser] = 11
end
if(msgcontains(msg, "purple tap")) then
npcHandler:say("A purple tapestry requires 5x red piece of cloth, 5x white piece of cloth and 5x green piece of cloth. Do you have these supplies?", cid)
talkState[talkUser] = 12
end
if(msgcontains(msg, 'yes')) then
if(talkState[talkUser] == 2) then
if(getPlayerItemCount(cid, 5901) >= 15) and (getPlayerItemCount(cid, 5911) >= 3) then
doPlayerRemoveItem(cid, 5901, 15)
doPlayerRemoveItem(cid, 5911, 3)
doPlayerAddItem(cid, 3903, 1)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
elseif(talkState[talkUser] == 3) then
if(getPlayerItemCount(cid, 5901) >= 15) and (getPlayerItemCount(cid, 5910) >= 3) then
doPlayerRemoveItem(cid, 5901, 15)
doPlayerRemoveItem(cid, 5910, 3)
doPlayerAddItem(cid, 3904, 1)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
elseif(talkState[talkUser] == 4) then
if(getPlayerItemCount(cid, 5901) >= 25) then
doPlayerRemoveItem(cid, 5901, 25)
doPlayerAddItem(cid, 3909, 10)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
elseif(talkState[talkUser] == 55) then
if(getPlayerItemCount(cid, 5901) >= 25) then
doPlayerRemoveItem(cid, 5901, 25)
doPlayerAddItem(cid, 3909, 10)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
elseif(talkState[talkUser] == 6) then
if(getPlayerItemCount(cid, 5912) >= 15) then
doPlayerRemoveItem(cid, 5912, 15)
doPlayerAddItem(cid, 1872, 1)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
elseif(talkState[talkUser] == 7) then
if(getPlayerItemCount(cid, 5911) >= 15) then
doPlayerRemoveItem(cid, 5911, 15)
doPlayerAddItem(cid, 1869, 1)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
elseif(talkState[talkUser] == 8) then
if(getPlayerItemCount(cid, 5911) >= 10) and (getPlayerItemCount(cid, 5909) >= 5) then
doPlayerRemoveItem(cid, 5911, 10)
doPlayerRemoveItem(cid, 5909, 5)
doPlayerAddItem(cid, 1866, 1)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
elseif(talkState[talkUser] == 9) then
if(getPlayerItemCount(cid, 5910) >= 15) then
doPlayerRemoveItem(cid, 5910, 15)
doPlayerAddItem(cid, 1860, 1)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
elseif(talkState[talkUser] == 10) then
if(getPlayerItemCount(cid, 5909) >= 15) then
doPlayerRemoveItem(cid, 5909, 15)
doPlayerAddItem(cid, 1880, 1)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
elseif(talkState[talkUser] == 11) then
if(getPlayerItemCount(cid, 5914) >= 15) then
doPlayerRemoveItem(cid, 5914, 15)
doPlayerAddItem(cid, 1863, 1)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
elseif(talkState[talkUser] == 12) then
if(getPlayerItemCount(cid, 5911) >= 5) and (getPlayerItemCount(cid, 5909) >= 5) and (getPlayerItemCount(cid, 5910) >= 5) then
doPlayerRemoveItem(cid, 5909, 5)
doPlayerRemoveItem(cid, 5910, 5)
doPlayerRemoveItem(cid, 5911, 5)
doPlayerAddItem(cid, 1857, 1)
npcHandler:say("Thanks!", cid)
else
npcHandler:say("You don't have enough supplies!", cid)
end
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no')) then
if(talkState[talkUser] == 1) then
npcHandler:say("Maybe later?", cid)
end
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: