Ermack Posted October 3, 2022 Share Posted October 3, 2022 Пишу худ , и не могу ничего найти , как сделать плавное отбавление хп. Что находил скрипты с анимацией , везде используются js скрипты.Но я надеюсь что эту анимацию можно сделать как то по другому из за этого пишу сюда. Link to comment
Scripting Moderators Sarrum Posted October 5, 2022 Scripting Moderators Share Posted October 5, 2022 . Перенёс тему в более подходящий раздел. Попробуйте использовать функцию interpolateBetween. Примеры есть на странице вики. Link to comment
Ermack Posted October 7, 2022 Author Share Posted October 7, 2022 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
AngelAlpha Posted October 8, 2022 Share Posted October 8, 2022 (edited) 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 October 8, 2022 by AngelAlpha Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now