Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- local taskList = _MONSTERS_TASK_SYSTEM_CONFIG
- local libcfg = _SETTING_TASK_SYSTEM_CONFIG
- function creatureSayCallback(cid, type, msg)
- if(not npcHandler:isFocused(cid)) then
- return false
- end
- local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
- --- [[ MENSAGENS PRIMÁRIAS ]] ---
- if (msgcontains(msg, 'task') or msgcontains(msg, 'tasks')) then
- local str = ''
- for index, result in pairs(taskList) do
- str = str.."{"..index.."}, "
- end
- selfSay('Actually I have task for these monsters: '..str..'now tell me what monster you wanna do?', cid)
- talkState[talkUser] = 1
- --- [[ CONSULTANDO RECOMPENSAS ]] ---
- elseif (msgcontains(msg, 'awards') or msgcontains(msg, 'help')) then
- selfSay('Tell me a monster name to know the awards.', cid)
- talkState[talkUser] = 10
- --- [[ LISTANDO TASKS ]] ---
- elseif (msgcontains(msg, 'consult') or msgcontains(msg, 'check')) then
- getTask = checkPlayerIsInTask(cid)
- if #getTask > 0 then
- acTasks = doGiveTaskMonsterList(cid, getTask) -- Retorna Lista de Tasks Ativas como Texto
- selfSay('This is your active task list: ['..acTasks..'].', cid)
- talkState[talkUser] = 12
- else
- selfSay('You aren\'t in any task.', cid)
- talkState[talkUser] = 0
- end
- --- [[ CANCELANDO TASK ]] ---
- elseif (msgcontains(msg, 'cancel') or msgcontains(msg, 'canceling')) then
- getTask = checkPlayerIsInTask(cid)
- if #getTask > 0 then
- acTasks = doGiveTaskMonsterList(cid, getTask) -- Retorna Lista de Tasks Ativas como Texto
- selfSay('This is your active task list: ['..acTasks..']. What task you wanna cancel?', cid)
- talkState[talkUser] = 12
- else
- selfSay('You aren\'t in any task.', cid)
- talkState[talkUser] = 0
- end
- --- [[ CONCLUINDO TASKS ]] ---
- elseif (msgcontains(msg, 'done') or msgcontains(msg, 'completed')) then
- doneTask = doPlayerDonePersoTask(cid)
- if doneTask then
- confer = taskList[doneTask]
- if confer then
- killeds = tonumber(getPlayerStorageValue(cid, confer.countSto))
- if killeds >= tonumber(confer.count) then
- --[[ Givin' The Awards ]]--
- doGiveTaskAwards(cid, confer.awards)
- --[[ Resetin' Values ]]--
- inativo = 0
- getInfo = getInfoPlayerTask(cid, doneTask)
- repet = getInfo[1] + 1
- newValue = "&"..inativo.."/"..repet.."/0"
- setPlayerStorageValue(cid, confer.storage, newValue)
- setPlayerStorageValue(cid, confer.countSto, 0)
- --[[ Sendin' Message ]]--
- getAwardList = getAwardsList(cid, confer.awards)
- selfSay('Congratulations, you have done the {'..doneTask..' task} and received: '..getAwardList..'.', cid)
- talkState[talkUser] = 0
- else
- selfSay('Sorry, you have killed '..killeds..' of '..confer.count..' '..doneTask..', go kill more '..(confer.count-killeds)..'.', cid)
- talkState[talkUser] = 0
- end
- else
- selfSay('Sorry, but some error occurred with your task, contact to administrator.', cid)
- talkState[talkUser] = 0
- end
- else
- selfSay('You don\'t have done any task.', cid)
- talkState[talkUser] = 0
- end
- --- [[ NEGOCIAÇÃO & CONFIRMAÇÃO ]] ---
- elseif talkState[talkUser] == 1 then
- getMonster = taskList[msg:lower()]
- if getMonster then
- mMonster = msg:lower()
- mCount = getMonster.count
- mPrice = getMonster.price
- mSto = getMonster.storage
- mCountSto = getMonster.countSto
- repetMax = getMonster.repeated
- getAwardList = getAwardsList(cid, getMonster.awards)
- if getMonster.inDay then -- Task com Tempo
- selfSay('Alright, in this task you have to kill {'..mCount..' '..mMonster..' in '..getMonster.inDay..' day(s)}, your award is '..getAwardList..' and will {cost '..mPrice..' gold coins}, do you wanna try?', cid)
- else
- selfSay('Alright, in this task you have to kill {'..mCount..' '..mMonster..'}, your award is '..getAwardList..' and will {cost '..mPrice..' gold coins}, do you wanna try?', cid)
- end
- talkState[talkUser] = 2
- else
- selfSay('I\'m sorry, this monster isn\'t in my task system.', cid)
- talkState[talkUser] = 1
- end
- elseif talkState[talkUser] == 2 then
- if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
- checkTask = checkPlayerIsInTask(cid) -- Retorna Lista de Tasks Ativas
- acTasks = doGiveTaskMonsterList(cid, checkTask) -- Retorna Lista de Tasks Ativas como Texto
- if #checkTask < libcfg.taskAtSameTime then
- getInfo = getInfoPlayerTask(cid, mMonster)
- if not getInfo or getInfo[1] < repetMax then
- getDoingTask = checkAlreadyDoingThisTask(cid, mMonster, checkTask)
- if not getDoingTask then
- if #checkTask > 0 then
- selfSay('Okay, actually you have '..acTasks..' task actives ['..#checkTask..'/'..libcfg.taskAtSameTime..']. Do you wanna active the {'..mMonster..' task} payin\' {'..mPrice..' gold coins}?', cid)
- else
- selfSay('Okay, do you wanna continue with the task and payin\' '..mPrice..' gold coins?', cid)
- end
- talkState[talkUser] = 3
- else
- selfSay('Sorry, but the {'..mMonster..'} task already is active.', cid)
- talkState[talkUser] = 0
- end
- else
- selfSay('Sorry, but you have done {'..mMonster..'} task for '..getInfo[1]..' times.', cid)
- talkState[talkUser] = 0
- end
- else
- selfSay('Sorry, but you have '..acTasks..' task(s) actives, the limit of task actives at same time is '..libcfg.taskAtSameTime..', go done it.', cid)
- talkState[talkUser] = 0
- end
- elseif (msgcontains(msg, 'not') or msgcontains(msg, 'no')) then
- selfSay('Okay, see u later.', cid)
- talkState[talkUser] = 0
- else
- selfSay('Can I help you? Say {task} again if I do.', cid)
- talkState[talkUser] = 0
- end
- elseif talkState[talkUser] == 3 then
- if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
- if doPlayerRemoveMoney(cid, mPrice) then
- ativo = 1
- if not getInfo then
- repet = 0
- else
- repet = getInfo[1]
- end
- if not getMonster.inDay then
- newValue = "&"..ativo.."/"..repet.."/0"
- selfSay('Congratulations, you have started the {'..mMonster..'} task, go kill {'..mCount..'} and come back.', cid)
- else
- finalDate = (os.time() + (86400 * getMonster.inDay))
- newValue = "&"..ativo.."/"..repet.."/"..finalDate..""
- selfSay('Congratulations, you have started the {'..mMonster..'} task, go kill {'..mCount..'} untill {'..os.date("%b %d, %Y at %X", finalDate)..'} and come back.', cid)
- end
- setPlayerStorageValue(cid, mSto, newValue)
- setPlayerStorageValue(cid, mCountSto, 0)
- talkState[talkUser] = 0
- else
- selfSay('Sorry, but you don\'t have money enough.', cid)
- talkState[talkUser] = 0
- end
- else
- selfSay('Okay, see u later.', cid)
- talkState[talkUser] = 0
- end
- --- [[ INFORMAÇÕES DE TASKS ]] ---
- elseif talkState[talkUser] == 10 then
- getMonster = taskList[msg:lower()]
- if getMonster then
- getAwardList = getAwardsList(cid, getMonster.awards)
- if getMonster.inDay then
- selfSay('Alright, killing {'..getMonster.count..' '..msg:lower()..'s in '..getMonster.inDay..' day(s)} payin\' {'..getMonster.price..' gold coins} give you the follow awards: '..getAwardList..'.', cid)
- else
- selfSay('Alright, killing {'..getMonster.count..' '..msg:lower()..'s} payin\' {'..getMonster.price..' gold coins} give you the follow awards: '..getAwardList..'.', cid)
- end
- talkState[talkUser] = 0
- else
- selfSay('I\'m sorry, this monster isn\'t in my task system.', cid)
- talkState[talkUser] = 10
- end
- --- [[ CANCELANDO TASKS ]] ---
- elseif talkState[talkUser] == 12 then
- monst = msg:lower()
- saying = taskList[monst]
- if saying then
- checkTask = checkPlayerIsInTask(cid) -- Retorna Lista de Tasks Ativas
- checking = checkAlreadyDoingThisTask(cid, monst, checkTask)
- if checking then
- selfSay('You are sure that you wanna cancel the {'..monst..' task}?', cid)
- talkState[talkUser] = 13
- else
- selfSay('I\'m sorry, you don\'t have this task active right now.', cid)
- talkState[talkUser] = 0
- end
- else
- selfSay('I\'m sorry, this monster isn\'t in my task system.', cid)
- talkState[talkUser] = 12
- end
- --- [[ CANCELANDO TASKS ]] ---
- elseif talkState[talkUser] == 13 then
- if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
- inf = getInfoPlayerTask(cid, monst)
- doCloseTimedTask(cid, monst)
- selfSay('Congratulations, your {'..monst..' task} has been cancelled succesfully.', cid)
- talkState[talkUser] = 0
- else
- selfSay('Ok, I see you later.', cid)
- talkState[talkUser] = 0
- end
- end
- return true
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment