<?xml version="1.0"?>
<npc name="Heroid" walkinterval="3000" floorchange="0">
<health now="100" max="100"/>
<look type="128" head="79" body="0" legs="40" feet="94" addons="1"/>
<interaction range="4" idletime="30" idleinterval="3000" defaultpublic="0">
<!--This will include the bankman interaction, in this way several npc can use the same interaction-->
<include file="npcrook.xml"/>
<interact keywords="hi" focus="1">
<!--These are the alternative keywords-->
<keywords>hello</keywords>
<response text="Hi |NAME|. I have some types of food for sale. Say {trade} if you are interested."/>
</interact>
<interact keywords="bye" focus="0">
<!--These are the alternative keywords-->
<keywords>farewell</keywords>
<response text="Good bye |NAME|, and please visit me again later!"/>
</interact>
<interact event="onPlayerLeave" focus="0">
<response text="People are so rude!"/>
</interact>
<interact keywords="trade">
<list>food</list>
<response>
<action name="script">
<![CDATA[
openShopWindow(cid, itemlist, -1, -1)
]]>
</action>
</response>
</interact>
<interact event="onPlayerShopBuy">
<response>
<action name="price" value="|BUYPRICE|"/>
<action name="script">
<![CDATA[
if(getPlayerMoney(cid) >= _state.amount * _state.price) then
local count
for count=0, _state.amount-1 do
local result = doPlayerAddItem(cid, _state.itemid, _state.subtype, 0)
if(result == -1) then
if(count == 0) then
selfSay("You need more free slots in your backpack to buy it!", cid)
return
else
selfSay("I've sold some for you, but it seems you can't carry more than this. I won't take more money than necessary.", cid)
doPlayerRemoveMoney(cid, count * _state.price)
return
end
end
end
selfSay("Here you are.", cid)
doPlayerRemoveMoney(cid, _state.price * _state.amount)
else
selfSay("Sorry, you do not have enough gold.", cid)
end
]]>
</action>
</response>
</interact>
<interact event="onPlayerShopSell">
<response>
<action name="price" value="|SELLPRICE|"/>
<action name="script">
<![CDATA[
if(doPlayerRemoveItem(cid, _state.itemid, _state.amount, _state.subtype) == TRUE) then
doPlayerAddMoney(cid, _state.price * _state.amount)
selfSay("Thanks for this item.", cid)
else
selfSay("Sorry, you do not have one.", cid)
end
]]>
</action>
</response>
</interact>
</interaction>
</npc>