kamilcioo
Veteran OT User
- Joined
- Jul 25, 2008
- Messages
- 979
- Solutions
- 1
- Reaction score
- 291
Tried some options but none of them worked. I need a npc who will give promotion. For example:
*You are mage and you can promote to Druid or Sorcerer.
*You are paladin and you can promote to Assassin or Sharpshooter.
*You are knight and you can promote to Berserker or Crusader.
Voc ids:
mage - 1
sorcerer - 4
mage - 5
paladin - 2
assassin - 6
Sharpshooter - 8
Knight - 3
Berserker - 7
Crusader - 9
Tried with this script but bugged:
*You are mage and you can promote to Druid or Sorcerer.
*You are paladin and you can promote to Assassin or Sharpshooter.
*You are knight and you can promote to Berserker or Crusader.
Voc ids:
mage - 1
sorcerer - 4
mage - 5
paladin - 2
assassin - 6
Sharpshooter - 8
Knight - 3
Berserker - 7
Crusader - 9
Tried with this script but bugged:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local vocations =
{
[Begginer] = {Mage, Archer, Knight}
[0] = {1, 2, 3},
[Mage] = {Master Sorcerer, Elder Druid}
[1] = {4, 5},
[Ranger] = {Bow master, Crossbow Master}
[2] = {6, 8},
[Knight] = {Berserker, Crusader}
[3] = {7, 9}
}
local promotions = {}
local choose = {}
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
if msg:lower() == "promotion" then
if not vocations[getPlayerVocation(cid)] and getPlayerVocation(cid) > 0 then
return npcHandler:say("You already have the highest promotion.", cid)
end
promotions[cid] = {}
local vocs = vocations[getPlayerVocation(cid)]
local sep = ", "
local i = 0
local text = ""
for _, id in pairs(vocs) do
i = i + 1
if i == #vocs - 1 then
sep = " and "
elseif i == #vocs then
sep = "."
end
text = text .. "{" .. getVocationInfo(id).name .. "}" .. sep
table.insert(promotions[cid], getVocationInfo(id).name:lower())
end
npcHandler:say("You can choose " .. (#vocs > 1 and "one between" or "") .. " the following promotion" .. (#vocs > 1 and "s" or "") .. ": " .. text .. ". Wich will you select?", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 and isInArray(promotions[cid], msg:lower()) then
npcHandler:say("Are you sure do you want to be promoted to {" .. msg:lower() .. "}?", cid)
talkState[talkUser] = 2
choose[cid] = getVocationByName(msg)
elseif talkState[talkUser] == 2 then
if msg:lower() == "yes" then
doPlayerSetVocation(cid, choose[cid])
npcHandler:say("Congratulations! You have been promoted to " .. getVocationInfo(choose[cid]).name .. ".", cid)
choose[cid] = nil
promotions[cid] = nil
talkState[talkUser] = 0
else
npcHandler:say("Ok then.", cid)
choose[cid] = nil
promotions[cid] = nil
talkState[talkUser] = 0
end
end
return true
end
function getVocationByName(name)
for k, v in pairs(vocations) do
for _, voc in ipairs(v) do
if getVocationInfo(voc).name:lower() == name:lower() then
return voc
end
end
end
return 0
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Attachments
-
Bez tytułu.jpg68.1 KB · Views: 6 · VirusTotal
