A vocação some ao deslogar porque o "fromvoc" no Vocation.XML está configurado errado.
4
996
info
Grupo: Campones
Registrado: 29/01/12
Posts: 72
Reputação: +3
Gênero: Masculino
Char no Tibia: Ann Seehy

21 de agosto de 2012 às 14:43
21 de agosto de 2012 às 16:22
Para o NPC
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local NPC_NEED_ITEMS = {{9971, 1}} -- Itens, caso o modo de promotion seja "items"
local NPC_NEED_LEVEL = 200
local NPC_NEED_PROMOTION = 1
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 function ordinalprefix(n)
local ordinal = {[1] = "st", [2] = "nd", [3] = "rd"}
return n .. (ordinal[n] or "th")
end
function onCreatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, "promotion") then
if getPlayerLevel(cid) < NPC_NEED_LEVEL then
selfSay("Sorry, but you need level ".. NPC_NEED_LEVEL .." to be promoted.", cid)
return
end
if getPlayerPromotionLevel(cid) ~= NPC_NEED_PROMOTION then
selfSay("Sorry, but you need to have {".. ordinalprefix(NPC_NEED_PROMOTION) .."} promotion.", cid)
return
end
local say = "So do you want to be promoted, heh? I need"
for n = 1, #NPC_NEED_ITEMS do
local sep = (n == 1 and " " or (n == #NPC_NEED_ITEMS and " and " or ", "))
say = say .. sep .. math.max(1, NPC_NEED_ITEMS[n][2]) .." ".. getItemNameById(NPC_NEED_ITEMS[n][1])
end
selfSay(say, cid)
talkSate[talkUser] = 1
end
if talkState[talkUser] == 1 then
if msgcontains(msg, "yes") then
local ret = {}
for _, item in ipairs(NPC_NEED_ITEMS) do
local g = getPlayerItemById(cid, true, item[1])
if g.uid > 0 and math.max(1, g.type) > item[2] then
table.insert(ret, {g.uid, item[2]})
else
ret = {}
break
end
end
if #ret > 0 then
for _, item in ipairs(ret) do
doRemoveItem(item[1], item[2])
end
selfSay("May the Gods bless you. You are now promoted.", cid)
doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
else
selfSay("You do not have all the items I need", cid)
npcHandler:releaseFocus(cid)
end
elseif msgcontains(msg, "no") then
selfSay("Alright.")
npcHandler:releaseFocus(cid)
end
end
return true
end
npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME|. Do you want the {promotion}?")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSayCallback)
npcHandler:setCallback(CALLBACK_GREET, onGreetCallback)
npcHandler:addModule(FocusModule:new())
Para que o NPC apareça e suma
globalevents/scripts/nome_do_arquivo.lua
local npc_name = "The Promotion King"
local npc_position = {x = 160, y = 54, z = 7}
function onThink(interval)
local NPC = doCreateNpc(npc_name, position)
addEvent(doRemoveCreature, 60 * 60 * 1000, NPC)
return true
end
globalevents.xml
<globalevent name="promotionnpc" time="00:00:00" event="script" value="save.lua"/>
Não esqueça de configurar os itens aqui:
local NPC_NEED_ITEMS = {{9971, 1}}
local NPC_NEED_ITEMS = {{ITEM1, COUNT1}, {ITEM2, COUNT2}, {ITEM3, COUNT3}, ..., {ITEM999, COUNT999}}
Abraços.
Editado Agosto 21 por Oneshot
info
Grupo: Marquês
Registrado: 18/05/11
Posts: 1.1k
Reputação: +333
Gênero: Masculino
Char no Tibia: Kyuzen

21 de agosto de 2012 às 16:57
Vo testar, se der certo Rep+
Edit--
Pode usar para Pokemon tambem?
É que eu não especifiquei se era pra tibia ou pokemon...
Eu queria pra pokemon tem como ajeitar?
Editado Agosto 22 por Bolz



info
Grupo: Marquês
Registrado: 18/05/11
Posts: 1.1k
Reputação: +333
Gênero: Masculino
Char no Tibia: Kyuzen
Eu queria um Npc parecido com o desse topico (http://www.xtibia.co...a-ate-deslogar/)
Mais o dele some a vocaçao quando desloga...
Eu queria um que aparece uma vez por dia, e que so ficasse 1 hora no lugar se ninguem fosse falar com ele, ele sumia.Quando falasse com ele, tinha que dar 4 itens para ele em troca da vocaçao.E que a vocaçao não sumisse quando deslogava.
Quem puder ajudar eu agradeço.