Advertisement
fox1759

npcItems.lua

Apr 2nd, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.93 KB | None | 0 0
  1. local config = {
  2.        
  3.         items = {{itemid = 2225, count = 30}, {itemid = 2033, count = 20}, {itemid = 2363, count = 1}, {itemid = 2350, count = 1}},
  4.         storage = 74561, -- Não mudar
  5.         add_item = 2160, -- Item que vai ganhar
  6. }
  7.  
  8. local keywordHandler = KeywordHandler:new()
  9. local npcHandler = NpcHandler:new(keywordHandler)
  10. NpcSystem.parseParameters(npcHandler)
  11. local talkState = {}
  12.  
  13. function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
  14. function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
  15. function onCreatureSay(cid, type, msg)          npcHandler:onCreatureSay(cid, type, msg)        end
  16. function onThink()                  npcHandler:onThink()                    end
  17.  
  18.  
  19. function creatureSayCallback(cid, type, msg)
  20.     if(not npcHandler:isFocused(cid)) then
  21.         return false
  22.     end
  23.  
  24.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  25.  
  26.     if getPlayerStorageValue(cid, config.storage) >= 1 then
  27.         selfSay('você já me ajudou!!', cid)
  28.         return false
  29.     end
  30.    
  31.     if msgcontains(msg:lower(), 'pedido') then
  32.         selfSay('Estou precisando de uns itens e se tu me trouxer eu lhe recompensarei... \nlista de Itens:\n-30 Piece of Iron\n-20 Golden Mug\n-1 Blood Orb\n-1 Sword Hilt.', cid)
  33.     end
  34.  
  35.     if msgcontains(msg:lower(), 'entrega') then
  36.        
  37.         item = 0
  38.  
  39.          for i = 1, #config.items do
  40.             if getPlayerItemCount(cid, config.items[i].itemid) >= config.items[i].count then
  41.                 item = item + 1
  42.             end
  43.         end
  44.  
  45.         if item == #config.items then
  46.             for x = 1, #config.items do
  47.                 doPlayerRemoveItem(cid, config.items[x].itemid, config.items[x].count)
  48.             end
  49.             selfSay('Aqui está sua recompensa', cid)
  50.             doPlayerAddItem(cid, config.add_item, 1)
  51.             setPlayerStorageValue(cid, config.storage, 1)
  52.          else
  53.             selfSay('Verifique se você tem todos os items...', cid)
  54.          end
  55.        
  56.     end
  57.  
  58.  
  59.     return true
  60. end
  61.  
  62. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  63. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement