skydangerous

Untitled

Nov 23rd, 2011
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.42 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, "Ola |PLAYERNAME|, eu posso cuidar de seu ovo digite {cuidar} ou {egg system} ")
  14.  
  15. local sky =
  16. {
  17.    
  18.     preco = 50000,
  19.     tempo = 2*60,
  20.     storage = 5052
  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, 'cuidar') then
  34.                                            
  35.                            selfSay('Voce quer que eu cuide de seu ovo, por {50k}?', cid)
  36.                             talkState[talkUser] = 1
  37.                        
  38.  
  39.         elseif talkState[talkUser] == 1 then
  40.                 if msgcontains(msg, 'yes') then
  41.                             if (getPlayerStorageValue(cid, sky.storage) > os.time()) then                              
  42.                                 if doPlayerRemoveMoney(cid, sky.preco) == TRUE then  
  43.                                     setPlayerStorageValue(cid, sky.storage, (os.time()+sky.tempo))
  44.                                                                
  45.                              selfSay('Volte em breve para pega-lo.', cid)                      
  46.                              talkState[talkUser] = 0
  47.                     else
  48.                          selfSay('Voce precissa de '..sky.preco - getPlayerMoney(cid)..' de dinheiro', cid)  
  49.                     end
  50.                     else
  51.                         selfSay('Voce deve esperar o tmepo', cid)  
  52.                     end
  53.                    
  54.  
  55.       elseif msgcontains(msg, 'checar') then
  56.             if (getPlayerStorageValue(cid, sky.storage) > os.time()) then
  57.                 selfSay('test', cid)
  58.             else
  59.                          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)                
  60.                     end
  61.         end
  62.     end
  63.         return true
  64.    end
  65.   end
  66.    
  67.  
  68. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  69. npcHandler:addModule(FocusModule:new())
  70.  
  71.  
Advertisement
Add Comment
Please, Sign In to add comment