local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 talkState = {}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
price = 300000
if msgcontains(msg, "second promote") then
selfSay("Olá você quer ser promovido por '.. price ..' diga {yes} por favor.", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, "yes") and talkState[talkUser] == 1)then
if doPlayerRemoveMoney(cid, price) == TRUE then
if(isInArray({5, 6, 7, 8}, getPlayerVocation(cid))) then
selfSay('Parabens você foi prpmovido!', cid)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
else
selfSay('Você já foi promovido', cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
else
selfSay('You don\'t have '.. price ..'', cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
elseif msg == "no" and talkState[talkUser] == 1 then
selfSay("Then not", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())