Advertisement
adrianoswatt

NPC Voc - ClassicBrTibia

Oct 23rd, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. local talkState = {}
  5. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  6. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  7. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  8. function onThink() npcHandler:onThink() end
  9. ---------- INÍCIO DAS CONFIGS ------------
  10. local vocsAgree = {1, 2, 3, 4} -- Voc IDs Permitidas para Promote
  11. local cost = 20000 -- Custo em Gold Coins
  12. ----------- FIM DAS CONFIGS ---------------
  13.  
  14. function creatureSayCallback(cid, type, msg)
  15. if(not npcHandler:isFocused(cid)) then
  16.     return false
  17. end
  18. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  19.  
  20. ------------------ MESSAGENS --------------------------
  21. local getStoStep = getPlayerStorageValue(cid, strgStep) -- STARTING MISSION
  22. if (msgcontains(msg, 'promote') or msgcontains(msg, 'promotion')) then
  23.     if isInArray(vocsAgree, getPlayerVocation(cid)) then
  24.         selfSay('I can promote you for 20000 gold coins. Do you want me to promote you?', cid)
  25.         talkState[talkUser] = 1
  26.     else
  27.         selfSay('Sorry, you already was promoted.', cid)
  28.         talkState[talkUser] = 0
  29.     end
  30.  
  31.     --------- HELP --------
  32. elseif (msgcontains(msg, 'help') or msgcontains(msg, 'ajuda')) then
  33.     selfSay('Say {promote} or {promotion} to be prometed for '..cost..' gold coins.', cid)
  34.     talkState[talkUser] = 0
  35.  
  36.     ------ NEGOCIAÇÃO ------
  37. elseif talkState[talkUser] == 1 then
  38.     if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
  39.         if doPlayerRemoveMoney(cid, cost) then
  40.             setPlayerPromotionLevel(cid, 1)
  41.             selfSay('Congratulation, now you\'re promoted.', cid)
  42.             talkState[talkUser] = 0
  43.         else
  44.             selfSay('You don\'t have money.', cid)
  45.         talkState[talkUser] = 0
  46.         end
  47.     else
  48.         selfSay('Alright then, come back when you are ready.', cid)
  49.         talkState[talkUser] = 0
  50.     end
  51. end
  52. return true
  53. end
  54. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  55. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement