skydangerous

Untitled

Nov 22nd, 2011
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.35 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.  
  12.  
  13. npcHandler:setMessage(MESSAGE_GREET, "Hello Test")
  14.  
  15. local sky =
  16. {
  17.    
  18.     preco = 50000,
  19.     tempo = 5*60,
  20.     storage = 5050
  21. }
  22.    
  23.  
  24. function creatureSayCallback(cid, type, msg)
  25.         if(not npcHandler:isFocused(cid)) then
  26.                 return false
  27.         end
  28.  
  29.         local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  30.    
  31.    
  32.  
  33.     if msgcontains(msg, 'egg system') or msgcontains (msg, 'eggs') then
  34.                             selfSay('Ola eu vendo tal coisa quer comprar', cid)
  35.                             talkState[talkUser] = 1
  36.                        
  37.  
  38.         elseif talkState[talkUser] == 1 then
  39.                 if msgcontains(msg, 'yes') then
  40.                             if doPlayerRemoveMoney(cid, sky.preco) == TRUE then  
  41.                             setPlayerStorageValue(cid, sky.storage, (os.time()+sky.tempo))
  42.                              selfSay('Bora jogar !.', cid)                     
  43.                              talkState[talkUser] = 0
  44.                     else
  45.                          selfSay('Voce precissa de '..sky.preco - getPlayerMoney(cid)..' de dinheiro', cid)  
  46.                     end
  47.        
  48.         elseif msgcontains(msg, 'tempo')  then
  49.                         selfSay('Ola eu vendo tal coisa quer comprar', cid)
  50.                              talkState[talkUser] = 2  
  51.                        
  52.                     elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
  53.                             if (getPlayerStorageValue(cid, sky.storage) < os.time()) then
  54.                                  selfSay('Você só pode pegar o ovo daqui '.. math.floor((getPlayerStorageValue(cid, sky.storage) - os.time())/60) ..' minutos e '.. getPlayerStorageValue(cid, sky.storage) % 60 ..' segundos.', cid)                    
  55.                                 talkState[talkUser] = 0
  56.             end
  57.     end
  58.         return true
  59.    end
  60.   end
  61.    
  62.  
  63. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  64. npcHandler:addModule(FocusModule:new())
  65.  
Advertisement
Add Comment
Please, Sign In to add comment