Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.96 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
  5. function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
  6. function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
  7. function onThink()                          npcHandler:onThink()                        end
  8. local talkState = {}
  9. local off_spell = "Immortal"
  10. local deff_spell = "Reflection"
  11. local talk_storage = 215231
  12. local kill_monster_offensive = [T]Goku
  13. local kill_monster_deffensive = [T]C17
  14.  
  15. function greetCallback(cid)
  16.     if getPlayerStorageValie(cid, talk_storage) < 0 then
  17.         npcHandler:setMessage(MESSAGE_GREET, "Hello "..getCreatureName(cid).." do you want to {learn} something new?")
  18.         npcHandler:addFocus(cid)
  19.     elseif getPlayerStorageValue(cid,talk_storage) == 0 then -- koniec
  20.         if getPlayerStorageValue(cid, kill_monster_offensive) == 0 then
  21.             npcHandler:say("You have to find and defeat: "..monster_off)   
  22.         end
  23.         if getPlayerStorageValue(cid, kill_monster_deffensive) == 0 then
  24.             npcHandler:say("You have to find and defeat: "..monster_def)       
  25.         end
  26.         npcHandler:addFocus(cid)
  27.         npcHandler:releaseFocus(cid)   
  28.     elseif getPlayerStorageValie(cid, talk_storage) == 1 then -- koniec
  29.         npcHandler:setMessage(MESSAGE_GREET, "Okay, boya.. Did you kill this {monster}?")
  30.         npcHandler:addFocus(cid)
  31.     elseif getPlayerStorageValie(cid, talk_storage) == 2 then -- koniec
  32.         npcHandler:say("I can not teach you anything more.")   
  33.         npcHandler:addFocus(cid)
  34.         npcHandler:releaseFocus(cid)
  35.     end
  36.  
  37. if(not npcHandler:isFocused(cid)) then
  38.     return false
  39. end
  40.     return true
  41. end
  42. function creatureSayCallback(cid, type, msg)
  43.     if(not npcHandler:isFocused(cid)) then
  44.         return false
  45.     end
  46.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  47.         if(msgcontains(msg, 'learn')) and getPlayerStorageValue(cid,talk_storage) < 0 then
  48.             selfSay("I create new techniques for cyborgs do you want to learn these ?{teach}.", cid)
  49.             talkState[talkUser] = 1
  50.         elseif(msgcontains(msg, 'teach')) and getPlayerStorageValue(cid,talk_storage) < 0 and talkState[talkUser] == 1 then
  51.             selfSay("Okay soo.. you want to learn the {offensive}, {deffensive} technique?", cid)
  52.             talkState[talkUser] = 2
  53.         elseif(msgcontains(msg, 'offensive')) and getPlayerStorageValue(cid,talk_storage) < 0 and talkState[talkUser] == 2 then
  54.             selfSay("text jakis tam... offensive", cid)
  55.             setPlayerStorageValue(cid, kill_monster_offensive, 0)
  56.             setPlayerStorageValue(cid,talk_storage, 0)
  57.             --talkState[talkUser] = 2      
  58.         elseif(msgcontains(msg, 'deffensive')) and getPlayerStorageValue(cid,talk_storage) < 0 and talkState[talkUser] == 2 then
  59.             selfSay("text jakis tam... deffensive", cid)
  60.             setPlayerStorageValue(cid, kill_monster_deffensive, 0)
  61.             setPlayerStorageValue(cid,talk_storage, 0)
  62.             --talkState[talkUser] = 2
  63.         elseif(msgcontains(msg, 'monster')) and getPlayerStorageValue(cid,talk_storage) == 1 then
  64.             if getPlayerStorageValue(cid, kill_monster_offensive) == 1 then
  65.                 selfSay("Okay you are strong you kill "..monster_off".. so i can learn you this spell right now!", cid)
  66.                 doPlayerLearnInstantSpell(cid, off_spell)
  67.                 doPlayerSendTextMessage(cid, 22,"You have new spell: "..off_spell..".")
  68.                 setPlayerStorageValue(cid,talk_storage, 2)
  69.             elseif getPlayerStorageValue(cid, kill_monster_deffensive) == 1 then
  70.                 selfSay("Okay you are strong you kill "..monster_def".. so i can learn you this spell right now!", cid)
  71.                 doPlayerLearnInstantSpell(cid, deff_spell)
  72.                 doPlayerSendTextMessage(cid, 22,"You have new spell: "..deff_spell..".")
  73.                 setPlayerStorageValue(cid,talk_storage, 2)
  74.             else
  75.                 selfSay("You dont kill this monster!", cid)
  76.             end
  77.         end
  78.     return true
  79. end
  80.  
  81. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
  82. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  83. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement