Ayuda con el npc King Tibianus version 8.60 Tfs 0.3.6

Xanadu123

Miembro
Mensajes
10
Puntos
78
Hola, tengo un problema con el npc king Tibianus, solo me da promotion, pero me gustaría añadirle para que me dé premium. ¿Cómo puedo hacerlo? ¿Alguien podría ayudarme con este problema, por favor? Es para TFS 0.3.6 versión 8.60.

Código:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="King Tibianus" script="data/npc/scripts/King Tibianus.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="332" head="21" body="87" legs="107" feet="95" addons="0"/>
<parameters>
       <parameter key="message_greet" value="I greet thee, my loyal subject |PLAYERNAME|."/>
        <parameter key="message_farewell" value="Good bye, |PLAYERNAME|"/>
        <parameter key="message_walkaway" value="Good bye, |PLAYERNAME|" />
        <parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="job;king;" />
        <parameter key="keyword_reply1" value="I am your sovereign, King Tibianus III, and it's my duty to uphold justice and provide guidance for my subjects." />
         <parameter key="keyword_reply2" value="I am the king, so watch what you say!" />
    </parameters>

</npc>

Código:
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 node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be promoted in your vocation for 20000 gold?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
--[[
local node2 = keywordHandler:addKeyword({'epic'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can epicize you for 200000 gold coins. Do you want me to epicize you?'})
    node2:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 200000, level = 120, promotion = 2, text = 'Congratulations! You are now epicized.'})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
]]--

npcHandler:addModule(FocusModule:new())
 
Solución
me sale error en la consola bro

Ver archivo adjunto 5478
Código:
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, t, msg) npcHandler:onCreatureSay(cid, t, msg) end
function onThink()                  npcHandler:onThink()                  end

local PREMIUM_PRICES = {
  [30] = 60000,
  [60] = 110000
}

local function sayPrice(cid, message, keywords, parameters, node)
  local days = parameters.days
  local price = PREMIUM_PRICES[days]
  npcHandler:say(days .. " days cost " .. price .. "...
Hola, tengo un problema con el npc king Tibianus, solo me da promotion, pero me gustaría añadirle para que me dé premium. ¿Cómo puedo hacerlo? ¿Alguien podría ayudarme con este problema, por favor? Es para TFS 0.3.6 versión 8.60.

Código:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="King Tibianus" script="data/npc/scripts/King Tibianus.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="332" head="21" body="87" legs="107" feet="95" addons="0"/>
<parameters>
       <parameter key="message_greet" value="I greet thee, my loyal subject |PLAYERNAME|."/>
        <parameter key="message_farewell" value="Good bye, |PLAYERNAME|"/>
        <parameter key="message_walkaway" value="Good bye, |PLAYERNAME|" />
        <parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="job;king;" />
        <parameter key="keyword_reply1" value="I am your sovereign, King Tibianus III, and it's my duty to uphold justice and provide guidance for my subjects." />
         <parameter key="keyword_reply2" value="I am the king, so watch what you say!" />
    </parameters>

</npc>

Código:
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 node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be promoted in your vocation for 20000 gold?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
--[[
local node2 = keywordHandler:addKeyword({'epic'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can epicize you for 200000 gold coins. Do you want me to epicize you?'})
    node2:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 200000, level = 120, promotion = 2, text = 'Congratulations! You are now epicized.'})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
]]--

npcHandler:addModule(FocusModule:new())

Hola, creo que en las viejas se utiliza doPlayerAddPremiumDays, a verificar, no me acuerdo bien, se que en las nuevas usamos player:addPremium por ejemplo pero en caso, utiliza o busca esa palabra en tu servidor para ver si la usas.
Dile premium y haber si funciona

Código:
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, t, msg) npcHandler:onCreatureSay(cid, t, msg) end
function onThink()                  npcHandler:onThink()                  end

--- Dias / Precio
local PREMIUM_PRICES = {
  [30] = 60000,
  [60] = 110000,
}

-- Agregar premium utilizando doPlayerAddPremium
local function addPremiumAction(cid, message, keywords, parameters, node)
  local days = parameters.days
  local price = PREMIUM_PRICES[days]
  if not price then
    npcHandler:say("Something went wrong with the selected duration.", cid)
    return true
  end

  if not doPlayerRemoveMoney(cid, price) then
    npcHandler:say("You don't have enough gold. You need ".. price .." gold coins.", cid)
    return true
  end

  doPlayerAddPremiumDays(cid, days)  -- TFS 0.3.6 API
  npcHandler:say("Done! I've added ".. days .." premium days to your account.", cid)
  return true
