Jump to content

dxDrawImageSection - problem


Recommended Posts

Hi . I'm trying to make a new health bar, but i'm got stuck.

I'm trying to do it with relative positions, because i've tried with absolute position and at some resolution it works bad.

Photo is 485 x 425 px.

Maxim health is 12000. I can do it , but i don't know why it looks like this :

https://s32.postimg.org/krx2y33ad/mta_s ... _11_13.png

i'm trying to draw 200 px from that photo so :

my resolution is 1366*768

200/1366 = 0.1464

dxDrawImageSection(screenW * 0.6340, screenH * 0.0130, screenW *[ 0.1464], screenH * 0.5534, 0, 0, 425, 425, ":DayZ/images/health.png", 0, 0, 0, tocolor(r, g, b, 170), false) 

And it looks like this:

https://s32.postimg.org/krx2y33ad/mta_s ... _11_13.png

full photo (485px)

485px/1366 = 0.3551

dxDrawImageSection(screenW * 0.6340, screenH * 0.0130, screenW *  [0.3551], screenH * 0.5534, 0, 0, 425, 425, ":DayZ/images/health.png", 0, 0, 0, tocolor(r, g, b, 170), false) 

And it looks like this:

https://s31.postimg.org/wsr8ibe2z/mta_s ... _22_09.png

PS: i used "[,]" to make that number more visible.

Any help ? Please ?

Link to comment

Try this:

dxDrawImageSection(screenW * 0.6340, screenH * 0.0130, screenW *  0.3551, screenH * 0.5534, 0, 0, (getElementHealth(localPlayer)*425)/100, 425, ":DayZ/images/health.png", 0, 0, 0, tocolor(r, g, b, 170), false) 

Link to comment

You're not using it right, you're changing the width which is wrong. What you want to change is the parameter called usize.

Since you always have it at 425, it will draw the entire image. And since you're changing the overall width instead of the section length - it gets squeezed like the picture you showed.

Link to comment
Show us how you modified the code.
dxDrawImageSection(screenW * 0.6340, screenH * 0.0130, screenW *  0.3551, screenH * 0.5534, 0, 0, ((getElementData(getLocalPlayer(),"blood") or 0)*425)/12000, 425, ":DayZ/images/health.png", 0, 0, 0, tocolor(r, g, b, 170), false) 

My maximum health is 12000 . So if i will have maximum blood it will be 12000 * 425 / 12000 = 425. When i have 12k blood it is displayed fine . (see photos)

Link to comment

Sorry for the delay, not as active on these forums anymore. Try this;

dxDrawImageSection(screenW*0.6340, screenH*0.0130, screenW*0.3551, screenH*0.5534, 0, 0, (((getElementData(getLocalPlayer(),"blood") or 0)/12000)*425), 425, ":DayZ/images/health.png", 0, 0, 0, tocolor(r, g, b, 170), false) 

Link to comment
I fixed it . Not this was problem . But thanks anyway :D:D:wink:

Now i have another question :

Why at 3000 blood , it looks like 0 blood , i mean that health bar is empty . Why it is imprecise ?

Did you try what I posted above? Your issue was the math being incorrect, sounds like it still is.

Link to comment

Same problem .

I can't fix it fuck off.

Look , the code :

local x = (((getElementData(getLocalPlayer(),"blood") or 0)/12000)*485)/screenW 
    dxDrawImageSection(screenW * 0.6340, screenH * 0.0130, screenW *  x  , screenH * 0.5534, 0, 0,((getElementData(getLocalPlayer(),"blood") or 0)/12000)*425, 425, ":DayZ/images/health.png", 0, 0, 0, tocolor(r, g, b, 170), false) 
     

Image have resolution : 425x425 px.

But i want draw it at 485x425 px.

2 Problems :

1)

my resolution : (1366x768x32)

https://s31.postimg.org/6ujkt0rq3/mta_s ... _35_54.png

my friend resolution (1280x1024x32)

https://s32.postimg.org/8lht9awz9/mta_s ... _05_05.png

2)

at 3000 blood health bar is still empty .

I don't know how to fix this thing , i don't know why it works at me , but my friend have that visual bug ... .

PS :

getElementData(getLocalPlayer(),"blood") = 3000

(3000/12000)*485 = 121.25

(3000 * 485)/12000 = 121.25

It is the same thing , not this is the problem ... :(:cry::cry::cry:

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