skydangerous

Untitled

Nov 22nd, 2011
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 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.                                            
  35.                            selfSay('Ola eu vendo tal coisa quer comprar', 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.                                     if doRemoveItem(4850,1) == TRUE then
  44.                                 setPlayerStorageValue(cid, sky.storage, (os.time()+sky.tempo))
  45.                                 SendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
  46.                                
  47.                              selfSay('Volte em breve para pega-lo.', cid)                      
  48.                              talkState[talkUser] = 0
  49.                     else
  50.                          selfSay('Voce precissa de '..sky.preco - getPlayerMoney(cid)..' de dinheiro', cid)  
  51.                     end
  52.                     else
  53.                          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)                
  54.                     end
  55.     end
  56.     end
  57.         return true
  58.    end
  59.   end
  60.    
  61.  
  62. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  63. npcHandler:addModule(FocusModule:new())
  64.  
Advertisement
Add Comment
Please, Sign In to add comment