Ir para conteúdo
  • 0

Npc Vocation


Snowsz

Pergunta

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 ?

Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0
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())

Link para o comentário
Compartilhar em outros sites

  • 0

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 por Snowsz
Link para o comentário
Compartilhar em outros sites

  • 0
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())

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...