Ir para conteúdo

Featured Replies

Postado

Adicionou a função doPlayerAddPoints corretamente? Eu tinha testado esse script e funciona normalmente o sell.

Sobre a edição, tente assim:

local t = {
[10310] = {price = 25, sellprice = 50},
[6512] = {price = 100, sellprice = 200},
[8926] = {price = 200, sellprice = 400},
[2390] = {price = 200, sellprice = 400},
[7450] = {price = 200, sellprice = 400},
[7424] = {price = 200, sellprice = 400},
[7438] = {price = 100, sellprice = 200},
[2352] = {price = 100, sellprice = 200},
[7440] = {price = 30, sellprice = 60},
[9693] = {price = 8, sellprice = 16}
}

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 onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
        if t[item] and getPoints(cid) < t[item].price then
            selfSay("Você não tem "..t[item].price.." p points.", cid)
        else
            doPlayerAddItem(cid, item)
            doPlayerRemovePoints(cid, t[item].price)
            selfSay("Aqui está seu item.", cid)
        end
       return true
    end
 
    local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks)
        if getPoints(cid) >= 0 then
            doPlayerRemoveItem(cid, item, 1)
            doPlayerAddPoints(cid, t[item].sellprice)
            selfSay("Você vendeu o item por "..t[item].price.." p points.", cid)
        end
       return true
    end
 
    if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
        for var, ret in pairs(t) do
            table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = ret.price, name = getItemNameById(var)})
        end
       openShopWindow(cid, shopWindow, onBuy, onSell)
    end
   return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new()) 

  • Respostas 17
  • Visualizações 1k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Testa: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHand

  • Testa ai: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcH

  • Configurei pra você escolher os points ali na config, testa ai: Global Events:   CreatureEvents:

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo