Advertisement
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 Topic = {}
- 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 greetCallback(cid)
- if getPlayerStorageValue(cid, 66666) > 0 then
- npcHandler:setMessage(MESSAGE_GREET, "Be greeted, |PLAYERNAME|! It's so good to see you again. Should I {bless} you today?")
- else
- npcHandler:setMessage(MESSAGE_GREET, "Welcome to the Stonegate Temple, |PLAYERNAME|. Are you a {citizen} of Stonegate?")
- end
- topic = nil
- return true
- end
- npcHandler:setCallback(CALLBACK_GREET, greetCallback)
- function creatureSayCallback(cid, type, msg)
- if(not npcHandler:isFocused(cid)) then
- return false
- end
- local t = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
- local delayTime = 3*1000
- local v = getPlayerStorageValue(cid, 3001)
- if msgcontains(msg, "bless") then
- if getPlayerStorageValue(cid, 66666) > 0 then
- npcHandler:say("Would you like me to use all of my powers to bless you? In return all I ask for is 50000 gold coins.", cid)
- Topic[t] = 9
- end
- elseif Topic[t] == 9 then
- if msgcontains(msg, "yes") then
- local blessing = {1, 2, 3, 4, 5}
- for i = 1, #blessing do
- if not getPlayerBlessing(cid, blessing[i]) then
- if doPlayerRemoveMoney(cid, 50000) == TRUE then
- npcHandler:say("By the powers invested in me be blessed!", cid)
- doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
- doPlayerAddBlessing(cid, blessing[i])
- Topic[t] = nil
- else
- npcHandler:say("I am sorry but you do not have enough gold.", cid)
- Topic[t] = nil
- end
- else
- npcHandler:say("I think you are getting a bit old, you already posses my blessing.", cid)
- Topic[t] = nil
- end
- end
- else
- npcHandler:say("I understand, stay strong!", cid)
- Topic[t] = nil
- end
- elseif isInArray({"citizen", "task", "mission", "quest"}, msg:lower()) then
- if getPlayerStorageValue(cid, 3002) > 0 then
- npcHandler:say("Would you like to become a citizen of our city, ".. getPlayerName(cid) .."?", cid)
- Topic[t] = 2
- elseif getPlayerStorageValue(cid, 3001) == 50 then
- npcHandler:say("Woah! Great job ".. getPlayerName(cid) .."! You really did it. You are free to join our city at anytime.", cid)
- doPlayerAddExperience(cid, 5000)
- setPlayerStorageValue(cid, 3002, 1)
- elseif getPlayerStorageValue(cid, 3000) > 0 then
- npcHandler:say("You haven't killed enough trolls, you need to kill ".. (50 - v) .." more.", cid)
- elseif getPlayerStorageValue(cid, 3002) < 1 then
- npcHandler:say("Hmm... I don't know young ".. getPlayerName(cid) ..", I can't just let you in to our town without testing you ...", cid)
- npcHandler:say("Would you like to take a citizen test, ".. getPlayerName(cid).."?", cid,3000) Topic[t] = 1
- end
- elseif Topic[t] == 1 then
- if msgcontains(msg, "yes") then
- npcHandler:say("Okay listen, we've spotted some troll activity to the north-east our city ...", cid)
- npcHandler:say("If you want to become a citizen I want you to go and kill no less than 50 trolls. Type doesn't matter as long it's a troll ... So go and take care of this matter and prove yourself worthy!", cid,3000)
- setPlayerStorageValue(cid, 3000, 1)
- setPlayerStorageValue(cid, 3001, 0)
- Topic[t] = nil
- else
- npcHandler:say("Hmm... I guess you'll just be a visitor for now then.", cid)
- Topic[t] = nil
- end
- elseif msgcontains(msg, "name") then
- npcHandler:say("My name is Benedict", cid)
- elseif msgcontains(msg, "job") then
- npcHandler:say("I am a priest. My work involves healing, helping citizens, welcoming new citizen.", cid)
- elseif Topic[t] == 2 then
- if msgcontains(msg, "yes") then
- npcHandler:say("So be it. You are now considered to be a member of our community.", cid)
- doSendMagicEffect(getPlayerPosition(cid), 11)
- doPlayerSetTown(cid, 1)
- setPlayerStorageValue(cid, 3003, 1)
- Topic[t] = nil
- else
- npcHandler:say("Another time.", cid)
- Topic[t] = nil
- end
- end
- return TRUE
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement