Xierra Posted June 4, 2010 Posted June 4, 2010 Hi guys! As I told you, I just made the Health & Armor bar. Thanks to 50p and Doomed_space_marine, who helped me a lot. Now I wanted to make ammo DX text. I tried some effort, but it failed. It said bad arguments repeatedly. Script (client): -- Direct X Drawings function DXdraw() health = getElementHealth( getLocalPlayer() ) lineLength1 = 114 * ( health / 100 ) armor = getPedArmor( getLocalPlayer() ) lineLength2 = 114 * ( armor / 100 ) ammoinclip = getPedAmmoInClip (getLocalPlayer()) totalammo = getPedTotalAmmo (getLocalPlayer()) showammo1=ammoinclip showammo2=totalammo dxDrawText("",646.0,731.0,694.0,766.0,tocolor(0,255,255,175),1.0,"bankgothic","right","top",false,false,false) --Ammo (for shotgun, grenades, etc) 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(showammo2,684.0,731.0,732.0,766.0,tocolor(0,255,255,175),1.0,"bankgothic","left","top",false,false,false) -- Total Ammo dxDrawText("|",665.0,731.0,677.0,762.0,tocolor(255,200,0,200),1.0,"bankgothic","left","top",false,false,false) --Separator dxDrawText(showammo1,611.0,731.0,659.0,766.0,tocolor(0,255,255,175),1.0,"bankgothic","right","top",false,false,false) -- Ammo in clip dxDrawRectangle(818.0,725.0,114.0,14.0,tocolor(50,50,50,150),false) dxDrawRectangle(818.0,745.0,lineLength1,14.0,tocolor(175,0,0,200),false) end addEventHandler("onClientRender",getRootElement(),DXdraw) function hudChanger () showPlayerHudComponent ( "armour", false ) -- Hide the ammo displays for the newly joined player showPlayerHudComponent ( "health", false ) -- Hide the weapon displays for the newly joined player showPlayerHudComponent ( "money", false ) showPlayerHudComponent ( "clock", false ) showPlayerHudComponent ( "weapon", false ) showPlayerHudComponent ("ammo", false) showPlayerHudComponent ( "money", false ) end addCommandHandler ( "hidehud", hudChanger ) function hudChanger2 () showPlayerHudComponent ( "armour", true ) -- Hide the ammo displays for the newly joined player showPlayerHudComponent ( "health", true ) -- Hide the weapon displays for the newly joined player showPlayerHudComponent ( "money", true ) showPlayerHudComponent ( "clock", true ) showPlayerHudComponent ( "weapon", true ) showPlayerHudComponent ("ammo", true) showPlayerHudComponent ( "money", true) end addCommandHandler ( "showhud", hudChanger2) XX3 is gone. This is my new name. :3
50p Posted June 4, 2010 Posted June 4, 2010 dxDrawText expects you to put string in the first parameter but you put a number. Convert the number to string: dxDrawText( tostring( ammoinclip ), ...... ) dxDrawText( tostring( totalammo ), ...... ) - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Xierra Posted June 4, 2010 Author Posted June 4, 2010 (edited) Yes! It's working. Thanks again 50p! One thing though, is it possible to detect reloads? Like the GTA's ammo system. Only reduce total ammo after he reloads. Also, for some weapons, I want it to show only total ammo. How to do that? (check the script again, on line 15, that's where it's gonna be used.) Edited June 4, 2010 by Guest XX3 is gone. This is my new name. :3
50p Posted June 4, 2010 Posted June 4, 2010 No, AFAIK. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Dark Dragon Posted June 4, 2010 Posted June 4, 2010 create a table which stores the clip size of all weapons, then simply add the difference between max clip amount and currently in clip amount to your totalammo Loads of fun for free! Also a lot of fun for free!
Xierra Posted June 4, 2010 Author Posted June 4, 2010 That's for the reload am I right? I'll give it a shot tomorrow. Now I'm gonna release the first beta version first. XX3 is gone. This is my new name. :3
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