local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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_DEFAULT and 0 or cid
if msgcontains(msg, 'promot') then
if getPlayerLevel(cid,x) == 1 then
if getPlayerVocation(cid,x) == 1 then
selfSay('Do you want to promote yourself for x gold?', cid)
else
selfSay('You need to be level x.', cid)
talkState[talkUser] = 1
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if getPlayerItemCount(cid, x, x) == 1 then
if getPlayerLevel(cid,x) == 1 then
if getPlayerVocation(cid,x) == 1 then
doPlayerRemoveItem(cid, x, x)
?doPromotePlayer?
selfSay('You are now promoted.', cid)
talkState[talkUser] = 0
else
selfSay('gtfo', cid)
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 creatureSayCallback(cid, type, msg)
if (msgcontains(msg, 'hail') or msgcontains(msg, 'hello') or msgcontains(msg, 'salutations')) and msgcontains(msg, 'queen') and (not npcHandler:isFocused(cid)) then
npcHandler:say('I greet thee, my loyal subject.', cid, TRUE)
npcHandler:addFocus(cid)
Topic[cid] = 0
elseif(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then
npcHandler:say('Farewell, '..getCreatureName(cid)..'!', cid, TRUE)
Topic[cid] = nil
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, 'promot') then
npcHandler:say('Do you want to be promoted in your vocation for 20000 gold?', cid)
Topic[cid] = 1
elseif msgcontains(msg, 'yes') and Topic[cid] == 1 then
if getPlayerPromotionLevel(cid) >= 1 then
npcHandler:say('You are already promoted.', cid)
elseif getPlayerLevel(cid) < 20 then
npcHandler:say('You need to be at least level 20 in order to be promoted.', cid)
elseif getPlayerMoney(cid) < 20000 then
npcHandler:say('You do not have enough money.', cid)
elseif isPremium(cid) then
npcHandler:say('Congratulations! You are now promoted. Visit the sage Eremo for new spells.', cid)
setPlayerPromotionLevel(cid, 1)
doPlayerRemoveMoney(cid, 20000)
else
npcHandler:say('You need a premium account in order to promote.', cid)
end
Topic[cid] = 0
elseif Topic[cid] == 1 then
npcHandler:say('Ok, whatever.', cid)
Topic[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
local t = {
[1] = {'So you want a promotion to Master sorcerer?', 1, 20000, 20},
[2] = {'So you want a promotion to Elder druid?', 2, 20000, 20},
[3] = {'So you want a promotion to Royal paladin?', 3, 20000, 20},
[4] = {'So you want a promotion to Elite knight?', 4, 20000, 20}
}
function creatureSayCallback(cid, type, msg)
local v = t[getPlayerVocation(cid)]
if msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
if v then
npcHandler:say(v[1], cid)
Topic[cid] = v[2]
elseif getPlayerVocation(cid) > 4 then
npcHandler:say('You are already promoted!', cid)
end
end
if Topic[cid] == v[2] then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid, v[3]) then
if getPlayerLevel(cid) >= v[4] then
if isPremium(cid) then
npcHandler:say('Congratulations! You are now promoted!. Visit the sage Eremo for new spells', cid)
setPlayerPromotionLevel(cid, 1)
Topic[cid] = 0
else
npcHandler:say('You need a premium account in order to get promoted', cid)
end
else
npcHandler:say('You must be level ' .. v[4] .. ' or more in order to get the promotion', cid)
end
else
npcHandler:say('You must have ' .. v[3] .. ' or more money in order to get the promotion', cid)
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
local t = {
[1] = {1, 'Master Sorcerer', 'Epic Sorcerer',5},
[2] = {2, 'Elder Druid', 'Epic Druid',6},
[3] = {3, 'Royal Paladin', 'Epic Paladin',7},
[4] = {4, 'Elite Knight', 'Epic Knight',8}
}--[Voc] = {Topic1, '1st', '2nd', Topic2} --
local promos = {
[1] = {'Master Sorcerer',20000, 20, 5},
[1] = {'Epic Sorcerer',20000, 20, 9},
[2] = {'Elder Druid',20000, 20, 6},
[2] = {'Epic Druid',20000, 20, 10},
[3] = {'Royal Paladin',20000, 20, 7},
[3] = {'Epic Paladin',20000, 20, 11},
[4] = {'Elite Knight',20000, 20, 8},
[4] = {'Epic Knight',20000, 20, 12},
}--[Voc] = {'Tovoc, Money, Level, Nr of Tovoc(Tovocation) --
function creatureSayCallback(cid, type, msg)
local v = t[getPlayerVocation(cid)]
if msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
if v then
npcHandler:say('Would you like a promotion?', cid)
Topic[cid] = v[1]
elseif getPlayerVocation(cid) > 4 then
npcHandler:say('You are already promoted!', cid)
end
end
if Topic[cid] == v[1] then
if msgcontains(msg, 'yes') then
npcHandler:say('Okay, what vocation do you want, ' .. v[2] .. ' or ' .. v[3] .. '?',cid)
Topic[cid] = v[4]
end
end
if Topic[cid] == v[4] then
for k, j in pairs(promos) do
if getPlayerVocation(cid) == k then
if msgcontains(msg, j[1]) then
if doPlayerRemoveMoney(cid, j[2]) then
if getPlayerLevel(cid) >= j[3] then
if isPremium(cid) then
npcHandler:say('Congratulations! You are now promoted!. Visit the sage Eremo for new spells', cid)
doPlayerSetVocation(cid, j[4])
Topic[cid] = 0
else
npcHandler:say('You need a premium account in order to get promoted', cid)
end
else
npcHandler:say('You must be level ' .. j[3] .. ' or more in order to get the promotion', cid)
end
else
npcHandler:say('You must have ' .. j[2] .. ' or more money in order to get the promotion', cid)
end
end
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
You can't index tables like that, one index can only hold 1 value.LUA:[1] = {'Master Sorcerer',20000, 20, 5}, [1] = {'Epic Sorcerer',20000, 20, 9},
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
local cost = 20000
local level = 20
local prem = getConfigInfo('premiumForPromotion')
function greetCallback(cid)
Topic[cid] = 0
return true
end
function creatureSayCallback(cid, type, msg)
if msgcontains(msg, 'promot') then
if getPlayerPromotionLevel(cid) ~= 0 then
npcHandler:say('You are already promoted!', cid)
Topic[cid] = 0
else
local v = getPlayerVocation(cid)
npcHandler:say('Alright, which vocation do you choose: {' .. getVocationInfo(v+4).name .. '} or {' .. getVocationInfo(v+8).name .. '}?', cid)
Topic[cid] = 1
end
elseif Topic[cid] == 1 then
local v = getPlayerVocation(cid)
if msgcontains(msg, getVocationInfo(v+8).name) then
v = v + 8
elseif msgcontains(msg, getVocationInfo(v+4).name) then
v = v + 4
end
if v > 4 then
npcHandler:say('Are you sure you want to get promoted to ' .. getVocationInfo(v).description .. ' for ' .. cost .. ' gold?',cid)
Topic[cid] = v
end
elseif Topic[cid] > 4 then
if msgcontains(msg, 'yes') then
if not prem or isPremium(cid) then
if getPlayerLevel(cid) >= level then
if doPlayerRemoveMoney(cid, cost) then
npcHandler:say('Congratulations! You are now promoted!', cid)
doPlayerSetPromotionLevel(cid, math.ceil((Topic[cid] - 4) / 4))
Topic[cid] = 0
else
npcHandler:say('You need ' .. cost .. ' gold to get promoted.', cid)
end
else
npcHandler:say('You need to be level ' .. level .. ' or higher to get promoted.', cid)
end
else
npcHandler:say('You need a premium account to get promoted.', cid)
end
else
npcHandler:say('Then not.', cid)
end
Topic[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())