| 
				
				Создание полоски здоровья, меняющей цвет
				 | 
				
			  | 
 
|  
 |   
 
 
 
  
  
  
  
 
 
 
 
 
 
  
  
 | Статус: |  
  |  
   
  
 | : |  
  |  
  
 
  
 | Сообщений: |  
  |  
   
 
 
  
 
 
  
 
  
 | Регистрация: |  
  |  
   
 
 
 
 
 
  
 | 
 
 Для этого нам понадобятся стандартные файлы:   config/ui/maingame.xml   config/ui/ui_custom_msgs.xml   scripts/bind_stalker.script 
   1. Создаём файл new_hud_health.script в папке gamedata/scripts и пишем в него:   Код   local hud_name = "hud_health" 
   -- записываем переменную   function save_variable(variable_name, value)   xr_logic.pstor_store(db.actor, variable_name, value)   end 
   -- загружаем переменную   function load_variable(variable_name, value_if_not_found)   return xr_logic.pstor_retrieve(db.actor, variable_name, value_if_not_found)   end 
   -- удаляем переменную   function del_variable(variable_name)   if db.storage[db.actor:id()].pstor[variable_name] then   db.storage[db.actor:id()].pstor[variable_name] = nil   end   end 
   -- координаты(параметры) x, y, width, height   local pbg = {x=0,y=0,w=0,h=0} --/ bg   local plv = {x=0,y=0,w=0,h=0} --/ lv 
   local skl_w = -1 --/ текущая длина шкалы   local wide = false --/ текущий режим экрана 
   local color = 0   local change_color = false   local change_wpn = false   local hud_show = false 
   function update(bShow)   local hud = get_hud()   local cs_bg = hud:GetCustomStatic("hud_health_bg")   local cs_lv = hud:GetCustomStatic("hud_health_lv") 
   if (load_variable("opt_hp",true) == false or bShow == false) then   if cs_bg then hud:RemoveCustomStatic("hud_health_bg") end   if cs_lv then hud:RemoveCustomStatic("hud_health_lv") end   return   save_variable("opt_hp",false)   end 
   local hp = db.actor.health 
   if (hp == nil or hp == 0) then   if hud_show == false then --/ рамку можно не стирать при смене оружия   if cs_bg then hud:RemoveCustomStatic("hud_health_bg") end   end   if cs_lv then hud:RemoveCustomStatic("hud_health_lv") end   return   end 
   -- проверка смены режима экрана   if wide ~= db.wide then   wide = db.wide   if cs_bg then hud:RemoveCustomStatic("hud_health_bg") end   if cs_lv then hud:RemoveCustomStatic("hud_health_lv") end   cs_bg, cs_lv = nil, nil   end 
   local cur_hud = "hud_health_bg"   if cs_bg == nil then   hud:AddCustomStatic(cur_hud, true)   cs_bg = hud:GetCustomStatic(cur_hud)   local wnd = cs_bg:wnd()   if wnd then   pbg = read_params(cur_hud)   wnd:SetWndPos(pbg.x,pbg.y)   wnd:SetWidth (pbg.w)   wnd:SetHeight(pbg.h)   wnd:SetAutoDelete(true)   end   end 
   cur_hud = "hud_health_lv"   if cs_lv == nil then   hud:AddCustomStatic(cur_hud, true)   cs_lv = hud:GetCustomStatic(cur_hud)   local wnd = cs_lv:wnd()   if wnd ~= nil then   plv = read_params(cur_hud)   wnd:SetWndPos(pbg.x+plv.x,pbg.y+plv.y)   wnd:SetWidth (skl_w)   wnd:SetHeight(plv.h)   wnd:SetAutoDelete(true)   change_color = true --/ смена цвета   end   end 
   if cs_lv ~= nil then   local hp_w = math.floor(hp * plv.w)   if hp_w ~= skl_w then   if hp_w < 1 then   skl_w = -1   else   skl_w = hp_w   end   end   local texture_c = get_texture(hp)   local wnd = cs_lv:wnd()   wnd:SetWidth(skl_w) --/ Set Level Condition   wnd:InitTexture(texture_c) --/ Set ColorTexture   wnd:SetText(string.format(math.floor(hp*100+0.0001)).."%")   end 
   end 
   function read_params(cur_hud)   local ltx = ini_file("scripts\\new_hud_health.ltx")   local section = cur_hud   if wide then section = section.."_wide" end   if ltx and ltx:section_exist(section) then   local p = {x=0,y=0,w=0,h=0}   local result, idx, value, i   for i=0, ltx:line_count(section)-1 do   result, idx, value = ltx:r_line(section, i, "", "")   if idx == "x" then   p.x = tonumber(value)   elseif idx == "y" then   p.y = tonumber(value)   elseif idx == "width" then   p.w = tonumber(value)   elseif idx == "height" then   p.h = tonumber(value)   end   end   return p   end   end 
   function get_texture(hp)   local textures = {   [0] = "ui_mg_progress_efficiency_full", --/ зеленая   [1] = "ui_hud_shk_car", --/ оранжевая   [2] = "ui_hud_shk_health" --/ красная   }   local clr = 0 --/ current color   if hp > 0.7 then clr = 0   elseif hp > 0.3 then clr = 1   elseif hp < 0.3 then clr = 2   end   if color ~= clr then   color = clr   change_color = true   else   change_color = false   end   return textures[color]   end 
   2. Создаём файл new_hud_health.ltx в папке gamedata/config/scripts и пишем в него: 
   [hud_health_bg]   x = 860   y = 660   width = 155   height = 34 
   [hud_health_lv]   x = 33   y = 5   width = 110   height = 10 
   [hud_health_bg_wide]   x = 900   y = 660   width = 123   height = 34 
   [hud_health_lv_wide]   x = 24   y = 5   width = 84   height = 10 
   3. В файле ui_custom_msgs.xml прописываем: 
   <hud_health_bg x="0" y="0" width="1" height="1" stretch="1" complex_mode="1">   <texture>ui_hud_shkala_health</texture>   </hud_health_bg>   <hud_health_lv x="0" y="0" stretch="1" complex_mode="1">   <texture><!-- заглушка --></texture>   <text x="85" y="0" font="arial_14" r="255" g="255" b="255" a="255" ttl="8" complex_mode="1"/>   </hud_health_lv> 
   4. Открываем файл maingame.xml 
   находим строчки:   <static_health ....>   .....   </static_health> 
   и 
   <progress_bar_health ...>   ....   </progress_bar_health> 
   выделяем и заменяем на следущее: 
   <static_health x="860" y="660" width="155" height="34">   <texture></texture>   <auto_static x="5" y="10" width="19" height="18">   <texture></texture>   </auto_static>   </static_health>   <progress_bar_health x="33" y="5" width="110" height="10" horz="1" min="0" max="100" pos="0">   <progress>   <texture></texture>   </progress>   </progress_bar_health> 
   5. Открываем файл bind_stalker.script и пишем после: 
   .....   level_tasks.add_lchanger_location() 
   self.bCheckStart = false   end 
   следущее:   new_hud_health.update() 
   после этой строчки должно стоять end, проверьте 
   Автор неизвестен  
 
 
 |  
   
 
 
 
 
 
 
  
 
   
 |   
  
Пятница, 27.05.2011, 19:31  
 
|  
 |   
 
 
 
  
  
  
  
 
  
  
 | Статус: |  
  |  
   
  
 | Сообщений: |  
 666 |  
   
  
 | Регистрация: |  
  |  
   
  
    
  |  
 
 |  
   
  
 |  
  | 
 
|  
 |   
 
 
 
  
  
  
  
 
 
 
 
 
 
  
  
 | Статус: |  
   |  
   
  
 | Отмычка: |  
   |  
  
 
  
 | Сообщений: |  
 119 |  
   
 
 
 
  
 | Награды: |  
 4 |  
   
 
 
  
 
  
 | Регистрация: |  
 24.12.2010 |  
   
 
 
 
 
 
  
 | 
 
 Нужная вещь  
 
 
 |  
   
 
   
 |   
  
Пятница, 27.05.2011, 20:09  
 
|  
 |   
 
 
 
  
  
  
  
 
  
  
 | Статус: |  
   |  
   
  
 | Сообщений: |  
 666 |  
   
  
 | Регистрация: |  
 24.12.2010 |  
   
  
    
  |  
 
 |  
   
  
 |  
  | 
 
|  
 |   
 
 
 
 
    Jakoro  
Суббота, 18.06.2011, 15:56 | Сообщение # 3 
   
  
  
  
  
  
 
 
 
 
 
 
  
  
 | Статус: |  
   |  
   
  
 | Отмычка: |  
   |  
  
 
  
 | Сообщений: |  
 154 |  
   
 
 
 
  
 | Награды: |  
 0 |  
   
 
 
  
 
  
 | Регистрация: |  
 27.05.2011 |  
   
 
 
 
 
 
  
 | 
 
 красиво жаль на зп не работает  
 
