Captain Cody Posted October 1, 2014 Share Posted October 1, 2014 Anubhav has been scripting for my server and told me edit the hud he made for it but hes at school and I cannot figure out what is wrong with it tables = { health="", } addEventHandler("onClientResourceStart", resourceRoot, function() screenW, screenH = guiGetScreenSize() end ) function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end function getPedMaxHealth(ped) -- Output an error and stop executing the function if the argument is not valid assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") -- Grab his player health stat. local stat = getPedStat(ped, 24) -- Do a linear interpolation to get how many health a ped can have. -- Assumes: 100 health = 569 stat, 200 health = 1000 stat. local maxhealth = 100 + (stat - 569) / 4.31 -- Return the max health. Make sure it can't be below 1 return math.max(1, maxhealth) end addEventHandler("onClientRender", root, function() setPlayerHudComponentVisible( "money", false ) setPlayerHudComponentVisible( "armour", false ) setPlayerHudComponentVisible( "clock", false ) setPlayerHudComponentVisible( "health", false ) setPlayerHudComponentVisible( "ammo", false ) setPlayerHudComponentVisible( "weapon", false ) local hp = tostring(math.floor(getElementHealth( localPlayer ))).."%" local money = tostring(convertNumber( getPlayerMoney( localPlayer ))) local h, m = getTime() local ammo = tostring(getPedTotalAmmo(localPlayer) - getPedAmmoInClip(localPlayer).."-"..getPedAmmoInClip(localPlayer)) dxDrawText("HEALTH: "..hp, 280, (screenH - 42) / 1.09, (280) + 423, ( (screenH - 42) / 1.09) + 42, tocolor(255, 0, 0, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false) dxDrawText("HEALTH: "..hp, 281, 862, 538, 904, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "top", true, true, true, true, false) dxDrawText("MONEY: $"..money, 281, 862, 538, 904, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "top", true, true, true, true, false) dxDrawText("MONEY: $"..money, 280, (screenH - 42) / 1.14, (280) + 257, ( (screenH - 42) / 1.14) + 42, tocolor(0, 100, 0, 154), 1.00, "pricedown", "center", "top", true, true, true, true, false) dxDrawText("TIME: "..h..":"..m, 277, 828, 416, 860, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false) dxDrawText("TIME: "..h..":"..m, 276, (screenH - 32) / 1.2, (276) + 139, ( (screenH - 32) / 1.2) + 32, tocolor(56, 56, 56, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false end ) Link to comment
Banex Posted October 1, 2014 Share Posted October 1, 2014 ever heard of /debugscript 3? try this tables = { health="", } function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end function getPedMaxHealth(ped) -- Output an error and stop executing the function if the argument is not valid assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") -- Grab his player health stat. local stat = getPedStat(ped, 24) -- Do a linear interpolation to get how many health a ped can have. -- Assumes: 100 health = 569 stat, 200 health = 1000 stat. local maxhealth = 100 + (stat - 569) / 4.31 -- Return the max health. Make sure it can't be below 1 return math.max(1, maxhealth) end addEventHandler("onClientRender", root, function() setPlayerHudComponentVisible( "money", false ) setPlayerHudComponentVisible( "armour", false ) setPlayerHudComponentVisible( "clock", false ) setPlayerHudComponentVisible( "health", false ) setPlayerHudComponentVisible( "ammo", false ) setPlayerHudComponentVisible( "weapon", false ) local hp = getElementHealth (localPlayer) local money = convertNumber(getPlayerMoney(localPlayer)) local h, m = getTime() local ammo = getPedTotalAmmo(localPlayer)-getPedAmmoInClip(localPlayer).."-"..getPedAmmoInClip(localPlayer) local screenW, screenH = guiGetScreenSize() dxDrawText("HEALTH: "..math.floor(tostring(hp)).."%", 280, (screenH - 42) / 1.09, (280) + 423, ( (screenH - 42) / 1.09) + 42, tocolor(255, 0, 0, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false) dxDrawText("HEALTH: "..math.floor(tostring(hp)).."%", 281, 862, 538, 904, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "top", true, true, true, true, false) dxDrawText("MONEY: $"..money, 281, 862, 538, 904, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "top", true, true, true, true, false) dxDrawText("MONEY: $"..money, 280, (screenH - 42) / 1.14, (280) + 257, ( (screenH - 42) / 1.14) + 42, tocolor(0, 100, 0, 154), 1.00, "pricedown", "center", "top", true, true, true, true, false) dxDrawText("TIME: "..h..":"..m, 277, 828, 416, 860, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false) dxDrawText("TIME: "..h..":"..m, 276, (screenH - 32) / 1.2, (276) + 139, ( (screenH - 32) / 1.2) + 32, tocolor(56, 56, 56, 255), 1.00, "pricedown", "left", "top", true, true, true, true, false end ) Link to comment
Captain Cody Posted October 1, 2014 Author Share Posted October 1, 2014 I did check debugscript and I fixed it already just forgot to post it here Link to comment
Anubhav Posted October 1, 2014 Share Posted October 1, 2014 (edited) Actually he edited v 0.5.0 which I gave him. I am releasing v 1.0.0 ( source code ) today.! v 0.5.1 has no errors. He had permission Edited October 1, 2014 by Guest Link to comment
Captain Cody Posted October 1, 2014 Author Share Posted October 1, 2014 Differnce between coping and editing "With permission" 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