• 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 Don't Buy

marcos16

Falkhonn
Joined
May 4, 2012
Messages
224
Reaction score
1
I was using a tfs 0.4 8.6 I passed the files to tfs 0.3.7 10.10. The NPC's of trade I'm not buying the items. When I try to sell the item it says that I do not have any. Could anyone help?
NOTE: There is no error in the executable

Up
 
Last edited by a moderator:
I was using a tfs 0.4 8.6 I passed the files to tfs 0.3.7 10.10. The NPC's of trade I'm not buying the items. When I try to sell the item it says that I do not have any. Could anyone help?
NOTE: There is no error in the executable

Up

Did you update all the libs aswell?
Try to use the "default" NPC pack and see if they work, if they do it's either the libs or NPC Lua / XML code.
 
Did you update all the libs aswell?
Try to use the "default" NPC pack and see if they work, if they do it's either the libs or NPC Lua / XML code.

I did the test with the standard worked. I just added 1 npc of 8.6 to do the test, persisted in the error.
My NPC:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<npc name="Jade" access="3" lookdir="2" speed="0" walkinterval="0">
    <mana now="100" max="100"/>
    <health now="1500" max="1500"/>
    <look type="136" head="77" body="82" legs="79" feet="10" addon="1" corpse="3128"/>

<interaction range="2" idletime="0" defaultpublic="0">
    <!--This will include the merchant interaction, in this way several npc can use the same interaction-->
    <include file="merchant.xml"/>

    <interact keywords="hi" focus="1">
      <!--These are the alternative keywords-->
      <keywords>oi</keywords>

      <response text="Olá. Como posso te ajudar |NAME|?"/>
    </interact>

    <interact keywords="bye" focus="0">
      <!--These are the alternative keywords-->
      <keywords>tchau</keywords>

      <response text="Volte sempre."/>
    </interact>

    <!--
    <interact event="onBusy">
      <response text="One moment please, |NAME|.">
        <action name="addqueue" value="|PLAYER|"/>
      </response>
    </interact>
    -->

    <interact event="onPlayerLeave" focus="0">
      <response text="Volte sempre |NAME|."/>
    </interact>

    <interact keywords="name">
      <response text="Meu nome é |NPCNAME|."/>
    </interact>

    <interact keywords="job">
      <response text="Sou um comerciante, meu trabalho é te ajudar!"/>
    </interact>

    <interact keywords="trade">
        <keywords>lista</keywords>
        <keywords>buy</keywords>
        <keywords>sell</keywords>
       
      <list>axe</list>
      <response>
        <action name="script">
        <![CDATA[
          openShopWindow(cid, itemlist, -1, -1)
        ]]>
        </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("Aqui está.", cid)
          else
            selfSay("Você não tem nenhum.", cid)
          end
        ]]>
        </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("Você não tem espaço suficiente para carregar.", cid)
                  return
                else
                  selfSay("Você não consegue carregar mais.", cid)
                  doPlayerRemoveMoney(cid, count * _state.price)
                  return
                end
              end
            end

            selfSay("Aqui está.", cid)
            doPlayerRemoveMoney(cid, _state.price * _state.amount)
          else
            selfSay("Você não tem dinheiro suficiente.", cid)
          end
        ]]>
        </action>
      </response>
    </interact>
  </interaction>

</npc>

Default NPC:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Tyoric" script="default.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="134" head="57" body="59" legs="40" feet="76" addons="0"/>
    <parameters>
        <parameter key="module_shop" value="1"/>
        <parameter key="shop_sellable" value="crossbow,2455,150;bow,2456,130"/>
        <parameter key="shop_buyable" value="crossbow,2455,360;bow,2456,200;spear,2389,20;poison arrow,2545,18;bolt,2543,3;arrow,2544,2"/>
    </parameters>
</npc>
 
I did the test with the standard worked. I just added 1 npc of 8.6 to do the test, persisted in the error.
My NPC:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<npc name="Jade" access="3" lookdir="2" speed="0" walkinterval="0">
    <mana now="100" max="100"/>
    <health now="1500" max="1500"/>
    <look type="136" head="77" body="82" legs="79" feet="10" addon="1" corpse="3128"/>

<interaction range="2" idletime="0" defaultpublic="0">
    <!--This will include the merchant interaction, in this way several npc can use the same interaction-->
    <include file="merchant.xml"/>

    <interact keywords="hi" focus="1">
      <!--These are the alternative keywords-->
      <keywords>oi</keywords>

      <response text="Olá. Como posso te ajudar |NAME|?"/>
    </interact>

    <interact keywords="bye" focus="0">
      <!--These are the alternative keywords-->
      <keywords>tchau</keywords>

      <response text="Volte sempre."/>
    </interact>

    <!--
    <interact event="onBusy">
      <response text="One moment please, |NAME|.">
        <action name="addqueue" value="|PLAYER|"/>
      </response>
    </interact>
    -->

    <interact event="onPlayerLeave" focus="0">
      <response text="Volte sempre |NAME|."/>
    </interact>

    <interact keywords="name">
      <response text="Meu nome é |NPCNAME|."/>
    </interact>

    <interact keywords="job">
      <response text="Sou um comerciante, meu trabalho é te ajudar!"/>
    </interact>

    <interact keywords="trade">
        <keywords>lista</keywords>
        <keywords>buy</keywords>
        <keywords>sell</keywords>
      
      <list>axe</list>
      <response>
        <action name="script">
        <![CDATA[
          openShopWindow(cid, itemlist, -1, -1)
        ]]>
        </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("Aqui está.", cid)
          else
            selfSay("Você não tem nenhum.", cid)
          end
        ]]>
        </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("Você não tem espaço suficiente para carregar.", cid)
                  return
                else
                  selfSay("Você não consegue carregar mais.", cid)
                  doPlayerRemoveMoney(cid, count * _state.price)
                  return
                end
              end
            end

            selfSay("Aqui está.", cid)
            doPlayerRemoveMoney(cid, _state.price * _state.amount)
          else
            selfSay("Você não tem dinheiro suficiente.", cid)
          end
        ]]>
        </action>
      </response>
    </interact>
  </interaction>

</npc>

Default NPC:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Tyoric" script="default.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="134" head="57" body="59" legs="40" feet="76" addons="0"/>
    <parameters>
        <parameter key="module_shop" value="1"/>
        <parameter key="shop_sellable" value="crossbow,2455,150;bow,2456,130"/>
        <parameter key="shop_buyable" value="crossbow,2455,360;bow,2456,200;spear,2389,20;poison arrow,2545,18;bolt,2543,3;arrow,2544,2"/>
    </parameters>
</npc>

Check your source code if you even have "interaction" in it.
Seems like you are trying to script Lua in XML, that might have been removed / not added in your other version.
Best would be to just rescript them to XML and Lua if this is how all of your NPC codes look.
 
Back
Top