Ir para conteúdo

Featured Replies

Postado
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local itemId = 2160

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 onCreatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid) -- Obter o objeto Player

    if msgcontains(msg, "serial") then
        npcHandler:say("Eu coloco um identificador em seu item. Cobro pelo serviço um valor de 1 crystal coin. Deseja colocar em algum item?", cid)
        talkState[cid] = 0
    elseif talkState[cid] == 0 and msgcontains(msg, 'yes') then
        npcHandler:say("Qual item você está interessado em colocar o serial? Lembrando que isso não garante que o item pertence a você para sempre, se você perder o item a responsabilidade será sua e não da Equipe.", cid)
        talkState[cid] = 1
    elseif talkState[cid] == 1 then
        local item = player:getItemById(itemId, true) -- Procurar pelo item no inventário do jogador
        if item and item:isItem() then
            if player:removeItem(2160, 1) then -- Remover 1 Crystal Coin do jogador
                local description = "Este item foi registrado pelo jogador " .. player:getName() .. " no dia " .. os.date("%d/%m/%Y - %X") .. " Serial: " .. player:getGuid() .. "."
                local itemText = item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
                if itemText and itemText ~= "" then
                    itemText = itemText .. "\n" .. description
                else
                    itemText = description
                end
                item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, itemText)
                npcHandler:say("Aqui está o seu item. Deseja registrar outro?", cid)
            else
                npcHandler:say("Você não tem a quantidade necessária para registrar esse item.", cid)
            end
        else
            npcHandler:say("Você não possui este item.", cid)
        end
        talkState[cid] = 0
    else
        npcHandler:say("Pena que você não quer. Volte aqui quando estiver interessado.", cid)
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSayCallback)
npcHandler:addModule(FocusModule:new())

e Assim?

  • Respostas 6
  • Visualizações 358
  • Created
  • Última resposta

Top Posters In This Topic

Postado
  • Autor
On 5/27/2023 at 11:20 PM, Ruyzin Pikatxufly said:

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local itemId = 2160

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 onCreatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid) -- Obter o objeto Player

    if msgcontains(msg, "serial") then
        npcHandler:say("Eu coloco um identificador em seu item. Cobro pelo serviço um valor de 1 crystal coin. Deseja colocar em algum item?", cid)
        talkState[cid] = 0
    elseif talkState[cid] == 0 and msgcontains(msg, 'yes') then
        npcHandler:say("Qual item você está interessado em colocar o serial? Lembrando que isso não garante que o item pertence a você para sempre, se você perder o item a responsabilidade será sua e não da Equipe.", cid)
        talkState[cid] = 1
    elseif talkState[cid] == 1 then
        local item = player:getItemById(itemId, true) -- Procurar pelo item no inventário do jogador
        if item and item:isItem() then
            if player:removeItem(2160, 1) then -- Remover 1 Crystal Coin do jogador
                local description = "Este item foi registrado pelo jogador " .. player:getName() .. " no dia " .. os.date("%d/%m/%Y - %X") .. " Serial: " .. player:getGuid() .. "."
                local itemText = item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
                if itemText and itemText ~= "" then
                    itemText = itemText .. "\n" .. description
                else
                    itemText = description
                end
                item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, itemText)
                npcHandler:say("Aqui está o seu item. Deseja registrar outro?", cid)
            else
                npcHandler:say("Você não tem a quantidade necessária para registrar esse item.", cid)
            end
        else
            npcHandler:say("Você não possui este item.", cid)
        end
        talkState[cid] = 0
    else
        npcHandler:say("Pena que você não quer. Volte aqui quando estiver interessado.", cid)
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSayCallback)
npcHandler:addModule(FocusModule:new())

e Assim?

Bom dia não deu certo o item continua sem o registro 

 

09:58 You see a rainbow shield (Def:30).
It can only be wielded properly by knights of level 100 or higher.

 

eu uso tfs 1.4 será que precisa de algum script de look ? 

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.7k

Informação Importante

Confirmação de Termo