local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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 greetCallback(cid)
talkState[talkUser] = 0
return true
end
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
end
local vocationsNameId = {
{name = "Elder Druid", id = 5}, -- nome da vocação, id
{name = "Master Sorcerer", id = 6}
}
local startstorageid = 30031
local msg = string.lower(msg)
if getPlayerLevel(cid) < 20 then
selfSay("You need level 20 to change vocation.", cid)
npcHandler:onCreatureDisappear(cid)
end
if getPlayerStorageValue(cid, startstorageid) == 3 then
selfSay("You has changed your vocation!", cid)
npcHandler:onCreatureDisappear(cid)
end
if msgcontains(msg, 'yes') and talkState[talkUser] == nil or talkState[talkUser] == 0 then
selfSay("You want to change your vocation?", cid)
talkState[talkUser] = 2
elseif msgcontains(msg, 'no') and talkState[talkUser] == nil or talkState[talkUser] == 0 then
talkState[talkUser] = 0
npcHandler:onCreatureDisappear(cid)
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
selfSay("Ok, you change to {"..(vocationsNameId[1].name).."} or {"..(vocationsNameId[2].name).."}?", cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'no') and talkState[talkUser] == 2 then
talkState[talkUser] = 0
npcHandler:onCreatureDisappear(cid)
elseif msgcontains(msg, string.lower(vocationsNameId[1].name)) and talkState[talkUser] == 3 then
selfSay("You want to change your vocation to {"..(vocationsNameId[1].name).."}?", cid)
setPlayerStorageValue(cid, startstorageid, 1)
talkState[talkUser] = 4
elseif msgcontains(msg, string.lower(vocationsNameId[2].name)) and talkState[talkUser] == 3 then
selfSay("You want to change your vocation to {"..(vocationsNameId[2].name).."}?", cid)
setPlayerStorageValue(cid, startstorageid, 2)
talkState[talkUser] = 4
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 4 then
doPlayerSetVocation(cid, vocationsNameId[getPlayerStorageValue(cid, startstorageid)].id)
doSendMagicEffect(getCreaturePosition(cid), 29)
setPlayerStorageValue(cid, startstorageid, 3)
selfSay("Ok, you have changed this vocation to vocation {"..(vocationsNameId[getPlayerStorageValue(cid, startstorageid)].name).."}.", cid)
talkState[talkUser] = 0
npcHandler:onCreatureDisappear(cid)
elseif msgcontains(msg, 'no') and talkState[talkUser] == 4 then
talkState[talkUser] = 0
npcHandler:onCreatureDisappear(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
info
Grupo: Conde
Registrado: 30/06/11
Posts: 631
Reputação: +371
Char no Tibia: Warrior of Mort

vlw rep+ amanham tedo o rep vou testar quadno voltar umas 11hr eu testo pq vou cortar o cabelo fuii.
@EDIT
não é assim q eu quero eu queria q so tal vocation podesse selecionar a outra vocation q queria virar
Editado Agosto 9 por Snowsz
info
Grupo: Conde
Registrado: 30/06/11
Posts: 631
Reputação: +371
Char no Tibia: Warrior of Mort

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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 greetCallback(cid)
talkState[talkUser] = 0
return true
end
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
end
local vocationsNameId = {
{name = "Elder Druid", id = 5}, -- nome da vocação, id
{name = "Master Sorcerer", id = 6}
}
local vocationNeed = {1,2,3} -- id da vocação que precisa estar.
local startstorageid = 30031
local msg = string.lower(msg)
if getPlayerLevel(cid) < 20 then
selfSay("You need level 20 to change vocation.", cid)
npcHandler:onCreatureDisappear(cid)
end
if not isInArray(vocationNeed, getPlayerVocation(cid)) then
selfSay("You can not change his vocation here!", cid)
npcHandler:onCreatureDisappear(cid)
end
if getPlayerStorageValue(cid, startstorageid) == 3 then
selfSay("You has changed your vocation!", cid)
npcHandler:onCreatureDisappear(cid)
end
if msgcontains(msg, 'yes') and talkState[talkUser] == nil or talkState[talkUser] == 0 then
selfSay("You want to change your vocation?", cid)
talkState[talkUser] = 2
elseif msgcontains(msg, 'no') and talkState[talkUser] == nil or talkState[talkUser] == 0 then
talkState[talkUser] = 0
npcHandler:onCreatureDisappear(cid)
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
selfSay("Ok, you change to {"..(vocationsNameId[1].name).."} or {"..(vocationsNameId[2].name).."}?", cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'no') and talkState[talkUser] == 2 then
talkState[talkUser] = 0
npcHandler:onCreatureDisappear(cid)
elseif msgcontains(msg, string.lower(vocationsNameId[1].name)) and talkState[talkUser] == 3 then
selfSay("You want to change your vocation to {"..(vocationsNameId[1].name).."}?", cid)
setPlayerStorageValue(cid, startstorageid, 1)
talkState[talkUser] = 4
elseif msgcontains(msg, string.lower(vocationsNameId[2].name)) and talkState[talkUser] == 3 then
selfSay("You want to change your vocation to {"..(vocationsNameId[2].name).."}?", cid)
setPlayerStorageValue(cid, startstorageid, 2)
talkState[talkUser] = 4
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 4 then
doPlayerSetVocation(cid, vocationsNameId[getPlayerStorageValue(cid, startstorageid)].id)
doSendMagicEffect(getCreaturePosition(cid), 29)
setPlayerStorageValue(cid, startstorageid, 3)
selfSay("Ok, you have changed this vocation to vocation {"..(vocationsNameId[getPlayerStorageValue(cid, startstorageid)].name).."}.", cid)
talkState[talkUser] = 0
npcHandler:onCreatureDisappear(cid)
elseif msgcontains(msg, 'no') and talkState[talkUser] == 4 then
talkState[talkUser] = 0
npcHandler:onCreatureDisappear(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
info
Grupo: Visconde
Registrado: 06/04/11
Posts: 350
Reputação: +8
Char no Tibia: Mulekepirado

cara to prescisando de um script parecido, mais tipo tem que ter mais evoluçoes de vocaçao, e cada uma ter se level pra se conseguir tem como vc mim ajudar?
info
Grupo: Campones
Registrado: 29/01/12
Posts: 72
Reputação: +3
Gênero: Masculino
Char no Tibia: Ann Seehy





info
Grupo: Artesão
Registrado: 22/01/12
Posts: 121
Reputação: +23
Char no Tibia: Not...
bem eu queria pedir um npc que funcionace da seguinte maneira o player já nasce com uma vocação
ai ele vai no npc e fala com ele
hi
o npc fala You need level 20 to change vocation. caso ele n tenha lvl 20
se tiver lvl 20
hi
You want to change your vocation?
yes
Ok, you change to {talvocation} or {outravocation} ?
talvocation
You want to change your vocation to {talvocation}?
yes
Ok, you have changed this vocation to vocation {talvocation}.
bem é esse o npc q eu quero alguem pode me arrumar ?