Jump to content

Как сделать анимацию в HP Bar`е


Recommended Posts

Пишу худ , и не могу ничего найти , как сделать плавное отбавление хп. Что находил скрипты с анимацией , везде используются js скрипты.Но я надеюсь что эту анимацию можно сделать как то по другому из за этого пишу сюда.

Link to comment
local screenX, screenY = guiGetScreenSize()
local px, py = screenX/1920, screenY/1080
local sizeX, sizeY = 345*px, 90*py
local posX, posY = screenX - sizeX - 20*px, 10*py

local width = interpolateBetween(
		posX+171*px, posY+46*py, 0, 
		130*px/100*healthPlayer, 6*py, 0,
		1,"InOutBack")
	dxDrawRectangle(posX+171*px, posY+46*py, width, 6*py, tocolor(230,78,78,230))

Вот условно код , бара для худа. Полоска уменьшается и увеличивается , но без анимации. Пытался менять strEasingType , но ничего не вышло, я вот думаю что это fProgress(цифра "1" перед "InOutBck") , но она как будто увеличивает размер, я прочитал описание этого параметра , и не особо понял. Хотел попросить по подробнее объяснить насчет этой цифры , и хотелось бы понять что не так , заранее спасибо

Link to comment
local screenX, screenY = guiGetScreenSize()
local px, py = screenX/1920, screenY/1080
local sizeX, sizeY = 345*px, 90*py
local posX, posY = screenX - sizeX - 20*px, 10*py

local prevHP = 0
local width = 130*px
local speedAnim = 0.5

addEventHandler ("onClientRender", root, function()
	local curHP = getElementHealth(localPlayer)
	
	if prevHP ~= curHP then
		-- prevHP = curHP
		if prevHP < curHP then
			prevHP = math.min(curHP, prevHP + speedAnim)
		else
			prevHP = math.max(curHP, prevHP - speedAnim)
		end
	end
	
	dxDrawRectangle(posX+171*px, posY+46*py, width*(prevHP/getPedMaxHealth(localPlayer)), 6*py, tocolor(230,78,78,230))
end)

function getPedMaxHealth(ped)
    assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]")
    local stat = getPedStat(ped, 24)
    local maxhealth = 100 + (stat - 569) / 4.31
    return math.max(1, maxhealth)
end

getPedMaxHealth это функция с вики.
Чтобы менять скорость анимации меняй speedAnim

Edited by AngelAlpha
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...