Ir para conteúdo

Featured Replies

Postado

Ola,

 

Gostaria de pedir o seguintes NPC's.

 

- NPC Travel Especial: que teletransporta o char só se tiver a storage.

 

- NPC Trade Especial: que troca um item e da em seguida a storage para que ele não troque novamente o item

 

- NPC Quest Especial: Que pega um item e da storage.

 

Se for possível favor ou tiver que possa me passar agradeço.

 

Para versão 8.54.

Resolvido por Wakon

Ir para solução
  • Respostas 9
  • Visualizações 1.2k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Não testei os script's, caso tenha algum erro me avise. - NPC Travel Especial: que teletransporta o char só se tiver a storage:   - NPC Trade Especial: que troca um item e da em seguida a st

Postado
  • Administrador

Travel por storage.

Mostrar conteúdo oculto

Em npc/scripts crie um arquivo com qual quer nome.lua e adicione

Scripts npc trade

Mostrar conteúdo oculto
local id1 = 9533  --id do item a ser trocado
local id2 = 9533  --id do item a ser recebido
local stor = 34444 -- storage que o npc vai adr pelo item
local quantidade = 150 -- quantos itens player deve ter para trocar por storage 
local palavra = "trocar" --palavra chave pra falar com o npc pra trocar a storage
local mensagem = "BLABLABLALBALBALBLALBALBLA." -- a mensagem que deve ser dita se ele não tiver o item
 
 
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 playerHaveItems(cid, itemid)
local items = type(itemid) == "table" and itemid or {itemid}
for i = 1, #items do
if getPlayerItemCount(cid, items) <= 0 then
return false
end
end
return true
end
 
function doPlayerRemoveItems(cid, itemid, count)
local items = type(itemid) == "table" and itemid or {itemid}
for i = 1, #items do
doPlayerRemoveItem(cid, items, count ~= nil and count or 1)
end
return nil
end
 
function creatureSayCallback(cid, type, msg)
 
if(not npcHandler:isFocused(cid)) then
return false
end
 
if msgcontains(msg, palavra) then
if playerHaveItems(cid, {id1}) then
doPlayerRemoveItems(cid, {id1}, quantidade)
doPlayerAddItems(cid, {id2}, quantidade)
setPlayerStorageValue(cid, stor, 1)
else
selfSay(mensagem)
end
end 
return true
 
endnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Npc que pega item

Mostrar conteúdo oculto

Se der algum erro reporte aqui no topico.

Postado
  • Autor
Estão dando erro os 3, 2 da o seguinte erros
 
[04/05/2015 20:13:26] [Error - LuaScriptInterface::loadFile] data/npc/scripts/Boater.lua:52: 'end' expected (to close 'function' at line 36) near 'endnpcHandler'
[04/05/2015 20:13:26] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Boater.lua
[04/05/2015 20:13:26] data/npc/scripts/Boater.lua:52: 'end' expected (to close 'function' at line 36) near 'endnpcHandler'
 
[04/05/2015 20:13:26] [Error - Npc interface] 
[04/05/2015 20:13:26] data/npc/scripts/Johny.lua
[04/05/2015 20:13:26] Description: 
[04/05/2015 20:13:26] (luaGetThing) Thing not found
 
[04/05/2015 20:13:26] [Error - Npc interface] 
[04/05/2015 20:13:26] data/npc/scripts/Johny.lua
[04/05/2015 20:13:26] Description: 
[04/05/2015 20:13:26] data/lib/050-function.lua:299: attempt to index a boolean value
[04/05/2015 20:13:26] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Johny.lua
[04/05/2015 20:13:26] data/npc/scripts/Boater.lua:52: 'end' expected (to close 'function' at line 36) near 'endnpcHandler'
 
 
O terceiro não responde
 
10mmna8.jpg
Postado
  • Solução

Não testei os script's, caso tenha algum erro me avise.

- NPC Travel Especial: que teletransporta o char só se tiver a storage:

Mostrar conteúdo oculto

local position = {x = 160, y = 54, z = 7} -- Posição que irá levar.
local storage = {55509, 1} -- Storage necessária {key, value}.

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
    msg = msg:lower();
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if msgcontains(msg, 'travel') or msgcontains(msg, 'passage') then
       selfSay('Posso te levar até LOCAL, deseja ir?', cid)
       talkState[talkUser] = 1
    elseif msgcontains(msg, 'yes') then
        if talkState[talkUser] == 1 then
           if getPlayerStorageValue(cid, storage[1]) == storage[2] then
             doTeleportThing(cid, position)
             doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
             selfSay('Até mais...', cid)
           else
             selfSay('Você não tem permissão para acessar esse local.', cid)
             talkState[talkUser] = 0
           end
        end
    elseif msgcontains(msg, 'no') then
        if talkState[talkUser] == 1 then
           selfSay('Ok...', cid)
           talkState[talkUser] = 0
        end
    end
