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

Solved npc doesnt take gold

God Mythera

Veteran OT User
Joined
Aug 11, 2012
Messages
2,051
Solutions
2
Reaction score
260
Location
United States
when i try to trade to npc he doesnt sell anything, its like the gold isnt working? this is the scripts for it.

changegold.lua
Code:
local coins = {
   [ITEM_GOLD_COIN] = {
     to = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_YELLOW
   },
   [ITEM_PLATINUM_COIN] = {
     from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_LIGHTBLUE
   },
   [ITEM_CRYSTAL_COIN] = {
     from = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_TEAL
   }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
     return false
   end

   local coin = coins[item.itemid]
   if(not coin) then
     return false
   end

   if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
     doChangeTypeItem(item.uid, item.type - item.type)
     doPlayerAddItem(cid, coin.to, 1)
     doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
   elseif(coin.from ~= nil) then
     doChangeTypeItem(item.uid, item.type - 1)
     doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX)
   doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
   end

return true
end

actions
Code:
<!-- Change gold -->
    <action itemid="2148" event="script" value="other/changegold.lua"/>
    <action itemid="2152" event="script" value="other/changegold.lua"/>
    <action itemid="2160" event="script" value="other/changegold.lua"/>

000-constant.lua
Code:
ITEM_GOLD_COIN = 2148
ITEM_PLATINUM_COIN = 2152
ITEM_CRYSTAL_COIN = 2160
 
You forgot to post your server version.
Assuming you use TFS 0.3/0.4, you are probable missing worth as attribute for the money in items.xml.
Code:
<item id="2148" article="a" name="gold coin" plural="gold coins">
     <attribute key="weight" value="10" />
     <attribute key="worth" value="1" />
</item>
<item id="2152" article="a" name="platinum coin" plural="platinum coins">
   <attribute key="weight" value="10" />
     <attribute key="worth" value="100" />
</item>
<item id="2160" article="a" name="crystal coin" plural="crystal coins">
     <attribute key="weight" value="10" />
     <attribute key="worth" value="10000" />
</item>
 
You forgot to post your server version.
Assuming you use TFS 0.3/0.4, you are probable missing worth as attribute for the money in items.xml.
Code:
<item id="2148" article="a" name="gold coin" plural="gold coins">
     <attribute key="weight" value="10" />
     <attribute key="worth" value="1" />
</item>
<item id="2152" article="a" name="platinum coin" plural="platinum coins">
   <attribute key="weight" value="10" />
     <attribute key="worth" value="100" />
</item>
<item id="2160" article="a" name="crystal coin" plural="crystal coins">
     <attribute key="weight" value="10" />
     <attribute key="worth" value="10000" />
</item>
i have this already :\ players are upset cause they cant spend money on anything and cant buy anything...

edit: works thanks man
 
Last edited:
Back
Top