• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

NPC WHO SELL TIBIA COIN AND TRADE ITEMS FOR TC

darknelson

Member
Joined
Jun 19, 2011
Messages
190
Solutions
1
Reaction score
15
HI, IM REQUESTING 2 NPCS

THE FIRST IS JUST FOR BUY AND SELL TIBIA COINS, EXAMPLE WITH THIS DIALOG

PLAYER: HI
NPC: HI YOU WANT BUY OR SELL
PLAYER: BUY
NPC: HOW MANY TIBIA COINS U WANT, ?
PLAYER: 1
NPS: THAT WILL COST, 1KK
PLAYER: 20
NPC: THAT WILL COST, 20KK
PLAYER: SELL
NPC: HOW MANY COINS U WANT SELL
PLAYER: 1
NPC: I CAN PAY 1KK
PLAYER: 20
NPC: I CAN PAY 20KK
PLAYER: YES
NPC: HERE U ARE THANKS


AND NPC FOR TRADE ITEMS FOR COINS, EXAMPLE

PLAYER: HI
NPC: I TRADE ITEMS FROM THE STORE BACK TO TIBIA COINS
PLAYER: VIP BOOTS
NPC: I CAN PAY 50TC FOR THAT
PLAYER: YES
NPC: HERE U ARE THANKS

PLEASE HELP ME I EVEN CAN PAY IF IS TO MUCH DIFICULT TO DO THAT
 
Try this

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local count = {}
local transfer = {}
local ratio = 1250
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

local function creatureSayCallback(cid, type, msg)

    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

if msgcontains(msg, "balance") then
    npcHandler:say('Your balance is ' .. player:getCoinsBalance() .. ' tibia coins.', cid)

    elseif msgcontains(msg, "purchase") or msgcontains(msg, "exchange") or msgcontains(msg, "tibia coins")then
    count[cid] = player:getBankBalance()
        if count[cid] < 1 then
            npcHandler:say('You need to have gold in your bank to {exchange} currency.', cid)
            npcHandler.topic[cid] = 0
            return false
        end
        
            if string.match(msg,'%d+') then
                count[cid] = getMoneyCount(msg)
                if count[cid] < 1 then
                    npcHandler:say('You do not have enough money {in your bank} to make this exchange.', cid)
                    npcHandler.topic[cid] = 0
                    return false
                end
                amount = getMoneyCount(msg)
                cost = amount * ratio
                npcHandler:say('Would you really like to purchase ' .. count[cid] .. ' tibia coins for ' .. cost .. ' gold coins?', cid)
                npcHandler.topic[cid] = 2
                return true
            else
                npcHandler:say('How many tibia coins would you like to purchase?', cid)
                npcHandler.topic[cid] = 1
                return true
            end

        if not isValidMoney(count[cid]) then
            npcHandler:say('I\'m sorry. I can\'t do that.', cid)
            npcHandler.topic[cid] = 0
            return false
        end
    elseif npcHandler.topic[cid] == 1 then
        count[cid] = getMoneyCount(msg)
        amount = getMoneyCount(msg)
        cost = amount * ratio
    
        if isValidMoney(count[cid]) then
                npcHandler:say('Would you really like to purchase ' .. count[cid] .. ' tibia coins for ' .. cost .. ' gold coins?', cid)
                npcHandler.topic[cid] = 2
            return true
        else
            npcHandler:say('You do not have enough money {in your bank} to make this exchange.', cid)
            npcHandler.topic[cid] = 0
            return true
        end
    elseif npcHandler.topic[cid] == 2 then
        if msgcontains(msg, 'yes') then

            if not player:removeMoneyNpc(cost) then
                npcHandler:say('You do not have enough money {in your bank} to make this exchange.', cid)
                npcHandler.topic[cid] = 0
                return true
            end
            if player:setCoinsBalance(player:getCoinsBalance() + amount) then
                npcHandler:say('Alright, we have added the ' .. count[cid] .. ' tibia coins to your {balance}.', cid)
            else
                npcHandler:say('You do not have enough money {in your bank} to make this exchange.', cid)
            end
        elseif msgcontains(msg, 'no') then
            npcHandler:say('Is there something else I can do for you?', cid)
        end
        npcHandler.topic[cid] = 0
    return true







        
    
    end
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top