end    

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

 

- NPC Trade Especial: que troca um item e da em seguida a storage para que ele não troque novamente o item:

Mostrar conteúdo oculto

local t = {
    ineed = {2160, 10}, -- Item necessário e quantia {itemID, quantia}.
    ireward = 2465, -- Item que irá receber.
    storage = {55510, 1} -- Storage para não trocar novamente {key, value}.
}

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
    msg = msg:lower();
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if msgcontains(msg, 'change') or msgcontains(msg, 'trocar') then
       selfSay('Eu posso trocar '..t.ineed[2]..' '..getItemNameById(t.ineed[1])..' por um '..getItemNameById(t.ireward)..', deseja trocar?', cid)
       talkState[talkUser] = 1
    elseif msgcontains(msg, 'yes') then
        if talkState[talkUser] == 1 then
           if getPlayerStorageValue(cid, t.storage[1]) < t.storage[2] then
               if doPlayerRemoveItem(cid, t.ineed[1], t.ineed[2]) == TRUE then
                  doPlayerAddItem(cid, t.ireward, 1)
                  selfSay('Aqui está, obrigado', cid)
                  setPlayerStorageValue(cid, t.storage[1], t.storage[2])
                  talkState[talkUser] = 0
               else
                  selfSay('Você não tem os itens necessários.', cid)
                  talkState[talkUser] = 0
               end
           else
             selfSay('Você não pode trocar novamente.', cid)
             talkState[talkUser] = 0
           end
        end
    elseif msgcontains(msg, 'no') then
        if talkState[talkUser] == 1 then
           selfSay('Ok...', cid)
           talkState[talkUser] = 0
        end
    end
end    

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

 

- NPC Quest Especial: Que pega um item e da storage:

Mostrar conteúdo oculto

local t = {
    ineed = {2160, 1}, -- Item necessário e quantia {itemID, quantia}.
    storage = {55511, 1} -- Storage para não trocar novamente {key, value}.
}

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
    msg = msg:lower();
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if msgcontains(msg, 'mission') or msgcontains(msg, 'quest') then
       selfSay('Posso lhe oferecer acesso a uma área por '..t.ineed[2]..' '..getItemNameById(t.ineed[1])..', deseja fazer essa troca?', cid)
       talkState[talkUser] = 1
    elseif msgcontains(msg, 'yes') then
        if talkState[talkUser] == 1 then
           if getPlayerStorageValue(cid, t.storage[1]) < t.storage[2] then
               if doPlayerRemoveItem(cid, t.ineed[1], t.ineed[2]) == TRUE then
                  selfSay('Agora você tem acesso a área proibida!', cid)
                  setPlayerStorageValue(cid, t.storage[1], t.storage[2])
                  talkState[talkUser] = 0
               else
                  selfSay('Você não tem os itens necessários.', cid)
                  talkState[talkUser] = 0
               end
           else
             selfSay('Você já tem acesso a área proibida.', cid)
             talkState[talkUser] = 0
           end
        end
    elseif msgcontains(msg, 'no') then
        if talkState[talkUser] == 1 then
           selfSay('Ok...', cid)
           talkState[talkUser] = 0
        end
    end
end    

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

Editado por Wakon (veja o histórico de edições)

Postado
  • Autor

Wakon,

 

NPC Quest da o seguinte erro

 

[05/05/2015 15:08:58] [Error - Npc interface] 
[05/05/2015 15:08:58] data/npc/scripts/mayor2.lua:onCreatureSay
[05/05/2015 15:08:58] Description: 
[05/05/2015 15:08:58] data/lib/050-function.lua:287: attempt to index a boolean value
[05/05/2015 15:08:58] stack traceback:
[05/05/2015 15:08:58] data/lib/050-function.lua:287: in function 'getItemNameById'
[05/05/2015 15:08:58] data/npc/scripts/mayor2.lua:26: in function 'callback'
[05/05/2015 15:08:58] data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
[05/05/2015 15:08:58] data/npc/scripts/mayor2.lua:14: in function <data/npc/scripts/mayor2.lua:14>
 
- Quando vai falar Trocar.
 
- Trade Especial
 
[05/05/2015 15:11:29] [Error - Npc interface] 
[05/05/2015 15:11:29] data/npc/scripts/Boater.lua:onCreatureSay
[05/05/2015 15:11:29] Description: 
[05/05/2015 15:11:29] data/npc/scripts/Boater.lua:25: attempt to concatenate field 'ineed' (a table value)
[05/05/2015 15:11:29] stack traceback:
[05/05/2015 15:11:29] data/npc/scripts/Boater.lua:25: in function 'callback'
[05/05/2015 15:11:29] data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
[05/05/2015 15:11:29] data/npc/scripts/Boater.lua:13: in function <data/npc/scripts/Boater.lua:13>
 
- Não deu para testar o outro por causa que precisava dos dois...

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