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

Stupid question?

psychosisneamia

~Beginner~
Joined
Jun 7, 2012
Messages
162
Reaction score
7
I added a new coin my server but I can not get the npc to recognize that the coin is money.. What do you think I did wrong?

000constant
Code:
ITEM_GOLD_COIN = 2148
ITEM_PLAT_COIN = 2152
ITEM_CRYS_COIN = 2160
ITEM_DEMO_COIN = 18547

Items.xml
Code:
  <item id="18547" name="Demonic Coin" /> 
    <attribute key="weight" value="10" />  
  <attribute key="worth" value="1000000" />

Actions.xml
Code:
<action itemid="18547" event="script" value="other/changegold.lua"/>

Changegold.lua
Code:
GOLD_COIN = 2148
PLAT_COIN = 2152
CRYS_COIN = 2160
DEMO_COIN = 18547
 
What you done so far, that is just for change the gold isn't it?
To be able to buy with it in trade with NPC's, you have to do something totally different.
 
I added a new coin my server but I can not get the npc to recognize that the coin is money.. What do you think I did wrong?

000constant
I wrote this and I don't know if it works, try it out and see if it works, just backup your changegold.lua save this as changegold.lua.
Code:
local money = {
    2148, -- gold
    2152, -- platinum
    2160, -- crystal
    18547 -- demon coin
}

local amount = {
    1,
    100
}

function onUse(cid, item, frompos, item2, topos)
    local index = isInArray(money, item.itemid, true)
     if (index ~= -1 and index ~= #money) and item.type == amount[2] then
        doRemoveItem(item.uid, item.type)
        doPlayerAddItem(cid, money[index+1], amount[1])
        doPlayerSendTextMessage(cid, 22, "You have changed "..amount[2].." "..getItemInfo(money[index]).name." to "..amount[1].." "..getItemInfo(money[index+1]).name)
    elseif index > 1 and item.type < amount[2] then
        doRemoveItem(item.uid, amount[1])
        doPlayerAddItem(cid, money[index-1], amount[2])
        doPlayerSendTextMessage(cid, 22, "You have changed "..amount[1].." "..getItemInfo(money[index]).name." into "..amount[2].." "..getItemInfo(money[index-1]).name)
    else
        doPlayerSendTextMessage(cid, 22, "You need 100 gold in order to change to 1 platinum coin")
        return false
    end
    return true
end


function isInArray(table_t, value, returnIndex)
    if type(table_t) == "table" and value ~= nil then
        for index, v in pairs(table_t) do
            if v == value then
                return returnIndex and index or 1
            end
        end
    end
    return -1
end

Let me look at the npc system and see if I can edit the files,

I'll have a look in the morning, just got off work & its late :(
 
Last edited:
Back
Top