Jump to content

[Help] DX animations


Artenos

Recommended Posts

Posted

Hello, so I'm using PaiN^'s [GIE] GUI Interpolate Effects resource (https://forum.multitheftauto.com/viewtopic.php?f=108&t=64608/viewtopic.php?f=108&t=64608) to add animations to my dxrectangle but everytime I run the script it outputs "Not GUI Element" does this mean it doesn't work with dx? if so is there any other way to give simple animations to dx elements?

this is the code

local screenW, screenH = guiGetScreenSize() 
------start---------------- 
startX =  screenW * 0.6486 
startY = screenH * 0.4583 
startW = screenW * 0.1208 
startH = screenH * 0.3151 
-----end------------------- 
endX = screenW * 0.8367 
endY = screenH * 0.4583 
endW = screenW * 0.1208 
endH = screenH * 0.3151 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        rec1 = dxDrawRectangle(screenW * 0.6486, screenH * 0.4583, screenW * 0.1208, screenH * 0.3151, tocolor(255, 255, 255, 255), false) 
        exports.gie.guiAddInterpolateEffect( rec1, startX, startY, startW, 
                         startH, endX, endY, endW, endH, 5, 
                         Linear, Linear, 
                         1 ) 
    end 
) 
  
  

  • Moderators
Posted

Atenos, what does dxDrawRectangle return?

You can find the answer here: https://wiki.multitheftauto.com/wiki/DxDrawRectangle

Which is also the answer why it doesn't work.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
Hello, so I'm using PaiN^'s [GIE] GUI Interpolate Effects resource (https://forum.multitheftauto.com/viewtopic.php?f=108&t=64608/viewtopic.php?f=108&t=64608) to add animations to my dxrectangle but everytime I run the script it outputs "Not GUI Element" does this mean it doesn't work with dx? if so is there any other way to give simple animations to dx elements?

this is the code

local screenW, screenH = guiGetScreenSize() 
------start---------------- 
startX =  screenW * 0.6486 
startY = screenH * 0.4583 
startW = screenW * 0.1208 
startH = screenH * 0.3151 
-----end------------------- 
endX = screenW * 0.8367 
endY = screenH * 0.4583 
endW = screenW * 0.1208 
endH = screenH * 0.3151 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        rec1 = dxDrawRectangle(screenW * 0.6486, screenH * 0.4583, screenW * 0.1208, screenH * 0.3151, tocolor(255, 255, 255, 255), false) 
        exports.gie.guiAddInterpolateEffect( rec1, startX, startY, startW, 
                         startH, endX, endY, endW, endH, 5, 
                         Linear, Linear, 
                         1 ) 
    end 
) 
  
  

yes it is not working with dx elements it works with gui elements only so if you want to make animations on the dx element you must use interpolateBetween

if you are interested in dx elements you can check my DirectX GUI tutorial

You can find me here.

Posted

example : #

local start = getTickCount() 
local one, one1 = 0, 0 
local two, two1 = 750, 680 
  
addEventHandler("onClientRender", root, 
function() 
    local now = getTickCount() 
    local width, height = interpolateBetween(one, one1, 0, two, two1, 0, (now - start) / ((start + 1500) - start), "Linear") 
    dxDrawRectangle(319, 109, width, height, tocolor(0, 0, 0, 130), false) 
end) 

Discord: LoOs#1111

_____________________________

76561198299431254.png

Posted

Thank you for the help guys

example : #
local start = getTickCount() 
local one, one1 = 0, 0 
local two, two1 = 750, 680 
  
addEventHandler("onClientRender", root, 
function() 
    local now = getTickCount() 
    local width, height = interpolateBetween(one, one1, 0, two, two1, 0, (now - start) / ((start + 1500) - start), "Linear") 
    dxDrawRectangle(319, 109, width, height, tocolor(0, 0, 0, 130), false) 
end) 

How would I do it so that it slides instead

like this:

x8pznTh.png?1

Posted
Thank you for the help guys
example : #
local start = getTickCount() 
local one, one1 = 0, 0 ---- The coordinates of the beginning 
local two, two1 = 750, 680 ---- The coordinates of the end 
  
addEventHandler("onClientRender", root, 
function() 
    local now = getTickCount() 
    local width, height = interpolateBetween(one, one1, 0, two, two1, 0, (now - start) / ((start + 1500) - start), "Linear") 
    dxDrawRectangle(319, 109, width, height, tocolor(0, 0, 0, 130), false) 
end) 

easy : #

local start = getTickCount() 
local one, one1 = 0, 0 ---- The coordinates of the beginning 
local two, two1 = 319, 109 ---- The coordinates of the end 
  
addEventHandler("onClientRender", root, 
function() 
    local now = getTickCount() 
    local x,y = interpolateBetween(one, one1, 0, two, two1, 0, (now - start) / ((start + 1500) - start), "Linear") 
    dxDrawRectangle(x,y, 680, 750, tocolor(0, 0, 0, 130), false) 
end) 

Discord: LoOs#1111

_____________________________

76561198299431254.png

Posted
Thank you for the help guys
example : #
local start = getTickCount() 
local one, one1 = 0, 0 ---- The coordinates of the beginning 
local two, two1 = 750, 680 ---- The coordinates of the end 
  
addEventHandler("onClientRender", root, 
function() 
    local now = getTickCount() 
    local width, height = interpolateBetween(one, one1, 0, two, two1, 0, (now - start) / ((start + 1500) - start), "Linear") 
    dxDrawRectangle(319, 109, width, height, tocolor(0, 0, 0, 130), false) 
end) 

easy : #

local start = getTickCount() 
local one, one1 = 0, 0 ---- The coordinates of the beginning 
local two, two1 = 319, 109 ---- The coordinates of the end 
  
addEventHandler("onClientRender", root, 
function() 
    local now = getTickCount() 
    local x,y = interpolateBetween(one, one1, 0, two, two1, 0, (now - start) / ((start + 1500) - start), "Linear") 
    dxDrawRectangle(x,y, 680, 750, tocolor(0, 0, 0, 130), false) 
end) 

I get it now the x,y and the width and height can be manipulated by the interpolate effect, easy enough. Thanks dude!.

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...