Advertisement
Uissu

[X-TIBIA][NPC] VIP Promotion

Feb 4th, 2012
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new() -- By Byerne XTibia
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. local talkState = {}
  5.  
  6. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  7. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  8. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  9. function onThink() npcHandler:onThink() end
  10.  
  11. function creatureSayCallback(cid, type, msg)
  12. if(not npcHandler:isFocused(cid)) then
  13. return false
  14. end
  15.  
  16. local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
  17. local startVoc = (getPlayerVocation(cid) - ((getPlayerPromotionLevel(cid))*4))
  18.  
  19. if msgcontains(msg, 'promotion') then
  20.     if getPlayerPromotionLevel(cid) ~= 1 then
  21.         selfSay("Não posso te promover.", cid)
  22.     else
  23.         selfSay("Deseja virar um {VIP "..getVocationInfo(startVoc).name.."} por {40.000 gold coins} ({40k})?", cid)
  24.         talkState[talkUser] = 1
  25.     end
  26. elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
  27.     if doPlayerRemoveMoney(cid, 40000) then
  28.         doPlayerSetPromotionLevel(cid, 2)
  29.         selfSay("Parabéns, você agora é um "..getVocationInfo(getPlayerVocation(cid)).name..".", cid)
  30.     else
  31.         selfSay("Você não tem dinheiro suficiente.", cid)
  32.     end
  33.     talkState[talkUser] = 0
  34. end
  35.  
  36. return true
  37. end
  38.  
  39. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  40. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement