Ir para conteúdo
  • Cadastre-se

(Resolvido)Ajuda Script de npc de promotion Diferente


Ir para solução Resolvido por Storm,

Posts Recomendados

Se alguem poder fazer essa script para mim eu agradeço é  mais o menos assim

é normalmente igual ao promotion so que tipo assim

o player fala Hi o npc fala "Voce quer fazer super promotion ?" ai o player fala yes ,

ai o npc vai pedir X item com X quantidade , o npc ira remover o x item do player e da a ele

a super promotion, o npc vai trocar a vocação dele tipo

quem for vocation 255 e falar com o npc ganha a vocation 256, com X looktype e ganha mais 3000 de hp e mp !

 

Agradeço a quem conseguir

Link para o post
Compartilhar em outros sites
3 minutos atrás, Jociel disse:

Se alguem poder fazer essa script para mim eu agradeço é  mais o menos assim

é normalmente igual ao promotion so que tipo assim

o player fala Hi o npc fala "Voce quer fazer super promotion ?" ai o player fala yes ,

ai o npc vai pedir X item com X quantidade , o npc ira remover o x item do player e da a ele

a super promotion, o npc vai trocar a vocação dele tipo

quem for vocation 255 e falar com o npc ganha a vocation 256, com X looktype e ganha mais 3000 de hp e mp !

 

Agradeço a quem conseguir


Apenas essa vocation 255 conseguiria fazer a super promotion ou seria por uma tabela ?

Link para o post
Compartilhar em outros sites

@Jociel

local t  = {

[255] = {256, 50, 3000, 3000} -- {old vocation} = {New vocation, looktype, life extra, mana extra} 

}

local itemid, count = 2150 , 5 -- ID do item que precisa 

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)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local a = t[getPlayerVocation(cid)]

      if msgcontains(msg, "yes") then
         if a then
            if doPlayerRemoveItem(cid, itemid, count) then
               doPlayerSetVocation(cid, a[1])
               doSetCreatureOutfit(cid, a[2], -1)
               setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + a[3])
               setCreatureMaxMana(cid, getCreatureMaxMana(cid) + a[4])
               selfSay("Congratulations!!", cid)
            else
                selfSay("Sua vocation não tem promotion", cid)
            end
         else
             selfSay("Sua vocation não tem promotion", cid)
         end 

      end
return TRUE
end

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

 

Link para o post
Compartilhar em outros sites

@Sttorm Funcionou a parte de trocar a vocation porem nao troca a looktype deu o seguinte error:

 

[25/05/2018 19:41:26] [Error - Npc interface] 
[25/05/2018 19:41:26] data/npc/scripts/mysticSystem.lua:onCreatureSay
[25/05/2018 19:41:26] Description: 
[25/05/2018 19:41:26] attempt to index a number value
[25/05/2018 19:41:26] stack traceback:
[25/05/2018 19:41:26]     [C]: in function 'doSetCreatureOutfit'
[25/05/2018 19:41:26]     data/npc/scripts/mysticSystem.lua:29: in function 'callback'
[25/05/2018 19:41:26]     data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[25/05/2018 19:41:26]     data/npc/scripts/mysticSystem.lua:18: in function <data/npc/scripts/mysticSystem.lua:18>

 

 

Editado por Jociel (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

@Sttorm 

na tabela ta tudo certo eu fiz 2 vocation ficou assim 

local t  = {

[569] = {570, 1006, 3000, 3000}, -- {old vocation} = {New vocation, looktype, life extra, mana extra} 
[174] = {571, 50, 3000, 3000}

}

testei o npc com as duas vocation e ele me da a mesma looktype no caso a looktype que ele me da e uma que eu nunca vi

Link para o post
Compartilhar em outros sites

@Jociel Tenta assim

local t  = {

[255] = {256, 50, 3000, 3000} -- {old vocation} = {New vocation, looktype, life extra, mana extra} 

}

local itemid, count = 2150 , 5 -- ID do item que precisa 

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)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local a = t[getPlayerVocation(cid)]
local outfit = {lookType = a[2]}

      if msgcontains(msg, "yes") then
         if a then
            if doPlayerRemoveItem(cid, itemid, count) then
               doPlayerSetVocation(cid, a[1])
               doCreatureChangeOutfit(cid, outfit)
               setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + a[3])
               setCreatureMaxMana(cid, getCreatureMaxMana(cid) + a[4])
               selfSay("Congratulations!!", cid)
            else
                selfSay("Sua vocation não tem promotion", cid)
            end
         else
             selfSay("Sua vocation não tem promotion", cid)
         end 

      end
return TRUE
end

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

 

Link para o post
Compartilhar em outros sites
27 minutos atrás, Jociel disse:

@Sttorm 

se nao for pedi demais poderia fazer essa promotion em tal LVL:

e depois que fizesse desse kick no player so para fechar em chave de ouro

local t  = {

[255] = {256, 50, 3000, 3000} -- {old vocation} = {New vocation, looktype, life extra, mana extra} 

}

local itemid, count = 2150 , 5 -- ID do item que precisa
local level = 100 -- level necessario para a promotion 

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)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local a = t[getPlayerVocation(cid)]
local outfit = {lookType = a[2]}

      if msgcontains(msg, "yes") then
         if a then
            if getPlayerLevel(cid) >= level then 
               if doPlayerRemoveItem(cid, itemid, count) then
                  doPlayerSetVocation(cid, a[1])
                  doCreatureChangeOutfit(cid, outfit)
                  setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + a[3])
                  setCreatureMaxMana(cid, getCreatureMaxMana(cid) + a[4])
                  addEvent(doRemoveCreature, 1000, cid)
               else
                   selfSay("voce nao tem o item necessario", cid)
               end
            else
                selfSay("Voce nao tem o level necessario", cid)
            end
         else
             selfSay("Sua vocation não tem promotion", cid)
         end
      end
