HG Snuuk Posted June 30, 2019 Posted June 30, 2019 (edited) Opa Sou novo gostaria de pedir ajuda pois esta tudo perfeito só que desce apenas o colete e a vida não mostra pela nametag descendo [Lua]local drawDistance = 70 g_StreamedInPlayers = {} function drawHPBar(x, y, v, d) if v < 0 then v = 0 elseif v > 100 then v = 100 end dxDrawRectangle(x - 21, y, 42, 6, tocolor(0, 0, 0, 150 - d)) dxDrawRectangle(x - 20, y + 1, v / 2.5, 4, tocolor((100 - v) * 2.55, v * 2.55, 0, 255 - d)) end function drawArmourBar(x, y, v, d) if v < 0 then v = 0 elseif v > 100 then v = 100 end dxDrawRectangle(x - 21, y, 42, 6, tocolor(0, 0, 0, 150 - d)) dxDrawRectangle(x - 20, y + 1, v / 2.5, 4, tocolor(255, 255, 255, 255 - d)) end function onClientRender() local cx, cy, cz, lx, ly, lz = getCameraMatrix() for k, player in pairs(g_StreamedInPlayers) do if isElement(player) and isElementStreamedIn(player) then local vx, vy, vz = getPedBonePosition(player, 8) local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz) if dist < drawDistance and isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) then local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3) if x and y then local name = getPlayerName(player) local w = dxGetTextWidth(name, 1, "default-bold", true) local h = dxGetFontHeight(1, "default-bold", true) dxDrawText(name, x - w + 40, y - 30, x + h, y, tocolor(255,255,255,255), 1, "default-bold", "center", "top", false, false, false, true) local health = getPedMaxHealth(player) local armour = getPedArmor(player) if health > 0 then drawHPBar(x, y - 6, health, dist) end if armour > 0 then drawArmourBar(x, y - 12, armour, dist) end end end else table.remove(g_StreamedInPlayers, k) end end end addEventHandler("onClientRender", root, onClientRender) function onClientElementStreamIn() if getElementType(source) == "player" and source ~= getLocalPlayer() then setPlayerNametagShowing(source, false) table.insert(g_StreamedInPlayers, source) end end addEventHandler("onClientElementStreamIn", root, onClientElementStreamIn) function onClientResourceStart(startedResource) visibleTick = getTickCount() normalhealthbar = false for k, v in pairs(getElementsByType("player")) do if isElementStreamedIn(v) and v ~= getLocalPlayer() then setPlayerNametagShowing(v, false) table.insert(g_StreamedInPlayers, v) end end end addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart) function dxDrawColorText(str, ax, ay, bx, by, color, scale, font) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x" .. col:sub(1, 2)), tonumber("0x" .. col:sub(3, 4)), tonumber("0x" .. col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x" .. col:sub(1, 2)), tonumber("0x" .. col:sub(3, 4)), tonumber("0x" .. col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end 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[/Lua ] Edited June 30, 2019 by Thg Map
Moderators Lord Henry Posted June 30, 2019 Moderators Posted June 30, 2019 Sua linha 39 está errada. Em vez de pegar a vida do jogador, está pegando a quantidade máxima de vida que ele pode ter. 1 Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment Discord Oficial do MTA: https://mtasa.com/discord Blacklist e Whitelist de Scripters: Planilha Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.
#DeltaSCR Posted June 30, 2019 Posted June 30, 2019 Linha 39 - Altere isso: local health = getPedMaxHealth(player) Para isso: local health = getElementHealth(player) 1 Minha resposta te ajudou? Por favor, não esqueça de avaliar - #DeltaSCR Minha página no Facebook: Delta Scripting - MTA "Viribus et honor"
HG Snuuk Posted June 30, 2019 Author Posted June 30, 2019 10 minutes ago, #DeltaSCR said: Linha 39 - Altere isso: local health = getPedMaxHealth(player) Para isso: local health = getElementHealth(player) oh meu caro muito obrigado meu lindro
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