Hi peopple, its me again, hehehe
Anyone know how to make a npc asks player vocation?
Like the Dead Bureaucrat NPC from poi, he asks playername,
This script is only an example, NPC asks for player name, and the player aswers with his name, then npc asks vocation...
here is where come the problem, actualy the function is getPlayerVocation, and it check player vocation with numbers, 1 2 3 4 5 6 7 8, how can i make this npc check if the player says Sorcerer for example?
Anyone know how to make a npc asks player vocation?
Like the Dead Bureaucrat NPC from poi, he asks playername,
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local Topic = {}
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 doNPCTalkALot(msgs,interval)
local e={}
local ret={}
if interval==nil then interval=3000 end --3 seconds is default time between messages
for aux=1,table.getn(msgs) do
e[aux]={}
doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux])
table.insert(ret,e[aux])
end
return(ret)
end
function creatureSayCallback(cid, type, msg)
if (msgcontains(msg, 'hi') or msgcontains(msg, 'hello') or msgcontains(msg, 'salutations')) and getPlayerSex(cid) == 0 and not npcHandler:isFocused(cid) then
npcHandler:say('Hello beautiful lady, welcome to the atrium of Pumin\'s Domain. We require some information from you before we canlet you pass. Where do you want to go?', cid, TRUE)
npcHandler:addFocus(cid)
Topic[cid] = 0
elseif (msgcontains(msg, 'hi') or msgcontains(msg, 'hello') or msgcontains(msg, 'salutations')) and getPlayerSex(cid) == 1 and not npcHandler:isFocused(cid) then
npcHandler:say('Welcome to the atrium of Pumin\'s domain, young man. We need some information before we can let you pass. Where do you want to go?', cid, TRUE)
Topic[cid] = 0
end
function getVocationName(id)
local vocations = {
[1] = {'druid'},
[2] = {'sorcerer'},
[3] = {'paladin'},
[4] = {'knight'},
[5] = {'druid'},
[6] = {'sorcerer'},
[7] = {'paladin'},
[8] = {'knight'},
}
local VocName = vocations[id]
return VocName
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local namee = getPlayerName(cid)
if (msgcontains(msg, 'Pumin') or msgcontains(msg, 'pumin') ) then
selfSay('Sure, where else. Everyone likes to meet my master, he is a great demon, isn\'t he? Your name is ...?',cid)
talkState[talkUser] = 1
elseif msg == getCreatureName(cid) and talkState[talkUser] == 1 then
selfSay('Alright '.. getCreatureName(cid) .. '. Vocation?',cid)
talkState[talkUser] = 2
elseif msg == getVocationName(getPlayerVocation(cid)) and talkState[talkUser] == 2 then
selfSay('Alright '.. VocName .. '..........' ,cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
This script is only an example, NPC asks for player name, and the player aswers with his name, then npc asks vocation...
here is where come the problem, actualy the function is getPlayerVocation, and it check player vocation with numbers, 1 2 3 4 5 6 7 8, how can i make this npc check if the player says Sorcerer for example?