end

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be promoted in your vocation for 20000 gold?'})
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
node1:addChildKeyword({'no'},  StdModule.say,          {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

--- Preguntar por premmy
local premiumRoot = keywordHandler:addKeyword({'premium'}, StdModule.say, {
  npcHandler = npcHandler,
  onlyFocus = true,
  text = "I can add premium days. Do you want {30} or {60} days?"
})

-- 30 Dias
local prem30 = premiumRoot:addChildKeyword({'30'}, StdModule.say, {
  npcHandler = npcHandler,
  onlyFocus = true,
  text = function(cid)
    return "30 days cost ".. PREMIUM_PRICES[30] .." gold coins. Do you want it?"
  end
})
prem30:addChildKeyword({'yes'}, addPremiumAction, {npcHandler = npcHandler, days = 30})
prem30:addChildKeyword({'no'},  StdModule.say,    {npcHandler = npcHandler, onlyFocus = true, text = "Alright, maybe next time.", reset = true})

-- 60 Dias
local prem60 = premiumRoot:addChildKeyword({'60'}, StdModule.say, {
  npcHandler = npcHandler,
  onlyFocus = true,
  text = function(cid)
    return "60 days cost ".. PREMIUM_PRICES[60] .." gold coins. Do you want it?"
  end
})
prem60:addChildKeyword({'yes'}, addPremiumAction, {npcHandler = npcHandler, days = 60})
prem60:addChildKeyword({'no'},  StdModule.say,    {npcHandler = npcHandler, onlyFocus = true, text = "Alright, maybe next time.", reset = true})

npcHandler:addModule(FocusModule:new())



Y luego para facilitar puedes agregar un texto, para que sepan que hace el npc:
Código:
<parameter key="message_greet" value="I greet thee, my loyal subject |PLAYERNAME|. Do you want a {promotion} or {premium} ?"/>
 
me sale error en la consola bro

Ver archivo adjunto 5478
Código:
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, t, msg) npcHandler:onCreatureSay(cid, t, msg) end
function onThink()                  npcHandler:onThink()                  end

local PREMIUM_PRICES = {
  [30] = 60000,
  [60] = 110000
}

local function sayPrice(cid, message, keywords, parameters, node)
  local days = parameters.days
  local price = PREMIUM_PRICES[days]
  npcHandler:say(days .. " days cost " .. price .. " gold coins. Do you want it?", cid)
  return true
end

local function addPremiumAction(cid, message, keywords, parameters, node)
  local days  = parameters.days
  local price = PREMIUM_PRICES[days]
  if not price then
    npcHandler:say("Something went wrong with the selected duration.", cid)
    return true
  end

  if not doPlayerRemoveMoney(cid, price) then
    npcHandler:say("You don't have enough gold. You need " .. price .. " gold coins.", cid)
    return true
  end

  doPlayerAddPremiumDays(cid, days)
  npcHandler:say("Done! I've added " .. days .. " premium days to your account.", cid)
  return true
end

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be promoted in your vocation for 20000 gold?'})
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
node1:addChildKeyword({'no'},  StdModule.say,          {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

local premiumRoot = keywordHandler:addKeyword({'premium'}, StdModule.say, {
  npcHandler = npcHandler,
  onlyFocus = true,
  text = "I can add premium days. Do you want {30} or {60} days?"
})

local prem30 = premiumRoot:addChildKeyword({'30'}, sayPrice, {npcHandler = npcHandler, days = 30})
prem30:addChildKeyword({'yes'}, addPremiumAction, {npcHandler = npcHandler, days = 30})
prem30:addChildKeyword({'no'},  StdModule.say,    {npcHandler = npcHandler, onlyFocus = true, text = "Alright, maybe next time.", reset = true})

local prem60 = premiumRoot:addChildKeyword({'60'}, sayPrice, {npcHandler = npcHandler, days = 60})
prem60:addChildKeyword({'yes'}, addPremiumAction, {npcHandler = npcHandler, days = 60})
prem60:addChildKeyword({'no'},  StdModule.say,    {npcHandler = npcHandler, onlyFocus = true, text = "Alright, maybe next time.", reset = true})

npcHandler:addModule(FocusModule:new())
 
Código:
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, t, msg) npcHandler:onCreatureSay(cid, t, msg) end
function onThink()                  npcHandler:onThink()                  end

local PREMIUM_PRICES = {
  [30] = 60000,
  [60] = 110000
}

local function sayPrice(cid, message, keywords, parameters, node)
  local days = parameters.days
  local price = PREMIUM_PRICES[days]
  npcHandler:say(days .. " days cost " .. price .. " gold coins. Do you want it?", cid)
  return true
end

local function addPremiumAction(cid, message, keywords, parameters, node)
  local days  = parameters.days
  local price = PREMIUM_PRICES[days]
  if not price then
    npcHandler:say("Something went wrong with the selected duration.", cid)
    return true
  end

  if not doPlayerRemoveMoney(cid, price) then
    npcHandler:say("You don't have enough gold. You need " .. price .. " gold coins.", cid)
    return true
  end

  doPlayerAddPremiumDays(cid, days)
  npcHandler:say("Done! I've added " .. days .. " premium days to your account.", cid)
  return true
end

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be promoted in your vocation for 20000 gold?'})
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
node1:addChildKeyword({'no'},  StdModule.say,          {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

local premiumRoot = keywordHandler:addKeyword({'premium'}, StdModule.say, {
  npcHandler = npcHandler,
  onlyFocus = true,
  text = "I can add premium days. Do you want {30} or {60} days?"
})

local prem30 = premiumRoot:addChildKeyword({'30'}, sayPrice, {npcHandler = npcHandler, days = 30})
prem30:addChildKeyword({'yes'}, addPremiumAction, {npcHandler = npcHandler, days = 30})
prem30:addChildKeyword({'no'},  StdModule.say,    {npcHandler = npcHandler, onlyFocus = true, text = "Alright, maybe next time.", reset = true})

local prem60 = premiumRoot:addChildKeyword({'60'}, sayPrice, {npcHandler = npcHandler, days = 60})
prem60:addChildKeyword({'yes'}, addPremiumAction, {npcHandler = npcHandler, days = 60})
prem60:addChildKeyword({'no'},  StdModule.say,    {npcHandler = npcHandler, onlyFocus = true, text = "Alright, maybe next time.", reset = true})

npcHandler:addModule(FocusModule:new())
ahora si me funciona al 100% lo probé gracias por todo un saludo :D
 
Arriba