skydangerous

Untitled

Nov 22nd, 2011
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.95 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. local talkState = {}
  5. function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid)                        end
  6. function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid)                     end
  7. function onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg)                end
  8. function onThink()                                      npcHandler:onThink()                                    end
  9. npcHandler:setMessage(MESSAGE_GREET, "Ola |PLAYERNAME| , eu posso cuidar de seu {ovo} por 50k voce quer? Digite {egg system}")
  10. local sky =
  11. {    
  12.     preco = 50000,
  13.     tempo = 5*60,
  14.     storage = 5050
  15. }
  16.  
  17. function creatureSayCallback(cid, type, msg)
  18.     if(not npcHandler:isFocused(cid)) then
  19.         return false
  20.     end
  21.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 and 2 or cid
  22.     if(msgcontains(msg, 'egg') or (msgcontains (msg, 'cuidar')) and talkState[talkUser] == 0) then
  23.        selfSay('Irei cuidar do seu ovo por um tempo, voce quer?', cid)
  24.     end
  25.     talkState[talkUser] = 1
  26.     if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
  27.         if(getPlayerStorageValue(cid, sky.storage) < os.time()) then                                                          
  28.             if(doPlayerRemoveMoney(cid, sky.preco)) == true then  
  29.                 doRemoveItem(4850,1)
  30.                    setPlayerStorageValue(cid, sky.storage, (os.time()+sky.tempo))
  31.                    sendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
  32.                    selfSay('Volte em breve para pega-lo.', cid)
  33.                    talkState[talkUser] = 0             
  34.                 else
  35.                    selfSay('Voce precissa de '..sky.preco - getPlayerMoney(cid)..' de dinheiro', cid)  
  36.                 end
  37.            
  38.             elseif(msgcontains(msg, 'checar') or (msgcontains (msg, 'checar o ovo')) and talkState[talkUser] == 0) then
  39.                  selfSay('Voce quer saber quanto tempo voce pode pegar o ovo?', cid)      
  40.                        talkState[talkUser] = 2
  41.                            
  42.    
  43.     elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
  44.         if(getPlayerStorageValue(cid, sky.storage) < os.time()) then                                                          
  45.                        selfSay('Volte em breve para pega-lo.', cid)
  46.                    talkState[talkUser] = 0             
  47.                  else
  48.                  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)      
  49.                end
  50.                end
  51.                   end
  52.    
  53.     return true
  54.   end
  55. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  56. npcHandler:addModule(FocusModule:new())
  57.  
Advertisement
Add Comment
Please, Sign In to add comment