return TRUE
end

 

Link para o post
Compartilhar em outros sites
14 horas atrás, Sttorm disse:

local t  = {

[255] = {256, 50, 3000, 3000} -- {old vocation} = {New vocation, looktype, life extra, mana extra} 

}

local itemid, count = 2150 , 5 -- ID do item que precisa
local level = 100 -- level necessario para a promotion 

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)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local a = t[getPlayerVocation(cid)]
local outfit = {lookType = a[2]}

      if msgcontains(msg, "yes") then
         if a then
            if getPlayerLevel(cid) >= level then 
               if doPlayerRemoveItem(cid, itemid, count) then
                  doPlayerSetVocation(cid, a[1])
                  doCreatureChangeOutfit(cid, outfit)
                  setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + a[3])
                  setCreatureMaxMana(cid, getCreatureMaxMana(cid) + a[4])
                  addEvent(doRemoveCreature, 1000, cid)
               else
                   selfSay("voce nao tem o item necessario", cid)
               end
            else
                selfSay("Voce nao tem o level necessario", cid)
            end
         else
             selfSay("Sua vocation não tem promotion", cid)
         end
      end
return TRUE
end

 

quando o player conversa com o npc da o seguinte error

[26/05/2018 11:07:43] [Error - Npc interface] 
[26/05/2018 11:07:43] data/npc/scripts/mysticSystem.lua:onCreatureSay
[26/05/2018 11:07:43] Description: 
[26/05/2018 11:07:43] data/npc/scripts/mysticSystem.lua:25: attempt to index local 'a' (a nil value)
[26/05/2018 11:07:43] stack traceback:
[26/05/2018 11:07:43]     data/npc/scripts/mysticSystem.lua:25: in function 'callback'
[26/05/2018 11:07:43]     data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[26/05/2018 11:07:43]     data/npc/scripts/mysticSystem.lua:19: in function <data/npc/scripts/mysticSystem.lua:19>

 

e quando o player nao tem a vocation o npc nao fala nada

Link para o post
Compartilhar em outros sites

@Jociel 

local t  = {

[255] = {256, 50, 3000, 3000} -- {old vocation} = {New vocation, looktype, life extra, mana extra} 

}

local itemid, count = 2150 , 5 -- ID do item que precisa
local level = 100 -- level necessario para a promotion 

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)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local a = t[getPlayerVocation(cid)]
local outfit = {lookType = a[2]}

      if msgcontains(msg, "yes") then
         if a then
            if getPlayerLevel(cid) >= level then 
               if doPlayerRemoveItem(cid, itemid, count) then
                  doPlayerSetVocation(cid, a[1])
                  doCreatureChangeOutfit(cid, outfit)
                  setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + a[3])
                  setCreatureMaxMana(cid, getCreatureMaxMana(cid) + a[4])
                  addEvent(doRemoveCreature, 1000, cid)
               else
                   selfSay('Voce precisa de '.. count ..' '.. getItemInfo(itemid).name ..' para fazer a super promotion.', cid)
               end
            else
                selfSay('Você precisa estar no level '.. level ..'.', cid)
            end
         else
             selfSay('Sua vocation não tem promotion disponivel', cid)
         end   
      return true
      end
end                
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Link para o post
Compartilhar em outros sites

@Sttorm o erro persiste

[26/05/2018 11:28:38] [Error - Npc interface] 
[26/05/2018 11:28:38] data/npc/scripts/mysticSystem.lua:onCreatureSay
[26/05/2018 11:28:38] Description: 
[26/05/2018 11:28:38] data/npc/scripts/mysticSystem.lua:25: attempt to index local 'a' (a nil value)
[26/05/2018 11:28:38] stack traceback:
[26/05/2018 11:28:38]     data/npc/scripts/mysticSystem.lua:25: in function 'callback'
[26/05/2018 11:28:38]     data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[26/05/2018 11:28:38]     data/npc/scripts/mysticSystem.lua:19: in function <data/npc/scripts/mysticSystem.lua:19>

Link para o post
Compartilhar em outros sites
  • Solução

@Jociel

local t  = {

[255] = {256, 50, 3000, 3000} -- {old vocation} = {New vocation, looktype, life extra, mana extra} 

}

local itemid, count = 2150 , 5 -- ID do item que precisa
local level = 100 -- level necessario para a promotion 

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)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local a = t[getPlayerVocation(cid)]

      if msgcontains(msg, "yes") then
         if a then
            if getPlayerLevel(cid) >= level then 
               if doPlayerRemoveItem(cid, itemid, count) then
local outfit = {lookType = a[2]}
                  doPlayerSetVocation(cid, a[1])
                  doCreatureChangeOutfit(cid, outfit)
                  setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + a[3])
                  setCreatureMaxMana(cid, getCreatureMaxMana(cid) + a[4])
                  addEvent(doRemoveCreature, 1000, cid)
               else
                   selfSay('Voce precisa de '.. count ..' '.. getItemInfo(itemid).name ..' para fazer a super promotion.', cid)
               end
            else
                selfSay('Você precisa estar no level '.. level ..'.', cid)
            end
         else
             selfSay('Sua vocation não tem promotion disponivel', cid)
         end   
      return true
      end
end                
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo