Advertisement
NanoBob

MTA HUD script

Jan 13th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.35 KB | None | 0 0
  1. addEventHandler("onClientResourceStart",getResourceRootElement(),
  2.     function()
  3.         showPlayerHudComponent("ammo",false)
  4.         showPlayerHudComponent("area_name",false)
  5.         showPlayerHudComponent("armour",false)
  6.         showPlayerHudComponent("breath",false)
  7.         showPlayerHudComponent("clock",false)
  8.         showPlayerHudComponent("health",false)
  9.         showPlayerHudComponent("money",false)
  10.         showPlayerHudComponent("weapon",false)
  11.         showPlayerHudComponent("wanted",false)
  12.     end )
  13.    
  14. function drawCustomHUD()
  15.     screenx,screeny=guiGetScreenSize()
  16.  
  17.     bgSX=screenx*0.75
  18.     bgSY=screeny*0.0
  19.     bgX=screenx*0.3
  20.     bgY=screeny*0.15
  21.    
  22.     --Basic background
  23.     dxDrawRectangle(bgSX,bgSY,bgX,bgY,tocolor(100,100,100,50),true)
  24.    
  25.     --Health, armour and breath
  26.         --Health
  27.     dxDrawLine(bgSX+bgX*0.05,bgSY+bgY*0.05,bgSX+bgX*0.4,bgSY+bgY*0.05,tocolor(0,0,0,255),bgY*0.015)     --      -
  28.     dxDrawLine(bgSX+bgX*0.05,bgSY+bgY*0.15,bgSX+bgX*0.4,bgSY+bgY*0.15,tocolor(0,0,0,255),bgY*0.015)     --      -
  29.     dxDrawLine(bgSX+bgX*0.05,bgSY+bgY*0.05,bgSX+bgX*0.05,bgSY+bgY*0.15,tocolor(0,0,0,255),bgY*0.015)    --      |
  30.     dxDrawLine(bgSX+bgX*0.4,bgSY+bgY*0.05,bgSX+bgX*0.4,bgSY+bgY*0.15,tocolor(0,0,0,255),bgY*0.015)      --      |
  31.    
  32.     HP=getElementHealth(getLocalPlayer())
  33.     BarLenght=bgSX+bgX*0.4
  34.     HPLenght=BarLenght/820*HP
  35.    
  36.     dxDrawLine(bgSX+bgX*0.05,bgSY+bgY*0.1,bgSX+bgX*0.05+HPLenght,bgSY+bgY*0.1,tocolor(200,0,0,200),bgY*0.085)
  37.     dxDrawLine(bgSX+bgX*0.05+HPLenght,bgSY+bgY*0.1,BarLenght,bgSY+bgY*0.1,tocolor(50,50,50,200),bgY*0.085)
  38.    
  39.     dxDrawText("Health : "..math.floor(HP).."%",bgSX+bgX*0.05,bgSY+bgY*0.05,bgSX+bgX*0.4,bgSY+bgY*0.28,tocolor(255,255,255,255),1,"sans","center","top",false,false,true,false,false)
  40.         --armour
  41.     dxDrawLine(bgSX+bgX*0.05,bgSY+bgY*0.18,bgSX+bgX*0.4,bgSY+bgY*0.18,tocolor(0,0,0,255),bgY*0.015)     --      -
  42.     dxDrawLine(bgSX+bgX*0.05,bgSY+bgY*0.28,bgSX+bgX*0.4,bgSY+bgY*0.28,tocolor(0,0,0,255),bgY*0.015)     --      -
  43.     dxDrawLine(bgSX+bgX*0.05,bgSY+bgY*0.18,bgSX+bgX*0.05,bgSY+bgY*0.28,tocolor(0,0,0,255),bgY*0.015)    --      |
  44.     dxDrawLine(bgSX+bgX*0.4,bgSY+bgY*0.18,bgSX+bgX*0.4,bgSY+bgY*0.28,tocolor(0,0,0,255),bgY*0.015)      --      |  
  45.        
  46.     Armour=getPedArmor(getLocalPlayer())
  47.     if Armour~=nil then
  48.         ArmourLenght=BarLenght/820*Armour
  49.         dxDrawLine(bgSX+bgX*0.05,bgSY+bgY*0.23,bgSX+bgX*0.05+ArmourLenght,bgSY+bgY*0.23,tocolor(255,255,255,200),bgY*0.085)
  50.         dxDrawLine(bgSX+bgX*0.05+ArmourLenght,bgSY+bgY*0.23,BarLenght,bgSY+bgY*0.23,tocolor(50,50,50,200),bgY*0.085)   
  51.        
  52.         dxDrawText("Armour : "..math.floor(Armour).."%",bgSX+bgX*0.05,bgSY+bgY*0.05,bgSX+bgX*0.4,bgSY+bgY*0.28,tocolor(255,255,255,255),1,"sans","center","bottom",false,false,true,false,false)
  53.     end
  54.         --breath
  55.    
  56.    
  57.    
  58.     --weapons
  59.     SelectedWeapon=getPedWeapon(getLocalPlayer())
  60.     if SelectedWeapon==0 then
  61.         slectedWeaponImageName="HUDImages/fist"
  62.     elseif SelectedWeapon==1 then
  63.         slectedWeaponImageName="HUDImages/"
  64.     elseif SelectedWeapon==2 then
  65.         slectedWeaponImageName="HUDImages/"
  66.     elseif SelectedWeapon==3 then
  67.         slectedWeaponImageName="HUDImages/nite"
  68.     elseif SelectedWeapon==4 then
  69.         slectedWeaponImageName="HUDImages/knife"
  70.     elseif SelectedWeapon==5 then
  71.         slectedWeaponImageName="HUDImages/bat"
  72.     elseif SelectedWeapon==6 then
  73.         slectedWeaponImageName="HUDImages/shovel"
  74.     elseif SelectedWeapon==7 then
  75.         slectedWeaponImageName="HUDImages/"
  76.     elseif SelectedWeapon==8 then
  77.         slectedWeaponImageName="HUDImages/"
  78.     elseif SelectedWeapon==9 then
  79.         slectedWeaponImageName="HUDImages/"
  80.     elseif SelectedWeapon==10 then
  81.         slectedWeaponImageName="HUDImages/"
  82.     elseif SelectedWeapon==11 then
  83.         slectedWeaponImageName="HUDImages/"
  84.     elseif SelectedWeapon==12 then
  85.         slectedWeaponImageName="HUDImages/"
  86.     elseif SelectedWeapon==13 then
  87.         slectedWeaponImageName="HUDImages/"
  88.     elseif SelectedWeapon==14 then
  89.         slectedWeaponImageName="HUDImages/"
  90.     elseif SelectedWeapon==15 then
  91.         slectedWeaponImageName="HUDImages/"
  92.     elseif SelectedWeapon==16 then
  93.         slectedWeaponImageName="HUDImages/nade"
  94.     elseif SelectedWeapon==17 then
  95.         slectedWeaponImageName="HUDImages/"
  96.     elseif SelectedWeapon==18 then
  97.         slectedWeaponImageName="HUDImages/molotov"
  98.     elseif SelectedWeapon==19 then
  99.         slectedWeaponImageName="HUDImages/"
  100.     elseif SelectedWeapon==20 then
  101.         slectedWeaponImageName="HUDImages/"
  102.     elseif SelectedWeapon==21 then
  103.         slectedWeaponImageName="HUDImages/"
  104.     elseif SelectedWeapon==22 then
  105.         slectedWeaponImageName="HUDImages/colt"
  106.     elseif SelectedWeapon==23 then
  107.         slectedWeaponImageName="HUDImages/silenced"
  108.     elseif SelectedWeapon==24 then
  109.         slectedWeaponImageName="HUDImages/deagle"
  110.     elseif SelectedWeapon==25 then
  111.         slectedWeaponImageName="HUDImages/shotgun"
  112.     elseif SelectedWeapon==26 then
  113.         slectedWeaponImageName="HUDImages/sawnoff"
  114.     elseif SelectedWeapon==27 then
  115.         slectedWeaponImageName="HUDImages/combat"
  116.     elseif SelectedWeapon==28 then
  117.         slectedWeaponImageName="HUDImages/uzi"
  118.     elseif SelectedWeapon==29 then
  119.         slectedWeaponImageName="HUDImages/smg"
  120.     elseif SelectedWeapon==30 then
  121.         slectedWeaponImageName="HUDImages/AK"
  122.     elseif SelectedWeapon==31 then
  123.         slectedWeaponImageName="HUDImages/m4"
  124.     elseif SelectedWeapon==32 then
  125.         slectedWeaponImageName="HUDImages/tec"
  126.     elseif SelectedWeapon==33 then
  127.         slectedWeaponImageName="HUDImages/cuntgun"
  128.     elseif SelectedWeapon==34 then
  129.         slectedWeaponImageName="HUDImages/sniper"
  130.     elseif SelectedWeapon==35 then
  131.         slectedWeaponImageName="HUDImages/RPG"
  132.     elseif SelectedWeapon==36 then
  133.         slectedWeaponImageName="HUDImages/"
  134.     elseif SelectedWeapon==37 then
  135.         slectedWeaponImageName="HUDImages/flame"
  136.     elseif SelectedWeapon==38 then
  137.         slectedWeaponImageName="HUDImages/"
  138.     elseif SelectedWeapon==39 then
  139.         slectedWeaponImageName="HUDImages/satchel"
  140.     elseif SelectedWeapon==40 then
  141.         slectedWeaponImageName="HUDImages/"
  142.     elseif SelectedWeapon==41 then
  143.         slectedWeaponImageName="HUDImages/"
  144.     elseif SelectedWeapon==42 then
  145.         slectedWeaponImageName="HUDImages/fire"
  146.     elseif SelectedWeapon==43 then
  147.         slectedWeaponImageName="HUDImages/"
  148.     elseif SelectedWeapon==44 then
  149.         slectedWeaponImageName="HUDImages/"
  150.     elseif SelectedWeapon==45 then
  151.         slectedWeaponImageName="HUDImages/"
  152.     elseif SelectedWeapon==46 then
  153.         slectedWeaponImageName="HUDImages/para"
  154.     end
  155.    
  156.     dxDrawImage(bgSX+bgX*0.45,bgSY+bgY*0.05,208,78,slectedWeaponImageName..".png")
  157.    
  158.         --ammo
  159.     totalammo=getPedTotalAmmo(getLocalPlayer())
  160.     clipAmmo=getPedAmmoInClip(getLocalPlayer())
  161.     if getPedWeaponSlot(getLocalPlayer())~=0 and getPedWeaponSlot(getLocalPlayer())~=1 and getPedWeaponSlot(getLocalPlayer())~=12 and getPedWeaponSlot(getLocalPlayer())~=11 and getPedWeaponSlot(getLocalPlayer())~=10 and getPedWeaponSlot(getLocalPlayer())~=9 then
  162.         dxDrawText(totalammo-clipAmmo..":"..clipAmmo,bgSX+bgX*0.45,bgSY+bgY*0.3,screenx,screeny,tocolor(200,200,200,255),1,"pricedown","center","top",false,false,true,false,true)
  163.     end
  164.     --money
  165.     moneyCount=getElementData(getLocalPlayer(),"FGNMoney")
  166.     if moneyCount~=false then
  167.         dxDrawText("$"..moneyCount,bgSX+bgX*0.45,bgSY+bgY*0.6,screenx,screeny,tocolor(0,200,0,255),1,"pricedown","right","top",false,false,true,false,true)
  168.     end
  169.     --wanted level
  170.         wantedLevel=getElementData(getLocalPlayer(),"wantedStars")
  171.         if wantedLevel~=false then
  172.             WSX=bgSX+bgX*0.7
  173.             WSY=bgSY+bgY*0.8
  174.             for i=1,wantedLevel do
  175.                 dxDrawImage(WSX,WSY,bgSY+bgY*0.2,bgSY+bgY*0.2,"HUDImages/wantedstar.png",0,0,0,tocolor(255,255,255,255,true))
  176.                 WSX=WSX-(bgSY+bgY*0.25)
  177.                
  178.             end
  179.         end
  180.        
  181.        
  182.        
  183.    
  184. end
  185. addEventHandler("onClientRender",getRootElement(),drawCustomHUD)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement