Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 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. npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. I am specialized in boots, especially in {soft boots}.")
  12.  
  13. function creatureSayCallback(cid, type, msg)
  14.     if(not npcHandler:isFocused(cid)) then
  15.         return false
  16.     end
  17.  
  18.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  19.     local newboots = 2640
  20.  
  21.     if(msgcontains(msg, 'soft') or msgcontains(msg, 'boots')) then
  22.         selfSay('Do you want to repair your worn soft boots for 10000 gold coins?', cid)
  23.         talkState[talkUser] = 1
  24.     elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
  25.         if (getPlayerItemCount(cid, 10021) >= 1) then
  26.             if (doPlayerRemoveMoney(cid, 10000)) then
  27.                 doPlayerRemoveItem(cid, 10021, 1)
  28.                 doPlayerAddItem(cid, newboots)
  29.             end
  30.             selfSay('Here you are.', cid)
  31.         elseif (getPlayerItemCount(cid, 2640) >= 1)then
  32.             if (doPlayerRemoveMoney(cid, 10000)) then
  33.                 doPlayerRemoveItem(cid, 2640, 1)
  34.                 doPlayerAddItem(cid, newboots)
  35.             end
  36.             selfSay('Here you are.', cid)
  37.         elseif (getPlayerItemCount(cid, 6530) then
  38.             if (doPlayerRemoveMoney(cid, 10000)) then
  39.                 doPlayerRemoveItem(cid, 6530, 1)
  40.                 doPlayerAddItem(cid, newboots)
  41.                     end
  42.             selfSay('Here you are.', cid)
  43.         else
  44.             selfSay('Sorry, you don\'t have enough gold.', cid)
  45.         end
  46.  
  47.         talkState[talkUser] = 0
  48.     elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
  49.         talkState[talkUser] = 0
  50.         selfSay('Ok then.', cid)
  51.     end
  52.  
  53.     return true
  54. end
  55.  
  56. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  57. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement