Fonseca_ Posted August 17, 2021 Posted August 17, 2021 Estou tentando animar os status de uma hud ("vida, colete, etc."), alguem poderia me ajudar ? estou usando interpolateBetween porem não consigo fazer as animações quando o player sofre dano e ganha vida, entre outros
Blaack Posted August 17, 2021 Posted August 17, 2021 41 minutes ago, Fonseca_ said: Estou tentando animar os status de uma hud ("vida, colete, etc."), alguem poderia me ajudar ? estou usando interpolateBetween porem não consigo fazer as animações quando o player sofre dano e ganha vida, entre outros Como você tentou fazer? nos mostre o código...
Fonseca_ Posted August 17, 2021 Author Posted August 17, 2021 47 minutes ago, Blaack said: Como você tentou fazer? nos mostre o código... tick = getTickCount() function teste() local health = getElementHealth(getLocalPlayer()) local animteste = interpolateBetween(0, 0, 0, health, 0, 0, (getTickCount() - tick)/1000, "Linear") dxDrawRectangle(x*1080, y*740, x*80/100*animteste, y*30, tocolor(255, 255, 255, 255), false) end obs: o codigo ai não pegou o Spoiler Spoiler addEventHandler("onClientRender", root, teste)
Other Languages Moderators androksi Posted August 18, 2021 Other Languages Moderators Posted August 18, 2021 Olá! Primeiro de tudo, você precisa atualizar o intervalo de tempo (tick). Para isso, você pode usar o evento onClientPlayerDamage, anexado no localPlayer. Também, são necessárias algumas variáveis para salvar o estado atual da vida. Fiz um código de exemplo, que você pode usar para fazer o colete também. local screenX, screenY = guiGetScreenSize() local barWidth, barHeight = 220, 20 local barX, barY = screenX / 2 - barWidth / 2, screenY - (barHeight + 10) local changeTick = 0 local currentHealth = getElementHealth(localPlayer) local playerHealth = currentHealth addEventHandler("onClientPlayerDamage", localPlayer, function(_, _, _, loss) if loss > 0 then changeTick = getTickCount() end end) addEventHandler("onClientRender", root, function() local changeHealth = getElementHealth(localPlayer) if changeHealth ~= currentHealth then playerHealth = interpolateBetween(currentHealth, 0, 0, getElementHealth(localPlayer), 0, 0, (getTickCount() - changeTick) / 800, "InOutQuad") if playerHealth == changeHealth then currentHealth = changeHealth end end dxDrawRectangle(barX, barY, barWidth, barHeight, tocolor(20, 21, 22, 200), false) dxDrawRectangle(barX, barY, barWidth * (playerHealth / 100), barHeight, tocolor(255, 55, 55, 255), false) dxDrawRectangle(barX, barY, barWidth * (changeHealth / 100), barHeight, tocolor(255, 255, 255, 255), false) end) Demonstração: https://streamable.com/jnyky9 1
Fonseca_ Posted August 18, 2021 Author Posted August 18, 2021 5 hours ago, androksi said: Olá! Primeiro de tudo, você precisa atualizar o intervalo de tempo (tick). Para isso, você pode usar o evento onClientPlayerDamage, anexado no localPlayer. Também, são necessárias algumas variáveis para salvar o estado atual da vida. Fiz um código de exemplo, que você pode usar para fazer o colete também. local screenX, screenY = guiGetScreenSize() local barWidth, barHeight = 220, 20 local barX, barY = screenX / 2 - barWidth / 2, screenY - (barHeight + 10) local changeTick = 0 local currentHealth = getElementHealth(localPlayer) local playerHealth = currentHealth addEventHandler("onClientPlayerDamage", localPlayer, function(_, _, _, loss) if loss > 0 then changeTick = getTickCount() end end) addEventHandler("onClientRender", root, function() local changeHealth = getElementHealth(localPlayer) if changeHealth ~= currentHealth then playerHealth = interpolateBetween(currentHealth, 0, 0, getElementHealth(localPlayer), 0, 0, (getTickCount() - changeTick) / 800, "InOutQuad") if playerHealth == changeHealth then currentHealth = changeHealth end end dxDrawRectangle(barX, barY, barWidth, barHeight, tocolor(20, 21, 22, 200), false) dxDrawRectangle(barX, barY, barWidth * (playerHealth / 100), barHeight, tocolor(255, 55, 55, 255), false) dxDrawRectangle(barX, barY, barWidth * (changeHealth / 100), barHeight, tocolor(255, 255, 255, 255), false) end) Demonstração: https://streamable.com/jnyky9 Perfeito, estou a procura de um evento ao contrario do onClientPlayerDamage para eu fazer a parte de subir a vida com animação, porem não encontro nenhum tipo de evento que me auxilie nisso, será que é possivel fazer ? ou somente por HTML
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