adrianoswatt

NPC Outfitter per Storage(s)

Mar 15th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  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. -- [[ START THE SETTINGS ]] ---
  12. local outfit = {storage = 10000, name = "Nome da Outfit"}
  13. local stoList = {
  14.     [1] = {key = 12125, value = 1, mission = "Informação da missão"},
  15.     [2] = {key = 12126, value = 1, mission = "Informação da missão"},
  16. }
  17. -- [[ END FROM SETTINGS THINGS ]] ---
  18.  
  19. function creatureSayCallback(cid, type, msg)
  20. if(not npcHandler:isFocused(cid)) then
  21. return false
  22. end
  23. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  24.  
  25. if (msgcontains(msg, 'outfit') or msgcontains(msg, 'addon')) then
  26.     selfSay('You really wanna active this addon?', cid)
  27.     talkState[talkUser] = 1
  28.    
  29.     -- [[ CONFIRMANDO BROADCASTMESSAGES ]] --
  30. elseif talkState[talkUser] == 1 then
  31.     if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
  32.         for a = 1, #stoList do
  33.             if getPlayerStorageValue(cid, stoList[a].key) < stoList[a].value then
  34.                 selfSay('I\'m so sorry, but you don\'t have the '..stoList[a].mission..'.', cid)
  35.                 talkState[talkUser] = 0
  36.             return true
  37.             end
  38.         end
  39.         setPlayerStorageValue(cid, outfit.storage, 1)
  40.         selfSay('Congratulations, you have active the '..outfit.name..' outfit.', cid)
  41.         talkState[talkUser] = 0
  42.     else
  43.         selfSay('Okay, see u later.', cid)
  44.         talkState[talkUser] = 0
  45.     end
  46.    
  47. end
  48.   return true
  49. end
  50. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  51. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment