HG Snuuk Posted August 20, 2019 Share Posted August 20, 2019 Opa tudo bom eu gostaria de tar colocando sistema na hud de ver a arma e o tanto de munição escrito exemplo : colt | munição: 30 . Ja tentei copiar codigos e passar pra hud porem n consigui local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local components = { "area_name", "radio", "vehicle_name" } local font = dxCreateFont('files/fonts/font.ttf', 10, false); local font2 = dxCreateFont('files/fonts/font.ttf', 14, false); function f_hud( ... ) if (not isPlayerMapVisible()) then local money = convertNumber(getPlayerMoney(getLocalPlayer())) local bank = convertNumber(getElementData(localPlayer, "Bank:Royal") or "0") local realName = getPlayerName(getLocalPlayer()) local Cargo_Atual = getElementData(localPlayer, "DNL:Cargo") dxDrawRectangle(x*1180, y*50, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*100, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*150, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawLine(x*1340, y*85, x*1180, y*85, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*135, x*1180, y*135, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*185, x*1180, y*185, tocolor(0, 60, 160, 255), 3, false) dxDrawImage(x*1180, y*155, x*35, y*35, "files/img/card.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1180, y*110, x*22, y*20, "files/img/money.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1185, y*60, x*20, y*20, "files/img/maleta.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("R$: "..money, x*1240, y*110, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) dxDrawText("R$: "..bank, x*1240, y*160, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) local Encaminhado = getElementData ( localPlayer, "Emprego") or "Desempregado" dxDrawText(Encaminhado, x*1230, y*60, x*1470, y*30, tocolor(255, 255, 255, 221), x*1.00, font, "left", "top", false, false, false, false, false) end end Link to comment
VictorScripting Posted August 20, 2019 Share Posted August 20, 2019 (edited) local arma = getWeaponNameFromID ( weapon ) dxDrawText("Arma: "..arma.. " || Pente: " ..tostring (showammo1).." / "..tostring (showammo2), x*1143, y*400, x*1195, y*82, tocolor(255, 255, 255, 255), x*0.9, fonte, "left", "center", false, false, true, false, false) você vai botar isso alir em arma eu criei a váriavel que é getWeaponNameFromID ( weapon) vai saber/pegar o nome da arma. alir em ..tostring (showammo1) descobre quantas balas tem e o ..tostring (showammo1) quantos pentes em x,y,z pode ta mudando as cordenadas e escolhendo Espero te lhe ajudado Edited August 20, 2019 by Victor Script 1 Link to comment
HG Snuuk Posted August 20, 2019 Author Share Posted August 20, 2019 (edited) eu deixei o codigo assim porem continua n aparecendo nada local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local components = { "area_name", "radio", "vehicle_name" } local font = dxCreateFont('files/fonts/font.ttf', 10, false); local font2 = dxCreateFont('files/fonts/font.ttf', 14, false); function f_hud( ... ) if (not isPlayerMapVisible()) then local money = convertNumber(getPlayerMoney(getLocalPlayer())) local bank = convertNumber(getElementData(localPlayer, "Bank:Royal") or "0") local realName = getPlayerName(getLocalPlayer()) local Cargo_Atual = getElementData(localPlayer, "DNL:Cargo") dxDrawRectangle(x*1180, y*50, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*100, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*150, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawLine(x*1340, y*85, x*1180, y*85, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*135, x*1180, y*135, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*185, x*1180, y*185, tocolor(0, 60, 160, 255), 3, false) dxDrawImage(x*1180, y*155, x*35, y*35, "files/img/card.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1180, y*110, x*22, y*20, "files/img/money.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1185, y*60, x*20, y*20, "files/img/maleta.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("R$: "..money, x*1240, y*110, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) dxDrawText("R$: "..bank, x*1240, y*160, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) local Encaminhado = getElementData ( localPlayer, "Emprego") or "Desempregado" dxDrawText(Encaminhado, x*1230, y*60, x*1470, y*30, tocolor(255, 255, 255, 221), x*1.00, font, "left", "top", false, false, false, false, false) local arma = getWeaponNameFromID ( weapon ) dxDrawText("Arma: "..arma.. " || Pente: " ..tostring (showammo1).." / "..tostring (showammo2), x*1240, y*180, x*1132, y*37, tocolor(255, 255, 255, 255), x*0.9, fonte, "left", "center", false, false, true, false, false) end end Edited August 20, 2019 by HG Snuuk Link to comment
#DeltaSCR Posted August 20, 2019 Share Posted August 20, 2019 (edited) Se tu não renderizar não vai aparecer nada mesmo não ;-; Dica: addEventHandler("onClientRender", root, f_hud) Edited August 20, 2019 by #DeltaSCR 1 Link to comment
HG Snuuk Posted August 20, 2019 Author Share Posted August 20, 2019 1 hour ago, #DeltaSCR said: Se tu não renderizar não vai aparecer nada mesmo não ;-; Dica: addEventHandler("onClientRender", root, f_hud) vlw meu querido tou aprendendo dos poucos ainda Link to comment
HG Snuuk Posted August 20, 2019 Author Share Posted August 20, 2019 2 hours ago, #DeltaSCR said: Se tu não renderizar não vai aparecer nada mesmo não ;-; Dica: addEventHandler("onClientRender", root, f_hud) intão eu coloquei porem continua n funcionando talvez seja alguma coisa que esta faltando esse é o script inteiro local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local components = { "area_name", "radio", "vehicle_name" } local font = dxCreateFont('files/fonts/font.ttf', 10, false); local font2 = dxCreateFont('files/fonts/font.ttf', 14, false); function f_hud( ... ) if (not isPlayerMapVisible()) then local money = convertNumber(getPlayerMoney(getLocalPlayer())) local bank = convertNumber(getElementData(localPlayer, "Bank:Royal") or "0") local realName = getPlayerName(getLocalPlayer()) local Cargo_Atual = getElementData(localPlayer, "DNL:Cargo") dxDrawRectangle(x*1180, y*50, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*100, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*150, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawLine(x*1340, y*85, x*1180, y*85, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*135, x*1180, y*135, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*185, x*1180, y*185, tocolor(0, 60, 160, 255), 3, false) dxDrawImage(x*1180, y*155, x*35, y*35, "files/img/card.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1180, y*110, x*22, y*20, "files/img/money.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1185, y*60, x*20, y*20, "files/img/maleta.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("R$: "..money, x*1240, y*110, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) dxDrawText("R$: "..bank, x*1240, y*160, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) local Encaminhado = getElementData ( localPlayer, "Emprego") or "Desempregado" dxDrawText(Encaminhado, x*1230, y*60, x*1470, y*30, tocolor(255, 255, 255, 221), x*1.00, font, "left", "top", false, false, false, false, false) local arma = getWeaponNameFromID ( weapon ) dxDrawText("Arma: "..arma.. " || Pente: " ..tostring (showammo1).." / "..tostring (showammo2), x*1240, y*180, x*1132, y*37, tocolor(255, 255, 255, 255), x*0.9, fonte, "left", "center", false, false, true, false, false) addEventHandler("onClientRender", root, f_hud) end end function toggleF11() if isVisible then addEventHandler("onClientRender", root, f_hud) else removeEventHandler("onClientRender", root, f_hud) end isVisible = not isVisible end bindKey ("F11", "down", toggleF11) function setHud() addEventHandler("onClientRender", getRootElement(), f_hud) setPlayerHudComponentVisible("armour", false) setPlayerHudComponentVisible("wanted", false) setPlayerHudComponentVisible("weapon", false) setPlayerHudComponentVisible("money", false) setPlayerHudComponentVisible("health", false) setPlayerHudComponentVisible("clock", false) setPlayerHudComponentVisible("breath", false) setPlayerHudComponentVisible("ammo", false) setPlayerHudComponentVisible("radar", false) for _, component in ipairs( components ) do setPlayerHudComponentVisible( component, false ) end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), setHud) function removeHud() setPlayerHudComponentVisible("armour", true) setPlayerHudComponentVisible("wanted", true) setPlayerHudComponentVisible("weapon", true) setPlayerHudComponentVisible("money", true) setPlayerHudComponentVisible("health", true) setPlayerHudComponentVisible("clock", true) setPlayerHudComponentVisible("breath", true) setPlayerHudComponentVisible("ammo", true) setPlayerHudComponentVisible("radar", true) end addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), removeHud) 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) assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") local stat = getPedStat(ped, 24) local maxhealth = 100 + (stat - 569) / 4.31 return math.max(1, maxhealth) end Link to comment
#DeltaSCR Posted August 20, 2019 Share Posted August 20, 2019 Ponha o Evento onClientRender no final da função, no seu caso, na linha 39. 1 Link to comment
HG Snuuk Posted August 21, 2019 Author Share Posted August 21, 2019 Intão fiz isso porem nada ainda local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local components = { "area_name", "radio", "vehicle_name" } local font = dxCreateFont('files/fonts/font.ttf', 10, false); local font2 = dxCreateFont('files/fonts/font.ttf', 14, false); function f_hud( ... ) if (not isPlayerMapVisible()) then local money = convertNumber(getPlayerMoney(getLocalPlayer())) local bank = convertNumber(getElementData(localPlayer, "Bank:Royal") or "0") local realName = getPlayerName(getLocalPlayer()) local Cargo_Atual = getElementData(localPlayer, "DNL:Cargo") dxDrawRectangle(x*1180, y*50, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*100, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*150, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawLine(x*1340, y*85, x*1180, y*85, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*135, x*1180, y*135, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*185, x*1180, y*185, tocolor(0, 60, 160, 255), 3, false) dxDrawImage(x*1180, y*155, x*35, y*35, "files/img/card.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1180, y*110, x*22, y*20, "files/img/money.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1185, y*60, x*20, y*20, "files/img/maleta.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("R$: "..money, x*1240, y*110, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) dxDrawText("R$: "..bank, x*1240, y*160, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) local Encaminhado = getElementData ( localPlayer, "Emprego") or "Desempregado" dxDrawText(Encaminhado, x*1230, y*60, x*1470, y*30, tocolor(255, 255, 255, 221), x*1.00, font, "left", "top", false, false, false, false, false) local arma = getWeaponNameFromID ( weapon ) dxDrawText("Arma: "..arma.. " || Pente: " ..tostring (showammo1).." / "..tostring (showammo2), x*1240, y*180, x*1132, y*37, tocolor(255, 255, 255, 255), x*0.9, fonte, "left", "center", false, false, true, false, false) end end addEventHandler("onClientRender", root, f_hud) function toggleF11() if isVisible then addEventHandler("onClientRender", root, f_hud) else removeEventHandler("onClientRender", root, f_hud) end isVisible = not isVisible end bindKey ("F11", "down", toggleF11) Link to comment
HG Snuuk Posted August 22, 2019 Author Share Posted August 22, 2019 On 21/08/2019 at 15:46, HG Snuuk said: Intão fiz isso porem nada ainda local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local components = { "area_name", "radio", "vehicle_name" } local font = dxCreateFont('files/fonts/font.ttf', 10, false); local font2 = dxCreateFont('files/fonts/font.ttf', 14, false); function f_hud( ... ) if (not isPlayerMapVisible()) then local money = convertNumber(getPlayerMoney(getLocalPlayer())) local bank = convertNumber(getElementData(localPlayer, "Bank:Royal") or "0") local realName = getPlayerName(getLocalPlayer()) local Cargo_Atual = getElementData(localPlayer, "DNL:Cargo") dxDrawRectangle(x*1180, y*50, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*100, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*150, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawLine(x*1340, y*85, x*1180, y*85, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*135, x*1180, y*135, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*185, x*1180, y*185, tocolor(0, 60, 160, 255), 3, false) dxDrawImage(x*1180, y*155, x*35, y*35, "files/img/card.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1180, y*110, x*22, y*20, "files/img/money.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1185, y*60, x*20, y*20, "files/img/maleta.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("R$: "..money, x*1240, y*110, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) dxDrawText("R$: "..bank, x*1240, y*160, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) local Encaminhado = getElementData ( localPlayer, "Emprego") or "Desempregado" dxDrawText(Encaminhado, x*1230, y*60, x*1470, y*30, tocolor(255, 255, 255, 221), x*1.00, font, "left", "top", false, false, false, false, false) local arma = getWeaponNameFromID ( weapon ) dxDrawText("Arma: "..arma.. " || Pente: " ..tostring (showammo1).." / "..tostring (showammo2), x*1240, y*180, x*1132, y*37, tocolor(255, 255, 255, 255), x*0.9, fonte, "left", "center", false, false, true, false, false) end end addEventHandler("onClientRender", root, f_hud) function toggleF11() if isVisible then addEventHandler("onClientRender", root, f_hud) else removeEventHandler("onClientRender", root, f_hud) end isVisible = not isVisible end bindKey ("F11", "down", toggleF11) https://prnt.sc/owault este é o debug Link to comment
Other Languages Moderators Lord Henry Posted August 23, 2019 Other Languages Moderators Share Posted August 23, 2019 Naquela linha 32, weapon não foi declarado em lugar nenhum. 1 Link to comment
HG Snuuk Posted August 23, 2019 Author Share Posted August 23, 2019 2 hours ago, Lord Henry said: Naquela linha 32, weapon não foi declarado em lugar nenhum. https://prnt.sc/owdo4u local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local components = { "area_name", "radio", "vehicle_name" } local font = dxCreateFont('files/fonts/font.ttf', 10, false); local font2 = dxCreateFont('files/fonts/font.ttf', 14, false); function f_hud( ... ) if (not isPlayerMapVisible()) then local money = convertNumber(getPlayerMoney(getLocalPlayer())) local bank = convertNumber(getElementData(localPlayer, "Bank:Royal") or "0") local realName = getPlayerName(getLocalPlayer()) local Cargo_Atual = getElementData(localPlayer, "DNL:Cargo") local weapon = getPedWeapon ( getLocalPlayer() ) local arma = getWeaponNameFromID ( weapon ) dxDrawRectangle(x*1180, y*50, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*100, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawRectangle(x*1180, y*150, x*160, y*35, tocolor(0, 0, 0, 230), false) dxDrawLine(x*1340, y*85, x*1180, y*85, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*135, x*1180, y*135, tocolor(0, 60, 160, 255), 3, false) dxDrawLine(x*1340, y*185, x*1180, y*185, tocolor(0, 60, 160, 255), 3, false) dxDrawImage(x*1180, y*155, x*35, y*35, "files/img/card.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1180, y*110, x*22, y*20, "files/img/money.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1185, y*60, x*20, y*20, "files/img/maleta.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("R$: "..money, x*1240, y*110, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) dxDrawText("R$: "..bank, x*1240, y*160, x*1132, y*37, tocolor(255, 255, 255, 221), 1.00, font, "left", "top", false, false, false, true, false) local Encaminhado = getElementData ( localPlayer, "Emprego") or "Desempregado" dxDrawText(Encaminhado, x*1230, y*60, x*1470, y*30, tocolor(255, 255, 255, 221), x*1.00, font, "left", "top", false, false, false, false, false) dxDrawText("Arma: "..arma.. " || Pente: " ..tostring (showammo1).." / "..tostring (showammo2), x*1143, y*130, x*1195, y*82, tocolor(255, 255, 255, 255), x*0.9, fonte, "left", "center", false, false, true, false, false) end end addEventHandler("onClientRender", root, f_hud) function toggleF11() if isVisible then addEventHandler("onClientRender", root, f_hud) else removeEventHandler("onClientRender", root, f_hud) end isVisible = not isVisible end bindKey ("F11", "down", toggleF11) Link to comment
Other Languages Moderators Lord Henry Posted August 23, 2019 Other Languages Moderators Share Posted August 23, 2019 O arquivo files/fonts/font.ttf não existe ou não foi declarado no meta.xml 1 Link to comment
HG Snuuk Posted August 23, 2019 Author Share Posted August 23, 2019 4 hours ago, Lord Henry said: O arquivo files/fonts/font.ttf não existe ou não foi declarado no meta.xml vlw meu querido dei uma olhada tava dando erro no dx da arma por causa de uma letra no arquivo da font , tava fonte . vlw meu querido 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