Xierra Posted November 1, 2010 Share Posted November 1, 2010 (edited) Hello guys! I proudly like to present my first and honored script made from scratch: Alternate HUD is a HUD based resource, used to replace the GTA SA HUD used here. This script uses 100% DX elements. Script was my idea and some great scripters helped me throughout the creation! This resource features time, money, health & armor bar, weapon icons, ammo in clip and total ammo. It fits on all resolutions (thanks to R3mp) and works nicely. Now I would like to let you all see my styles of the alternate HUDs, there is one available for now, but there will be more soon enough. If someone could showcase the HUD, I'll be honored to the author of the video. ========================================================================================================================================================== HUD Styles: 1. Compact (*updated* 1000 downloads! This resource is a SUCCESS!! ) Outcome of my first hardwork and experiments. This type is of HUD is suitable for freeroam and some deathmatch gamemodes. RPG is not really suitable in my opinion because it only shows GTA time without seconds, but it's up to you to choose. Location of the HUD is on the bottom left of the screen, gives some sort of exotic feeling, which was my goal of the HUD. This style is available for download now. Download it here: https://community.multitheftauto.com/index.php?p= ... ils&id=807 Latest version: 1.4.0 Changelog:1.4.0 *MTA SA 1.1 onwards*: - Re-positioned DX drawings for the second time. - Flipped ammo and total ammo. - Total ammo now works as it should be! - Toggleable HUD (Look at the commands) - Commands are altered. 1.3.5 Minor update *MTA SA 1.1 onwards*: - Implemented custom wanted stars - Hides the GTA wanted stars 1.3.0: - Added dynamic health color. - Added blink on the health bar if health is below 25% - Minute time will now always show in 2 digits. (thanks to 50p) - Armor bar will now hide if armor is 0% or no armor. 1.2.0: - Changed weapon settings - Re-positioned DX drawings (mostly weapon ammo to fit the weapon icons) - Weapon icons are now included! (Thanks to 50p for this!) 1.1.0: - Implemented weapon setting table to sort out what to display on the ammo. (Thanks to Doomed_space_marine and eXo|Dragon for the help) - Added a function to hide the GTA SA HUD on player join. 1.4.0 to do list: - GUIs to customize and set visibility of each HUD elements. - Shorten script (Maybe should be done fast) - Replace radio stations with icons + fade effect - Re-position the bars and weapon HUD a bit up. - Improve total ammo mechanics (Not decreasing ammo until you reload) A new update! Custom wanted stars is finally implemented. Though there is still no editing capabilities yet, I promise I'll make it sometime... Credits goes to:50p: For most of the help on this resource and the custom weapon icons (Big thanks!). Doomed_space_marine: For a helpful hint while I get health & armor bar update problems, and helping me creating a weapon table. R3mp: For helping me learn about guiGetScreenSize and of course, the Gui Editor! Dragon: For helping me making a part of DX text visible or invisible according to weapon. Dre-+-: For allowing me to take a little part of his HUD script, to improve my HUD resource. Custom HUD requests for implementing in gamemodes are welcome! Please PM me with layout if you want me to create it. Edited March 4, 2011 by Guest Link to comment
drake989 Posted November 20, 2010 Share Posted November 20, 2010 hm, what a new radar you have i cant find it .... can you give me a link to this radar mod? and alternate hud is nice. Detailed radar and "????" Link to comment
drake989 Posted November 20, 2010 Share Posted November 20, 2010 Ok i know. http://www.mediafire.com/?knxnkrdkyjz - radar link called "gta chile" Link to comment
Xierra Posted November 22, 2010 Author Share Posted November 22, 2010 Sorry for late answer! Actually, I took this from San Andreas Retextured mod. Link to comment
Neukfout Posted December 29, 2010 Share Posted December 29, 2010 Ok i know. http://www.mediafire.com/?knxnkrdkyjz - radar link called "gta chile" Ah thanks! Have been looking for that radar a long time, lol! Nice resource btw! Link to comment
Xierra Posted February 5, 2011 Author Share Posted February 5, 2011 Alright. I'm back... Please don't talk off topic or about my client visual modifications again. I won't answer it again. Now there is a new update, again! Custom wanted stars are finally implemented. You see, in the new MTA SA 1.1, wanted stars HUD component are implemented, so I finally able to make use of it for my custom HUD. And also, Total ammo now works as it should, and the HUD itself gets a new position! - Re-positioned DX drawings for the second time. - Flipped ammo and total ammo. - Total ammo issue fixed. - Toggleable HUD - Commands are altered. - Custom wanted stars are now implemented *MTA SA 1.1 onwards!* - Hides the GTA wanted stars *MTA SA 1.1 onwards!* - Cleaned up (When resource stops, turns on the GTA HUD.) It was a simple star, given by 50p. He also helped me scripting it.Thanks for that! Dre-+- did not think of being the rivals, instead, we shared scripts and compliments to each other! That's the right way! Link to comment
Phat Looser Posted June 21, 2011 Share Posted June 21, 2011 Finally people working together. I'm using this script in my stealth server at the moment. I never tested it (and scripted it in a minute) but this looks better considering the wanted level. for i = 1 to 6 do if i < wantedlevel then dxDrawImage(sWidth-21,sHeight-iCurrPosition,16.0,19.0,"images/star.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) -- Wanted level 1 else dxDrawImage(sWidth-21,sHeight-iCurrPosition,16.0,19.0,"images/star.png",0.0,0.0,0.0,tocolor(0,0,0,100),false) -- Wanted level 1 end iCurrPosition = iCurrPosition + 21; end I like my code like I like my women: effective and cute. Link to comment
Phat Looser Posted June 25, 2011 Share Posted June 25, 2011 Since I used the code for my own resource, I felt the need to give something back. -- Weapon tables for ammo. local resourceroot = getResourceRootElement(getThisResource()) local sWidth, sHeight = guiGetScreenSize() -- Getting the screen size local localPlayer = getLocalPlayer() local noreloadweapons = {} --Weapons that doesn't reload (including the flamethrower, minigun, which doesn't have reload anim). noreloadweapons[16] = true noreloadweapons[17] = true noreloadweapons[18] = true noreloadweapons[19] = true noreloadweapons[25] = true noreloadweapons[33] = true noreloadweapons[34] = true noreloadweapons[35] = true noreloadweapons[36] = true noreloadweapons[37] = true noreloadweapons[38] = true noreloadweapons[39] = true noreloadweapons[41] = true noreloadweapons[42] = true noreloadweapons[43] = true local meleespecialweapons = {} --Weapons that don't shoot, and special weapons. meleespecialweapons[0] = true meleespecialweapons[1] = true meleespecialweapons[2] = true meleespecialweapons[3] = true meleespecialweapons[4] = true meleespecialweapons[5] = true meleespecialweapons[6] = true meleespecialweapons[7] = true meleespecialweapons[8] = true meleespecialweapons[9] = true meleespecialweapons[10] = true meleespecialweapons[11] = true meleespecialweapons[12] = true meleespecialweapons[13] = true meleespecialweapons[14] = true meleespecialweapons[15] = true meleespecialweapons[40] = true meleespecialweapons[44] = true meleespecialweapons[45] = true meleespecialweapons[46] = true aClassList = {}; aObjectList = {}; iObjectCount = 0; function createClass(sName,aFunctionList) if aClassList[sName] then return; end aClassList[sName] = {}; local class = aClassList[sName]; for sFunctionName,fFunction in pairs(aFunctionList) do if type(sFunctionName) == "string" and type(fFunction) == "function" then class["f"..sFunctionName] = fFunction; end end if not class.fDestruct then class.fDestruct = fGeneralDestructor; end class.getVar = function(elm,sName) return elm["v"..tostring(sName)]; end class.setVar = function(elm,sName,value) elm["v"..tostring(sName)] = value; end end function createObject(sClass,aVariableList) if not aClassList[sClass] then return; end iObjectCount = iObjectCount + 1; aObjectList[iObjectCount] = {}; local object = aObjectList[iObjectCount]; for sString,fFunction in pairs(aClassList[sClass]) do object[sString] = fFunction; end for sVarName,vVariable in pairs(aVariableList) do if type(sVarName) == "string" and type(vVariable) ~= "function" then object["v"..sVarName] = vVariable; end end object.identifier = iObjectCount; end --------------------------------------- function getHealthColorActive(health) local maxHealth = 100; -- get max health stat local colourPercent = ( health / maxHealth ) * 200; local red, green; -- we don't need blue because we don't use it, it'll be 0 if health < ( maxHealth / 2 ) then red = 200; green = ( health / 50 ) * ( colourPercent * 2 ); else green = 200; red = 200 - ( ( health - 50 ) / 50 ) * 200; end return tocolor(red,green,0,200); end function getHealthColorInactive(health) local maxHealth = 100; -- get max health stat local colourPercent = ( health / maxHealth ) * 75; local red, green; -- we don't need blue because we don't use it, it'll be 0 if health < ( maxHealth / 2 ) then red = 75; green = ( health / 50 ) * ( colourPercent * 2 ); else green = 75; red = 75 - ( ( health - 50 ) / 50 ) * 75; end return tocolor(red,green,0,150) end function drawHealthBar(elm) if getElementData(localPlayer,"HUD_NOHEALTH") then return; end local health = getElementHealth( localPlayer ) if health > 100 then health = 100 end local xpos = elm.vx local ypos = elm.vy local width = elm.vwidth local height = elm.vheight local blinktime1 = elm.vblinktime1 local blinktime2 = elm.vblinktime2 if getTickCount () %blinktime1 < blinktime2 and health <= 20 and armor <=0 then -- If health is less than 20%, armor is 0%, the health bar will blink by hiding the health bar every 1.5 seconds. else local color1 = getHealthColorInactive(health) local color2 = getHealthColorActive(health) local lineLength1 = width * ( health / 100 ) -- Health bar dxDrawRectangle(xpos,ypos,width,height,color1, false) -- Health inactive bar dxDrawRectangle(xpos,ypos,lineLength1,height,color2,false) --Health active bar end end function drawArmorBar(elm) if getElementData(localPlayer,"HUD_NOARMOR") then return; end local xpos = elm.vx local ypos = elm.vy local width = elm.vwidth local height = elm.vheight armor = getPedArmor( localPlayer ) if armor <= 0 then else lineLength2 = width * ( armor / 100 ) -- Armor bar dxDrawRectangle(xpos,ypos,lineLength2,height,tocolor(200,200,200,200),false) -- Armor active bar dxDrawRectangle(xpos,ypos,width,height,tocolor(50,50,50,150),false) -- Armor inactive bar end end function drawMoney(elm) if getElementData(localPlayer,"HUD_NOMONEY") then return; end local xpos = elm.vx local ypos = elm.vy local width = elm.vwidth local height = elm.vheight moneycount=getPlayerMoney(localPlayer) money= '$' ..moneycount -- Money dxDrawText(tostring (money),xpos,ypos,width,height,tocolor(0,0,0,200),1.0,"pricedown","right","top",false,false,false) -- Money DX text (shadow) dxDrawText(tostring (money),xpos-2,ypos-3,width-2,height-3,tocolor(0,100,0,220),1.0,"pricedown","right","top",false,false,false) -- Money DX text end function drawWeaponIcon(elm) if getElementData(localPlayer,"HUD_NOWEAPONICON") then return; end local xpos = elm.vx local ypos = elm.vy local width = elm.vwidth local height = elm.vheight local weaponID = getPedWeapon (getLocalPlayer()); -- Get weapon ID dxDrawImage(xpos,ypos,width,height,"icons/".. tostring( weaponID ) .. ".png",0.0,0.0,0.0,tocolor(255,255,255,200),false) -- Weapon icons image. Check the icons file if you want to take and replace weapon icons. end function drawWeaponAmmo(elm) if getElementData(localPlayer,"HUD_NOAMMO") then return; end local axpos = elm.vx local aypos = elm.vy local awidth = elm.vwidth local aheight = elm.vheight local ammoinclip = getPedAmmoInClip (getLocalPlayer()) -- The ammo inside the clip local totalammo = getPedTotalAmmo(getLocalPlayer())-getPedAmmoInClip(getLocalPlayer()) -- The total ammo minus ammo inside clip local totalammo2 = getPedTotalAmmo(getLocalPlayer()) local showammo1 = ammoinclip local showammo2 = totalammo local showammo3 = totalammo2 if noreloadweapons [getPedWeapon(getLocalPlayer())] then dxDrawText(tostring (showammo3),axpos[1],aypos[1],awidth[1],aheight[1],tocolor(0,255,255,200),1.0,"bankgothic","right","top",false,false,false) -- No reload weapons (for shotgun, grenades, etc) elseif meleespecialweapons [getPedWeapon(getLocalPlayer())] then else --Weapons that reloads. dxDrawText(tostring (showammo2),axpos[2],aypos[2],awidth[2],aheight[2],tocolor(0,255,255,200),1.0,"bankgothic","right","top",false,false,false) dxDrawText("|",axpos[3],aypos[3],awidth[3],aheight[3],tocolor(255,200,0,200),1.0,"bankgothic","left","top",false,false,false) dxDrawText(tostring (showammo1),axpos[4],aypos[4],awidth[4],aheight[4],tocolor(0,255,255,200),1.0,"bankgothic","left","top",false,false,false) end end function drawTime(elm) if getElementData(localPlayer,"HUD_NOTIME") then return; end local xpos = elm.vx local ypos = elm.vy local width = elm.vwidth local height = elm.vheight local hour, mins = getTime () local time = hour .. ":" .. (((mins < 10) and "0"..mins) or mins) -- Time. This one makes the minutes always show by 2 digits (3:05 instead of 3:5) dxDrawRectangle(xpos,ypos,width,height,tocolor(0,0,0,150),false) -- GTA Time DX Rectangle dxDrawText(tostring (time),xpos+2,ypos+3,width+2,height+3,tocolor(250,250,250,200),1.0,"diploma","center","top",false,false,false) -- GTA Time DX text end function drawWantedLevel(elm) if getElementData(localPlayer,"HUD_NOWANTEDLEVEL") then return; end local xpos = elm.vx local ypos = elm.vy local width = elm.vwidth local height = elm.vheight local wantedlevel = getPlayerWantedLevel (getLocalPlayer()) --Getting the player's wanted level. for i = 1, 6, 1 do if i < wantedlevel then dxDrawImage(xpos-21,ypos+i*21,width,height,"images/star.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) else dxDrawImage(xpos-21,ypos+i*21,width,height,"images/star.png",0.0,0.0,0.0,tocolor(0,0,0,100),false) end end end --------------------------------------- Link to comment
Xierra Posted July 13, 2011 Author Share Posted July 13, 2011 OMG! Sorry for not answering. Wow, your edit of my resource sure looks a bit more complicated, but thanks for the shorter wanted script Let's see if I can get this to work. Link to comment
Phat Looser Posted July 13, 2011 Share Posted July 13, 2011 Its not more complicated, its object oriented. This way modifying the objects or adding objects is done in a second. I.e. when you want to change the position of the clock, you just look which function creates the clock: 328. createClass("Clock",{Draw = drawTime}); 329. createObject("Clock",{ --sWidth-81,sHeight-46,sWidth-10,sHeight-16 330. x =sWidth-81, 331. y =sHeight-46, 332. width =sWidth-10, 333. height =sHeight-16 334. }); and you can see xpos, ypos etc. I have to fix "width" and "height", since you didn't script it all in one fashion but used different code for different objects. Also, if you want to add a "drown bar" oxygen or something like that, it would be just another object (and another function). 328. createClass("Drownbar",{Draw = drawPlayerOxygen}); 329. createObject("Drownbar",{ 330. x =sWidth-181, 331. y =sHeight-146, 332. width =sWidth-110, 333. height =sHeight-116 334. }); 145.function drawPlayerOxygen(elm) 146. if getElementData(localPlayer,"HUD_NOOXYGEN") then 147. return; 148. end 149. local xpos = elm.vx 150. local ypos = elm.vy 151. local width = elm.vwidth 152. local height = elm.vheight 153. oxygen = getPedOXYGEN_DOESNT_EXIST( localPlayer ) 154. if oxygen <= 0 then 155. else 156. lineLength2 = width * ( oxygen / 100 ) 157. dxDrawRectangle(xpos,ypos,lineLength2,height,tocolor(200,200,200,200),false) 158. dxDrawRectangle(xpos,ypos,width,height,tocolor(50,50,50,150),false) 159. end 160.end The big, big plus of this code is that ALL elements are rendered / computed / working THE SAME WAY. Add a Class, and an Object, add the function. (Btw: the class contain the function "pointers", the objects contain the data. In other words: The class defines the functions used. This can be done much more "object oriented", but I actually want it the aspect oriented way so that you can change the functions any time.) Link to comment
Xierra Posted July 19, 2011 Author Share Posted July 19, 2011 I see. So sorting it like that is called Oriented Objects. I haven't learn that in LUA, so I better start off learning a more efficient way to create elements, like you did. Link to comment
HeK Posted December 30, 2011 Share Posted December 30, 2011 Hello there, can you help me modify your HUD? I wanna put "Xtreme Dead" where the time is. How can i do it? 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