Ir para conteúdo

Featured Replies

Postado
  • Solução

Sim, a versão era diferente. Usa assim:

 

Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)


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 storage = 56790
local item = {10581, 30} --id do item, quantidade

function creatureSayCallback(cid, type, msg)
    local msg, player = string.lower(msg), Player(cid)
    if not npcHandler:isFocused(cid) then
        if isInArray({"hi", "hello"}, msg) then
            npcHandler:addFocus(cid)
            if player:getStorageValue(storage) == -1 then
                npcHandler:say("Hi, ".. player:getName().."! I can give you the permission to {enter} at Lost Souls' City.", cid)
                npcHandler.topic[cid] = 1
            else
                npcHandler:say("You already have my permission to enter.", cid)
                npcHandler.topic[cid] = 0
                npcHandler:releaseFocus(cid)
            end
        else
            return false 
        end
    elseif msgcontains(msg, "enter") and npcHandler.topic[cid] == 1 then
        npcHandler:say("I need ".. item[2] .. " " .. getItemName(item[1])..". Do you have it?", cid)
         npcHandler.topic[cid] = 2
    elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
        if player:removeItem(item[1], item[2]) then
            player:setStorageValue(storage, 1)
            npcHandler:say("Ok, now you can enter.", cid)
             npcHandler.topic[cid] = 0
        else
            npcHandler:say("Sorry but you don't have the items I need.", cid)
             npcHandler.topic[cid] = 0
        end
    elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 2 then
        npcHandler:say("Ok, maybe on the next time.", cid)
         npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "bye") then
        npcHandler:say("Bye.", cid)
        npcHandler:releaseFocus(cid)
    else
        npcHandler:say("What?", cid)
         npcHandler.topic[cid] = 0
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

 

 

Spoiler

local storage = 56790

function onStepIn(creature, item, position, fromPosition)
if not creature:isPlayer() then return true end
if creature:getStorageValue(storage) == -1 then
    creature:sendCancelMessage("You should pay to enter.")
    creature:teleportTo(fromPosition)
end
	return true
end

 

 

<movevent event="StepIn" actionid="ACTION_ID_DO_PISO" script="tilepermission.lua" />

Contato:

 

  • Respostas 7
  • Visualizações 887
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Sim, a versão era diferente. Usa assim:       <movevent event="StepIn" actionid="ACTION_ID_DO_PISO" script="tilepermission.lua" />

Posted Images

  • 2 years later...

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