Сообщение отредактировал Jakoro - Суббота, 18.06.2011, 15:57  
 |  
   
 
   
 |   
  
Суббота, 18.06.2011, 15:56  
 
|  
 |   
 
 
 
  
  
  
  
 
  
  
 | Статус: |  
   |  
   
  
 | Сообщений: |  
 666 |  
   
  
 | Регистрация: |  
 27.05.2011 |  
   
  
    
  |  
 
 |  
   
  
 |  
  | 
 
|  
 |   
 
 
 
 
    kaizer96  
Суббота, 18.06.2011, 17:04 | Сообщение # 4 
   
  
  
  
  
  
 
 
 
 
 
 
  
  
 | Статус: |  
   |  
   
  
 | Неопытный: |  
   |  
  
 
  
 | Сообщений: |  
 575 |  
   
 
 
 
  
 | Награды: |  
 2 |  
   
 
 
  
 
  
 | Регистрация: |  
 25.12.2010 |  
   
 
 
 
 
 
  
 | 
 
 
 
 
 |  
   
 
   
 |   
  
Суббота, 18.06.2011, 17:04  
 
|  
 |   
 
 
 
  
  
  
  
 
  
  
 | Статус: |  
   |  
   
  
 | Сообщений: |  
 666 |  
   
  
 | Регистрация: |  
 25.12.2010 |  
   
  
    
  |  
 
 |  
   
  
 |  
  | 
 
|  
 |   
 
 
 
 
    Tris  
Суббота, 25.06.2011, 12:20 | Сообщение # 5 
   
  
  
  
  
  
 
 
 
 
 
Dead Forgetting Zone 
 
  
  
 | Статус: |  
   |  
   
  
 | Бывалый: |  
   |  
  
 
  
 | Сообщений: |  
 914 |  
   
 
 
 
  
 | Награды: |  
 3 |  
   
 
 
  
 
  
 | Регистрация: |  
 12.06.2011 |  
   
 
 
 
 
 
  
 | 
 
 Nikitos817, А на ЗП нельзя адаптировать?  
 
 
 |  
   
 
   
 |   
  
Суббота, 25.06.2011, 12:20  
 
|  
 |   
 
 
 
  
  
  
  
 
  
  
 | Статус: |  
   |  
   
  
 | Сообщений: |  
 666 |  
   
  
 | Регистрация: |  
 12.06.2011 |  
   
  
    
  |  
 
 |  
   
  
 |  
  | 
 
|  
 |   
 
 
 
 
    123new  
Четверг, 30.06.2011, 17:22 | Сообщение # 6 
   
  
  
  
  
  
 
 
 
 
 
 
  
  
 | Статус: |  
   |  
   
  
 | Отмычка: |  
   |  
  
 
  
 | Сообщений: |  
 102 |  
   
 
 
 
  
 | Награды: |  
 0 |  
   
 
 
  
 
  
 | Регистрация: |  
 30.06.2011 |  
   
 
 
 
 
 
  
 | 
 
 Ребята, Спасибо за скрипт. очень удобный. есть вопросик по нему:   Как выставить длинну ширину и высоту свою для этого скрипта? а то на моём экране полоска еле видная)   Длина устраивает а ширина вот ...  
 
 
 |  
   
 
   
 |   
  
