skydangerous

Untitled

Nov 22nd, 2011
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 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. local sky =
  12. {
  13.     preco = 50000,
  14.     tempo = 5*60,
  15.     storage = 5050
  16. }
  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.    
  27.  
  28.     if msgcontains(msg, 'egg system') or msgcontains (msg, 'eggs') then
  29.                             selfSay('Ola eu vendo tal coisa quer comprar', cid)
  30.                                talkState[talkUser] = 1
  31.                        
  32.  
  33.         elseif talkState[talkUser] == 1 then
  34.                 if msgcontains(msg, 'yes') then
  35.                             if doPlayerRemoveMoney(cid, sky.preco) == TRUE then  
  36.                             setPlayerStorageValue(cid, sky.storage, (os.time()+sky.tempo))
  37.                              selfSay('Bora jogar !.', cid)                     
  38.                 talkState[talkUser] = 0
  39.        
  40.         elseif msgcontains(msg, 'tempo') or msgcontains (msg, 'time') then
  41.                  selfSay('Ola eu vendo tal coisa quer comprar', cid)
  42.                                talkState[talkUser] = 2
  43.        
  44.         elseif talkState[talkUser] == 2 then
  45.                 if msgcontains(msg, 'yes') then
  46.                             if (getPlayerStorageValue(cid, sky.storage) < os.time()) then
  47.                                  selfSay('Voce so pode pegar'.. getPlayerStorageValue(cid, sky.storage) - os.time() ..'segundo o ovo!', cid)                   
  48.                                     talkState[talkUser] = 0
  49.     end
  50. end
  51.         end
  52.     end
  53.         return true
  54.    end
  55.   end
  56.    
  57.  
  58. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  59. npcHandler:addModule(FocusModule:new())
  60.  
Advertisement
Add Comment
Please, Sign In to add comment