Shark_vil

QSystem - Example Medic Dialogue

Apr 20th, 2021 (edited)
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.11 KB | None | 0 0
  1. local conversation = {
  2.     id = 'free_medic',
  3.     name = 'Вольный медик',
  4.     autoParent = true,
  5.     isRandomNpc = true,
  6.     randomNumber = 2,
  7.     class = 'npc_citizen',
  8.     condition = function(ply, npc)
  9.         if not bgNPC then
  10.             local actor = bgNPC:GetActor(npc)
  11.             if actor then return actor:HasTeam('medic') end
  12.         end
  13.  
  14.         return string.find(npc:GetModel():lower(), '/male_') ~= nil
  15.     end,
  16.     steps = {
  17.         start = {
  18.             text = {
  19.                 'Ты что-то хотел?',
  20.                 'А?..',
  21.                 'Чего надо?',
  22.                 'Да-да?',
  23.                 'Я слушаю.',
  24.                 'Чего хотели?'
  25.             },
  26.             delay = 3,
  27.             event = function(eDialogue)
  28.                 if CLIENT and eDialogue.isFirst then
  29.                     eDialogue:VoiceSay('vo/canals/matt_go_nag01.wav')
  30.                 end
  31.             end,
  32.             answers = {
  33.                 {
  34.                     text = {
  35.                         'Ничего, простите.',
  36.                         'Обознался.'
  37.                     },
  38.                     condition = function(eDialogue)
  39.                         local lock_health = eDialogue:GetPlayerValue('lock_health')
  40.                         return lock_health == nil
  41.                     end,
  42.                     event = function(eDialogue)
  43.                         if SERVER then eDialogue:Next('exit') end
  44.                     end
  45.                 },
  46.                 {
  47.                     text = 'Больше ничего не нужно, пока.',
  48.                     condition = function(eDialogue)
  49.                         local lock_health = eDialogue:GetPlayerValue('lock_health')
  50.                         return lock_health ~= nil
  51.                     end,
  52.                     event = function(eDialogue)
  53.                         if SERVER then eDialogue:Next('exit_2') end
  54.                     end
  55.                 },
  56.                 {
  57.                     text = 'Вылечи меня пожалуйста',
  58.                     event = function(eDialogue)
  59.                         if SERVER then
  60.                             local ply = eDialogue:GetPlayer()
  61.  
  62.                             if ply:Health() < 90 then
  63.                                 local lock_health = eDialogue:GetPlayerValue('lock_health')
  64.                                 if lock_health ~= nil and tonumber(lock_health) > os.time() then
  65.                                     eDialogue:Next('rejection_health')
  66.                                 else
  67.                                     if engine.ActiveGamemode() == 'darkrp' and ply:getDarkRPVar('money') < 100 then
  68.                                         eDialogue:Next('few_money')
  69.                                         return
  70.                                     end
  71.  
  72.                                     eDialogue:Next('get_health')
  73.                                 end
  74.                             else
  75.                                 eDialogue:Next('failed_health')
  76.                             end
  77.                         end
  78.                     end
  79.                 },
  80.             },
  81.         },
  82.         few_money = {
  83.             text = 'Ага, а деньги то есть?... Чего, и всего? Этого мало. Зайди когда на руках будет хотяб сотня...',
  84.             delay = 6,
  85.             eventDelay = function(eDialogue)
  86.                 if SERVER then eDialogue:Next('start', true) end
  87.             end
  88.         },
  89.         rejection_health = {
  90.             text = 'Я тебя уже подлатал, у меня и другие клиенты есть. Можешь зайти позднее.',
  91.             delay = 5,
  92.             eventDelay = function(eDialogue)
  93.                 if SERVER then eDialogue:Next('start', true) end
  94.             end
  95.         },
  96.         get_health = {
  97.             text = 'Ладно. Сейчас мы тебя починим. Вот так... И тут... Готово!',
  98.             delay = 4,
  99.             eventDelay = function(eDialogue)
  100.                 if SERVER then
  101.                     local ply = eDialogue:GetPlayer()
  102.                     local health = ply:Health()
  103.                     local new_health = health + math.random(10, 50)
  104.  
  105.                     if new_health < 100 then
  106.                         ply:SetHealth(new_health)
  107.                     else
  108.                         ply:SetHealth(100)
  109.                     end
  110.  
  111.                     if engine.ActiveGamemode() == 'darkrp' then
  112.                         ply:addMoney(-100)
  113.                     end
  114.  
  115.                     eDialogue:SavePlayerValue('lock_health', os.time() + 60)
  116.                     eDialogue:Next('start', true)
  117.                 end
  118.             end
  119.         },
  120.         failed_health = {
  121.             text = 'Ты не выглядишь таким уж помятым. Обойдёшься.',
  122.             delay = 4,
  123.             eventDelay = function(eDialogue)
  124.                 if SERVER then eDialogue:Next('start', true) end
  125.             end
  126.         },
  127.         exit = {
  128.             text = {
  129.                 'Ебать ты...',
  130.                 'Зря время отнимаешь',
  131.                 'Ну тебя...',
  132.                 'Ладно.',
  133.                 'Ладно. Всего доброго',
  134.                 'Ну бывай'
  135.             },
  136.             delay = 3,
  137.             eventDelay = function(eDialogue)
  138.                 if CLIENT then
  139.                     eDialogue:VoiceSay('vo/canals/gunboat_dam.wav')
  140.                 else
  141.                     eDialogue:Stop()
  142.                 end
  143.             end
  144.         },
  145.         exit_2 = {
  146.             text = {
  147.                 'Ладно.',
  148.                 'Ладно. Всего доброго',
  149.                 'Всего доброго',
  150.                 'Ну бывай'
  151.             },
  152.             delay = 3,
  153.             eventDelay = function(eDialogue)
  154.                 if SERVER then eDialogue:Stop() end
  155.             end
  156.         }
  157.     }
  158. }
  159. list.Set('QuestSystemDialogue', conversation.id, conversation)
Add Comment
Please, Sign In to add comment