stefutz101 Posted June 23, 2016 Share Posted June 23, 2016 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
Sasu Posted June 23, 2016 Share Posted June 23, 2016 You're modifying the width of the image but not the width of the section you're taking from the image. Link to comment
stefutz101 Posted June 24, 2016 Author Share Posted June 24, 2016 Ok , and how i can fix that ? Can someone give me an example how i must draw 200 px from that image ? Link to comment
Sasu Posted June 24, 2016 Share Posted June 24, 2016 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
Dealman Posted June 24, 2016 Share Posted June 24, 2016 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
stefutz101 Posted June 25, 2016 Author Share Posted June 25, 2016 Yah it works but it don't works like i want . Why the image is moving in right once my health is decreasesing ? http://postimg.org/gallery/f30r61s2/ Any help ? This was my real problem , i don't know how to fix that , first time i think i was doing something wrong , but why the image leave that border ? Link to comment
Sasu Posted June 25, 2016 Share Posted June 25, 2016 Show us how you modified the code. Link to comment
stefutz101 Posted June 25, 2016 Author Share Posted June 25, 2016 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
stefutz101 Posted June 26, 2016 Author Share Posted June 26, 2016 So anyone know where the mistake came from ? Link to comment
Dealman Posted June 26, 2016 Share Posted June 26, 2016 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
stefutz101 Posted June 26, 2016 Author Share Posted June 26, 2016 I fixed it . Not this was problem . But thanks anyway 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 ? Link to comment
Dealman Posted June 26, 2016 Share Posted June 26, 2016 I fixed it . Not this was problem . But thanks anyway 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
stefutz101 Posted June 26, 2016 Author Share Posted June 26, 2016 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 ... Link to comment
Dealman Posted June 26, 2016 Share Posted June 26, 2016 You're changing the width as well, don't do that. Only usize. Link to comment
stefutz101 Posted June 26, 2016 Author Share Posted June 26, 2016 From : https://forum.multitheftauto.com/viewtopic.php?f=91&t=28106 Look. That's why i changed the image width. Still i don't have any ideea how to fix that. Link to comment
stefutz101 Posted June 27, 2016 Author Share Posted June 27, 2016 Fixed . Thanks to anyone what was trying to help me . 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