Xierra Posted June 3, 2010 Share Posted June 3, 2010 (edited) Hi guys once again. I want to make a new script, which is putting a bar. I know about the healthbar as seen on the nametag. But If I want to make my own, how? Any ideas? (And of course not progress bar on GUI) And if you are grateful, is it possible to put custom bars on a GUI window? Edited June 4, 2010 by Guest Link to comment
loler Posted June 3, 2010 Share Posted June 3, 2010 When i know good than you can use dxDrawText and getElementHealth and getPlayerArmor dxDrawText : https://wiki.multitheftauto.com/wiki/DxDrawText getElementHealth: https://wiki.multitheftauto.com/wiki/GetElementHealth getPlayerArmor: https://wiki.multitheftauto.com/wiki/GetPlayerArmor Good luck! Link to comment
Xierra Posted June 3, 2010 Author Share Posted June 3, 2010 Yeah, I already knew how to make it with text. But how if using a bar instead of text? Link to comment
loler Posted June 3, 2010 Share Posted June 3, 2010 You want it as bar form? lol srry i didnt knew it ,here i dont know how to help you i thinked only to show a player his health so: Health:getElementHealth Armor:getPlayerArmor Here it is a example: local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() local playerHealth = getElementHealth(player) local playerArmor = getPlayerArmor(player) function createText( ) dxDrawText( playerHealth, 44, screenHeight-41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) dxDrawText( playerArmor, 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) -- etc im to lazy Link to comment
50p Posted June 3, 2010 Share Posted June 3, 2010 XX3, you may find this useful: https://community.multitheftauto.com/index.php?p= ... ils&id=234 I made it as an example to show people how to make peds that follow you but I also added health bars which can be shown/hidden. Link to comment
Xierra Posted June 3, 2010 Author Share Posted June 3, 2010 (edited) Ahh thanks for the reference. I'll take a look. Thanks 50p (and your peds script, it's cool!) Edit: I have made it! Sucess! But It only renders once, how should I make it update everytime when I reduced my health or armor? Script (client): local health = getElementHealth( getLocalPlayer() ) local lineLength1 = 114 * ( health / 100 ) local armor = getPedArmor( getLocalPlayer() ) local lineLength2 = 114 * ( armor / 100 ) -- Direct X Drawings addEventHandler("onClientRender",getRootElement(), function() dxDrawText("50",646.0,731.0,694.0,766.0,tocolor(0,255,255,175),1.0,"bankgothic","right","top",false,false,false) dxDrawRectangle(818.0,725.0,lineLength2,14.0,tocolor(200,200,200,200),true) dxDrawRectangle(818.0,745.0,114.0,14.0,tocolor(50,0,0,150),false) dxDrawText("50",684.0,731.0,732.0,766.0,tocolor(0,255,255,175),1.0,"bankgothic","left","top",false,false,false) dxDrawText("|",665.0,731.0,677.0,762.0,tocolor(255,200,0,200),1.0,"bankgothic","left","top",false,false,false) dxDrawText("50",611.0,731.0,659.0,766.0,tocolor(0,255,255,175),1.0,"bankgothic","right","top",false,false,false) dxDrawRectangle(818.0,725.0,114.0,14.0,tocolor(100,100,100,150),false) dxDrawRectangle(818.0,745.0,lineLength1,14.0,tocolor(175,0,0,200),false) end ) Credits to R3mp for the guieditor. Tips: those DX texts are for finding ammo and max ammo, plus one more text for throwing weapons and shotgun. I'll ask that after I made the bar first. That will be later. Edited June 4, 2010 by Guest Link to comment
Xierra Posted June 4, 2010 Author Share Posted June 4, 2010 Anyone? I tried to make a timer, but instead just keep creating, not updating. Anyway, does DX drawings detect resolutions? Link to comment
Castillo Posted June 4, 2010 Share Posted June 4, 2010 Anyone?I tried to make a timer, but instead just keep creating, not updating. Anyway, does DX drawings detect resolutions? this is weird, never happend to me b4, im trying many things and nothing works Link to comment
DiSaMe Posted June 4, 2010 Share Posted June 4, 2010 The code which gets health and armor of player should be put into the same function where drawing code is. And DX drawings don't detect resolutions, but you can use guiGetScreenSize(). Link to comment
Xierra Posted June 4, 2010 Author Share Posted June 4, 2010 Yes! It's working nicely! Thanks Doomed_space_marine, you really helped me! Later I'll try for the weapon ammo DX text. Thanks to everyone who helped me. Issue Solved. 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