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

TFS 1.X+ [tfs 1.2] npc sell items for other gold ID

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,210
Solutions
35
Reaction score
206
his script works on tfs 0.4 but not 1.3 it is in error.
(npc that when talking trade, you can buy with another type of coin ID, other than gold coin)
when the player does not have the new gold coin count, he should return the message:
LUA:
selfSay("U dont have "..t[item].price.." "..ItemType(newcoin):getId().." to buy.", cid)
but does not return anything nor error in the console.
the same mistake happens when buying, clicking to buy returns nothing
both case no error in console

obs: the trade channel open correct, with the items.
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
    local shopWindow = {}

    local newcoin = 6541 -- ID certain item

    local t = {
    [2342] = {price = 250}, -- helmet
    [2503] = {price = 250}, -- armor
    }

    local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
        if t[item] and not doPlayerRemoveItem(cid, newcoin, t[item].price) then
            selfSay("U dont have "..t[item].price.." "..ItemType(newcoin):getId().." to buy.", cid)
        else
            doPlayerAddItem(cid, item)
            selfSay("Here your item!", cid)
        end
        return true
    end


    if (msgcontains(msg, 'trade'))then
        for var, ret in pairs(t) do
            table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
        end
        openShopWindow(cid, shopWindow, onBuy, onSell)
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Solution
I think you'll have to add this coin through source files, Then NPC will learn to read it alone exactly like Gold/Platinum/Crystal coins.
I think you'll have to add this coin through source files, Then NPC will learn to read it alone exactly like Gold/Platinum/Crystal coins.
 
Solution
I think you'll have to add this coin through source files, Then NPC will learn to read it alone exactly like Gold/Platinum/Crystal coins.

but this script worked on 0.4 perfectly, no source modifications.
the new item u can get in quest, not a "new gold"
 
Back
Top