Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 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 = 6132
  20.     local oldboots = 10021
  21.  
  22.     if(msgcontains(msg, 'soft') or msgcontains(msg, 'boots')) then
  23.         selfSay('Do you want to repair your worn soft boots for 10000 gold coins?', cid)
  24.         talkState[talkUser] = 1
  25.     elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
  26.         if (getPlayerItemCount(cid, oldboots) >= 1) then
  27.             if (doPlayerRemoveMoney(cid, 10000)) then
  28.                 local item = getPlayerItemById(cid, true, oldboots)
  29.                 doTransformItem(item.uid, newboots)
  30.                 selfSay('Here you are.', cid)
  31.             else
  32.                 selfSay('Sorry, you don\'t have enough gold.', cid)
  33.             end
  34.         else
  35.             selfSay('Sorry, you need worn soft boots to repair them.', cid)
  36.         end
  37.         talkState[talkUser] = 0
  38.     elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
  39.         talkState[talkUser] = 0
  40.         selfSay('Ok then.', cid)
  41.     end
  42.     return true
  43. end
  44.  
  45. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  46. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement