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
- function onCreatureSayCallback(cid, type, msg)
- local config = {
- price = 50000,
- delay = 2 * 60,
- control = 5052,
- test = math.random(0,1),
- sto = 5152,
- eggn = 4850,
- }
- if not npcHandler:isFocused(cid) then
- return false
- end
- local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
- if msgcontains(msg, "care") then
- local p = (config.price % 1000 == 0 and (config.price / 1000) or config.price)
- if getPlayerStorageValue(cid, config.control) > os.time() then
- selfSay("Sorry, but I am already caring one of your eggs.", cid)
- else
- selfSay("Do you want me to take care of your egg for ".. p .." ".. (p == config.price and "" or "k") .."?", cid)
- talkState[talkUser] = 1
- end
- elseif msgcontains(msg, "back") then
- local s = getPlayerStorageValue(cid,config.sto)
- if s == true then
- selfSay("Hello, you came to pick up your egg?.", cid)
- else
- selfSay("Sorry, you do not because no egg to hatch",cid)
- talkState[talkUser] = 2
- end
- elseif msgcontains(msg, "check") then
- local t = getPlayerStorageValue(cid, config.control)
- if t < os.time() then
- selfSay("Yay, your egg has hatched and I've encountered a cute pet!", cid)
- else
- selfSay("I will be caring your egg for more ".. math.floor((t - os.time()) / 60) .." minutes and ".. (t - os.time()) % 60 .." seconds.", cid)
- end
- elseif talkState[talkUser] == 1 then
- if msgcontains(msg, "yes") then
- if doPlayerRemoveMoney(cid, config.price) then
- setPlayerStorageValue(cid,config.sto)
- setPlayerStorageValue(cid, config.control, os.time()+config.delay)
- selfSay("Okay! Check back soon.", cid)
- else
- selfSay("Sorry, you don't have enough money. You need more ".. (config.price - getPlayerMoney(cid)) .." coins.", cid)
- end
- elseif talkState[talkUser] == 2 then
- local x = getPlayerStorageValue(cid, config.control)
- if msgcontains(msg, "yes") then
- if x > os.time() then
- doPlayerAddItem(config.eggn,1)
- doSetItemSpecialDescription(config.eggn, "Shocked egg")
- selfSay("take your egg.", cid)
- else
- selfSay("Sorry you must wait long to get.", cid)
- end
- elseif msgcontains(msg, "no") then
- selfSay("Too pricey for you, heh?", cid)
- end
- end
- end
- return true
- end
- npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME|. I am a pet egg carer. Do you want me to {care} your pet eggs? Also you can {check} the egg status, if you want to get your egg talk {back}.")
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment