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

Help in NPC module - Problem with countable items 255 instead of 1

I've already repaired item names but I found next problem with stocking items.

Items wchich can be more then 1 are show in trade window with number 255, if I will buy 1 item in Trade Window NPC will give me 255..., if 2 in Trade Window NPC give me 510 etc.

Screen:
food3.png

As all can see, in this small window is number 255, and this is destroying everything :(

I tried add to item tables something like amount="1" or count="1" but it doesn't work

Now I will add my NPC script and script with tables:

NPC
Code:
<?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>


Tables with item lists
Code:
<?xml version="1.0"?>

<interaction>
  <itemlist listid="equipment">
    <item keywords="pick" id="2553" buyprice="50" name="pick"/>
    <item keywords="shovel" id="2554" buyprice="20" name="shovel"/>
    <item keywords="rope" id="2120" buyprice="20" sellprice="8" name="rope"/>
    <item keywords="backpack" id="1988" buyprice="20" name="backpack"/>
    <item keywords="bag" id="1987" buyprice="8" name="bag"/>
  </itemlist>

  <itemlist listid="food">
    <item keywords="blueberry" id="2677" sellprice="1" name="blueberry" pname="blueberries"/>
    <item keywords="bread" id="2689" buyprice="4" sellprice="1" name="bread"/>
    <item keywords="carrot" id="2684" sellprice="1" name="carrot" pname="carrots"/>
    <item keywords="cheese" id="2696" buyprice="5" sellprice="2" name="cheese" pname="cheeses"/>
    <item keywords="cherry" id="2679" sellprice="1" name="cherry" pname="cherries"/>
    <item keywords="egg" id="2695" buyprice="2" name="egg" pname="eggs"/>
    <item keywords="fish" id="2667" buyprice="6" name="fish"/>
    <item keywords="roll" id="2690" buyprice="2" name="roll" pname="rolls"/>
  </itemlist>
</interaction>



Thanks for given help :)
 
Last edited:
Copy script from another seller if it's continious you must repair or fix sources.

I have this error with all NPC who have in offer countable items (worms, diamonds, food etc.) With NPC who selling armors, shields, etc. there's no problem because this item can be just one ;/
 
Back
Top