Jump to content

Armor


ZeyadGTX

Recommended Posts

Hello i use this Line to Show the player armor in the Hud it works but i want if player have armor then it shown

if player doesn't have armor then it should be hidden

dxDrawText("#FFFFFFArmor: #0000FF"..armor.."%", (872/1024)*sWidth, (80/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (0, 0, 0, 255), (0.99/1366)*sWidth,(0.9/768)*sHeight,"bankgothic","left","top",false,false,false,true)  

Link to comment

That's dxDrawText Functions

Client Side

FPSLimit = 60 
FPSMax = 1 
player = getLocalPlayer() 
sWidth,sHeight = guiGetScreenSize() 
addEvent("onClientPlayerHUDShown", true) 
addEvent("onClientPlayerHUDHidden", true) 
  
function restoreHUD() 
setElementData(player, "state.hud", "enabled") 
showChat(true) 
showPlayerHudComponent("crosshair", true) 
showPlayerHudComponent("radar", true) 
triggerServerEvent("onPlayerHUDShown", player) 
triggerEvent("onClientPlayerHUDShown", player) 
end 
addEventHandler("onClientResourceStart", resourceRoot, restoreHUD) 
     
  
function hudvisible ( ) 
    if getElementData(player, "state.hud") == "disabled" then 
    return 
    end 
--Gets some elements 
    local hour, mins = getTime () 
    local time = hour .. ":" .. (((mins < 10) and "0"..mins) or mins) 
    local moneycount=getPlayerMoney(getLocalPlayer()) 
    local money= '' ..moneycount 
    local phealth = math.floor (getElementHealth ( getLocalPlayer() )) 
    local armor = math.floor(getPedArmor ( getLocalPlayer() )) 
    local zone = getZoneName (getElementPosition(getLocalPlayer())) 
    local oxygen = getPedOxygenLevel (getLocalPlayer()) 
    local ammo = getPedTotalAmmo (getLocalPlayer()) 
    local clip = getPedAmmoInClip (getLocalPlayer()) 
    local XP = getElementData(localPlayer, "EXP") or 0 
    local LV = getElementData(localPlayer, "LV") or 0 
    local lp = getElementData(player, "Army.rank") or "Newbie" 
  
  
--Draws the player hud 
    dxDrawText(tostring (time),(0.878)*sWidth, (0.007)*sHeight, (0.293)*sWidth, (0.263)*sHeight,tocolor(250,250,250,200),(0.9/1366)*sWidth,(0.9/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    dxDrawText(tostring (money), (0.08)*sWidth, (0.640)*sHeight, (0.282)*sWidth, (0.326)*sHeight, tocolor (0, 255, 0, 255), (0.9/1366)*sWidth,(0.9/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    dxDrawText("#FFFFFFHealth: #FF0000"..phealth.."%", (870/1024)*sWidth, (45/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (0, 0, 0, 255), (0.9/1366)*sWidth,(0.9/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    dxDrawText("#FFFFFFArmor: #0000FF"..armor.."%", (872/1024)*sWidth, (80/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (0, 0, 0, 255), (0.99/1366)*sWidth,(0.9/768)*sHeight,"bankgothic","left","top",false,false,false,true)  
    dxDrawText(zone, (850/1024)*sWidth, (740/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), (0.85/1366)*sWidth,(0.85/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    --dxDrawText(tonumber(getElementData(getLocalPlayer(), "distance.foot")).." m", (25/1024)*sWidth, (200/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), (0.7/1366)*sWidth,(0.7/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    --dxDrawText(tonumber(getElementData(getLocalPlayer(), "distance.Automobile")).." m", (25/1024)*sWidth, (215/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), (0.7/1366)*sWidth,(0.7/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    --dxDrawText(tonumber(getElementData(getLocalPlayer(), "distance.Plane")).." m", (25/1024)*sWidth, (230/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), (0.7/1366)*sWidth,(0.7/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    --dxDrawText(tonumber(getElementData(getLocalPlayer(), "distance.Bike")).." m", (25/1024)*sWidth, (245/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), (0.7/1366)*sWidth,(0.7/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    --dxDrawText(tonumber(getElementData(getLocalPlayer(), "distance.Helicopter")).." m", (25/1024)*sWidth, (260/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), (0.7/1366)*sWidth,(0.7/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    --dxDrawText(tonumber(getElementData(getLocalPlayer(), "distance.BMX")).." m", (25/1024)*sWidth, (275/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), (0.7/1366)*sWidth,(0.7/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    --dxDrawText(tonumber(getElementData(getLocalPlayer(), "distance.Quad")).." m", (25/1024)*sWidth, (290/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), (0.7/1366)*sWidth,(0.7/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    dxDrawImage((839/1024)*sWidth, (42/768)*sHeight, (33/1024)*sWidth, (33/768)*sHeight, "Heart.png") 
    dxDrawImage((840/1024)*sWidth, (80/768)*sHeight, (32/1024)*sWidth, (32/768)*sHeight, "armor.png") 
    dxDrawImage((47/1024)*sWidth, (490/768)*sHeight, (32/1024)*sWidth, (32/768)*sHeight, "$.png") 

Link to comment
  
if (armor) then  
 dxDrawText("#FFFFFFArmor: #0000FF"..armor.."%", (872/1024)*sWidth, (80/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (0, 0, 0, 255), (0.99/1366)*sWidth,(0.9/768)*sHeight,"bankgothic","left","top",false,false,false,true)  

?

An 'end' is missing P:

@Spider Learn LUA dude

At least tell what debug says, Something like this is simple, no need to write a whole topic for it :roll:

Link to comment

Any way non of your posts helped me i just tried code and worked for me

if armor > 0 then 
dxDrawText("#FFFFFFArmor: #0000FF"..armor.."%", (872/1024)*sWidth, (80/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (0, 0, 0, 255), (0.99/1366)*sWidth,(0.9/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
end 
  
if armor > 0 then 
dxDrawImage((840/1024)*sWidth, (80/768)*sHeight, (32/1024)*sWidth, (32/768)*sHeight, "armor.png") 
end 

Link to comment
Any way non of your posts helped me i just tried code and worked for me
if armor > 0 then 
dxDrawText("#FFFFFFArmor: #0000FF"..armor.."%", (872/1024)*sWidth, (80/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (0, 0, 0, 255), (0.99/1366)*sWidth,(0.9/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
end 
  
if armor > 0 then 
dxDrawImage((840/1024)*sWidth, (80/768)*sHeight, (32/1024)*sWidth, (32/768)*sHeight, "armor.png") 
end 

Maybe because someone WASN'T clear enough and post what debug says.

# ZA7F helped as well

Link to comment

if ( getPedArmor ( getLocalPlayer (   ) ) > 0 ) then 
    dxDrawText("#FFFFFFArmor: #0000FF"..armor.."%", (872/1024)*sWidth, (80/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (0, 0, 0, 255), (0.99/1366)*sWidth,(0.9/768)*sHeight,"bankgothic","left","top",false,false,false,true) 
    dxDrawImage((840/1024)*sWidth, (80/768)*sHeight, (32/1024)*sWidth, (32/768)*sHeight, "armor.png") 
end 
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...