Четверг, 30.06.2011, 17:22  
 
|  
 |   
 
 
 
  
  
  
  
 
  
  
 | Статус: |  
   |  
   
  
 | Сообщений: |  
 666 |  
   
  
 | Регистрация: |  
 30.06.2011 |  
   
  
    
  |  
 
 |  
   
  
 |  
  | 
 
|  
 |   
 
 
 
 
    VIRUS96  
Воскресенье, 03.07.2011, 11:56 | Сообщение # 7 
   
  
  
  
  
  
 
 
 
 
 
 
  
  
 | Статус: |  
   |  
   
  
 | Опытный: |  
   |  
  
 
  
 | Сообщений: |  
 1887 |  
   
 
 
 
  
 | Награды: |  
 2 |  
   
 
 
  
 
  
 | Регистрация: |  
 15.11.2010 |  
   
 
 
 
 
 
  
 | 
 
123new, вот тут   Code 2. Создаём файл new_hud_health.ltx в папке gamedata/config/scripts и пишем в него: 
   [hud_health_bg]   x = 860   y = 660   width = 155   height = 34 
   [hud_health_lv]   x = 33   y = 5   width = 110   height = 10 
   [hud_health_bg_wide]   x = 900   y = 660   width = 123   height = 34 
   [hud_health_lv_wide]   x = 24   y = 5   width = 84   height = 10    
   width значит длина, height значит ширина, меняй значения ширины.  
 
 
 |  
   
 
   
 |   
  
Воскресенье, 03.07.2011, 11:56  
 
|  
 |   
 
 
 
  
  
  
  
 
  
  
 | Статус: |  
   |  
   
  
 | Сообщений: |  
 666 |  
   
  
 | Регистрация: |  
 15.11.2010 |  
   
  
    
  |  
 
 |  
   
  
 |  
  | 
 
|  
 |   
 
 
 
 
    123new  
Воскресенье, 03.07.2011, 16:23 | Сообщение # 8 
   
  
  
  
  
  
 
 
 
 
 
 
  
  
 | Статус: |  
   |  
   
  
 | Отмычка: |  
   |  
  
 
  
 | Сообщений: |  
 102 |  
   
 
 
 
  
 | Награды: |  
 0 |  
   
 
 
  
 
  
 | Регистрация: |  
 30.06.2011 |  
   
 
 
 
 
 
  
 | 
 
 VIRUS96, благодарю  
 
 
 |  
   
 
   
 |   
  
Воскресенье, 03.07.2011, 16:23  
 
|  
 |   
 
 
 
  
  
  
  
 
  
  
 | Статус: |  
   |  
   
  
 | Сообщений: |  
 666 |  
   
  
 | Регистрация: |  
 30.06.2011 |  
   
  
    
  |  
 
 |  
   
  
 |  
  | 
 
|  
 |   
 
 
 
 
    Dik_lu  
Суббота, 23.06.2012, 12:45 | Сообщение # 9 
   
  
  
  
 
   
 |   
  
Суббота, 23.06.2012, 12:45  
 
|  
 |   
 
 
 
  
  
  
  
 
  
  
 | Статус: |  
   |  
   
  
 | Сообщений: |  
 666 |  
   
  
 | Регистрация: |  
 22.06.2012 |  
   
  
    
  |  
 
 |  
   
  
 |  
  | 
| 
 Пятница, 31.08.2012, 18:38  
 
|  
 |   
 
 
 
  
  
  
  
 
  
  
 | Статус: |  
   |  
   
  
 | Сообщений: |  
 666 |  
   
  
 | Регистрация: |  
 14.06.2012 |  
   
  
    
  |  
 
 |  
   
  
 |  
  |