Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.39 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4.  
  5. local Topic = {}
  6.  
  7. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  8. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  9. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  10. function onThink() npcHandler:onThink() end
  11.  
  12. function greetCallback(cid)
  13.     if getPlayerStorageValue(cid, 66666) > 0 then
  14.         npcHandler:setMessage(MESSAGE_GREET, "Be greeted, |PLAYERNAME|! It's so good to see you again. Should I {bless} you today?")
  15.     else
  16.         npcHandler:setMessage(MESSAGE_GREET, "Welcome to the Stonegate Temple, |PLAYERNAME|. Are you a {citizen} of Stonegate?")
  17.     end
  18.     topic = nil
  19.     return true
  20. end
  21.  
  22. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
  23.  
  24. function creatureSayCallback(cid, type, msg)
  25.  
  26.     if(not npcHandler:isFocused(cid)) then
  27.         return false
  28.     end
  29.        
  30.     local t = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  31.     local delayTime = 3*1000
  32.     local v = getPlayerStorageValue(cid, 3001)
  33.    
  34.     if msgcontains(msg, "bless") then
  35.         if getPlayerStorageValue(cid, 66666) > 0 then
  36.             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)
  37.             Topic[t] = 9
  38.         end
  39.     elseif Topic[t] == 9 then
  40.         if msgcontains(msg, "yes") then
  41.             local blessing = {1, 2, 3, 4, 5}
  42.             for i = 1, #blessing do
  43.                 if not getPlayerBlessing(cid, blessing[i]) then
  44.                     if doPlayerRemoveMoney(cid, 50000) == TRUE then
  45.                         npcHandler:say("By the powers invested in me be blessed!", cid)
  46.                         doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
  47.                         doPlayerAddBlessing(cid, blessing[i])
  48.                         Topic[t] = nil
  49.                     else
  50.                         npcHandler:say("I am sorry but you do not have enough gold.", cid)
  51.                         Topic[t] = nil 
  52.                     end                
  53.                 else
  54.                     npcHandler:say("I think you are getting a bit old, you already posses my blessing.", cid)
  55.                     Topic[t] = nil
  56.                 end
  57.             end
  58.         else
  59.             npcHandler:say("I understand, stay strong!", cid)
  60.             Topic[t] = nil 
  61.         end
  62.     elseif isInArray({"citizen", "task", "mission", "quest"}, msg:lower()) then
  63.         if getPlayerStorageValue(cid, 3002) > 0 then
  64.             npcHandler:say("Would you like to become a citizen of our city, ".. getPlayerName(cid) .."?", cid)
  65.             Topic[t] = 2
  66.         elseif getPlayerStorageValue(cid, 3001) == 50 then
  67.             npcHandler:say("Woah! Great job ".. getPlayerName(cid) .."! You really did it. You are free to join our city at anytime.", cid)
  68.             doPlayerAddExperience(cid, 5000)
  69.             setPlayerStorageValue(cid, 3002, 1)
  70.         elseif getPlayerStorageValue(cid, 3000) > 0 then
  71.             npcHandler:say("You haven't killed enough trolls, you need to kill ".. (50 - v) .." more.", cid)
  72.         elseif getPlayerStorageValue(cid, 3002) < 1 then
  73.             npcHandler:say("Hmm... I don't know young ".. getPlayerName(cid) ..", I can't just let you in to our town without testing you ...", cid)
  74.             npcHandler:say("Would you like to take a citizen test, ".. getPlayerName(cid).."?", cid,3000) Topic[t] = 1     
  75.         end
  76.     elseif Topic[t] == 1 then
  77.         if msgcontains(msg, "yes") then
  78.             npcHandler:say("Okay listen, we've spotted some troll activity to the north-east our city ...", cid)
  79.             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)
  80.             setPlayerStorageValue(cid, 3000, 1)
  81.             setPlayerStorageValue(cid, 3001, 0)
  82.             Topic[t] = nil
  83.         else
  84.             npcHandler:say("Hmm... I guess you'll just be a visitor for now then.", cid)
  85.             Topic[t] = nil
  86.         end
  87.     elseif msgcontains(msg, "name") then
  88.         npcHandler:say("My name is Benedict", cid)    
  89.     elseif msgcontains(msg, "job") then
  90.         npcHandler:say("I am a priest. My work involves healing, helping citizens, welcoming new citizen.", cid)      
  91.     elseif Topic[t] == 2 then
  92.         if msgcontains(msg, "yes") then
  93.             npcHandler:say("So be it. You are now considered to be a member of our community.", cid)
  94.             doSendMagicEffect(getPlayerPosition(cid), 11)
  95.             doPlayerSetTown(cid, 1)
  96.             setPlayerStorageValue(cid, 3003, 1)
  97.             Topic[t] = nil
  98.         else
  99.             npcHandler:say("Another time.", cid)
  100.             Topic[t] = nil
  101.         end
  102.     end
  103.     return TRUE
  104. end
  105. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  106. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement