Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keywordHandler = KeywordHandler:new()
- local npcHandler = NpcHandler:new(keywordHandler)
- NpcSystem.parseParameters(npcHandler)
- local talkState = {}
- function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
- function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
- function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
- function onThink() npcHandler:onThink() end
- npcHandler:setMessage(MESSAGE_GREET, "Hello Test")
- local sky =
- {
- preco = 50000,
- tempo = 5*60,
- storage = 5050
- }
- function creatureSayCallback(cid, type, msg)
- if(not npcHandler:isFocused(cid)) then
- return false
- end
- local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
- if msgcontains(msg, 'egg system') or msgcontains (msg, 'eggs') then
- selfSay('Ola eu vendo tal coisa quer comprar', cid)
- talkState[talkUser] = 1
- elseif talkState[talkUser] == 1 then
- if msgcontains(msg, 'yes') then
- if doPlayerRemoveMoney(cid, sky.preco) == TRUE then
- setPlayerStorageValue(cid, sky.storage, (os.time()+sky.tempo))
- selfSay('Bora jogar !.', cid)
- talkState[talkUser] = 0
- else
- selfSay('Voce precissa de '..sky.preco - getPlayerMoney(cid)..' de dinheiro', cid)
- end
- elseif msgcontains(msg, 'tempo') then
- selfSay('Ola eu vendo tal coisa quer comprar', cid)
- talkState[talkUser] = 2
- elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
- if (getPlayerStorageValue(cid, sky.storage) < os.time()) then
- 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)
- talkState[talkUser] = 0
- end
- end
- return true
- end
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment