Lua:
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 = cid
msg = string.lower(msg)
local vocations = {5, 6, 7, 8}
local level = 717217
if isInArray({"promotion", "promote", "promo"}, msg) then
selfSay('You need to have 100 VIP COINS and be at level 717217!', cid)
talkState[talkUser] = 1
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if isInArray(vocations, getPlayerVocation(cid):getId()) then
if getPlayerLevel(cid) >= level then
if getPlayerItemCount(cid, 11192) >= 100 then
doRemoveItem(cid, 11192, 100)
local newVocationId = getPlayerVocation(cid):getId() + 4
local newVocation = Vocation(newVocationId)
doPlayerSetVocation(cid, newVocation)
doSendMagicEffect(getPlayerPosition(cid), 12)
selfSay("Congratulations, you have been promoted!", cid)
else
selfSay("You don't have enough VIP COINS to be promoted.", cid)
end
else
selfSay("Sorry, you need to be at level " .. level .. " or above to be promoted!", cid)
end
else
selfSay("Sorry, you cannot receive promotion.", cid)
end
talkState[talkUser] = 0
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Goodbye then.", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())