Sparta Posted August 16, 2019 Share Posted August 16, 2019 GALERA TO CRIANDO UM SERVE, COLOQUEI UMA HUD E UM PAINEL LOGIN MAS O A HUD FICA SOBREPÕE O PAINEL LOGIN, ALGUÉM ME AJUDA IMAGEM DA HUD BUGADA: https://imgur.com/BFxvCck local screenH, screenW = guiGetScreenSize() local x, y = (screenH/1366), (screenW/768) local fonte = dxCreateFont("files/fonts/fonte.ttf", 10) --[[ dxDrawRectangle(451, 298, 186, 97, tocolor(0, 0, 0, 122), false) dxDrawRectangle(461, 308, 166, 77, tocolor(229, 112, 17, 208), false) ]] function HUD () if getElementData(getLocalPlayer(), "isPolice") then jobPolice = "Policial" else jobPolice = nil end local showammo1 = getPedAmmoInClip (localPlayer,getPedWeaponSlot(localPlayer)) local showammo2 = getPedTotalAmmo(localPlayer)-getPedAmmoInClip(localPlayer) local showammo3 = getPedTotalAmmo(getLocalPlayer()) local clip = getPedAmmoInClip (getLocalPlayer()) local weapon = getPedWeapon ( getLocalPlayer() ) local arma = getWeaponNameFromID ( weapon ) local SaldoBanco = getElementData(localPlayer,"banco:Saldo") or 0 local Procurado = getPlayerWantedLevel(localPlayer) local Level = getElementData(localPlayer,"Level") or 0 local Emp = jobPolice or (getElementData(getLocalPlayer(), "Emprego") or "Desempregado") local dinheiro1 = ("%008d"):format(getPlayerMoney(getLocalPlayer())) local color1 = tocolor(0,0,0,178) local color2 = tocolor(0,0,0,178) local color3 = tocolor(0,0,0,178) dxDrawImage(x*920, y*-25, x*215, y*112, "files/img/RetanguloHud.png", 0, 0, 0, tocolor(0, 0, 0, 255), true) dxDrawImage(x*1110, y*-25, x*215, y*112, "files/img/RetanguloHud.png", 0, 0, 0, tocolor(0, 0, 0, 255), true) dxDrawImage(x*1110, y*25, x*215, y*112, "files/img/RetanguloHud.png", 0, 0, 0, tocolor(0, 0, 0, 255), true) dxDrawImage(x*920, y*25, x*215, y*112, "files/img/RetanguloHud.png", 0, 0, 0, tocolor(0, 0, 0, 255), true) dxDrawImage(x*1020, y*70, x*215, y*112, "files/img/RetanguloHud.png", 0, 0, 0, tocolor(0, 0, 0, 255), false) dxDrawImage(x*944, y*18, x*26, y*30, "files/img/IconeMala.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(x*1134, y*15, x*31, y*38, "files/img/IconeDinheiro.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(x*1139, y*70, x*23, y*26, "files/img/IconeCartao.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(x*1050, y*116, x*23, y*21, "files/img/EstrelaIcone.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawText("Level: "..Level, x*944, y*-9, x*1202, y*173, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) dxDrawText(""..SaldoBanco, x*1175, y*40, x*1195, y*128, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) dxDrawText(""..Procurado, x*1090, y*36, x*1189, y*219, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) dxDrawText("$"..dinheiro1, x*1175, y*-16, x*1195, y*82, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) dxDrawText(Emp, x*985, y*-16, x*1195, y*82, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) dxDrawText("Arma: "..arma.. " || Pente: " ..tostring (showammo1).." / "..tostring (showammo2), x*1075, y*250, x*1195, y*82, tocolor(255, 255, 255, 255), x*0.9, fonte, "left", "center", false, false, true, false, false) end addEventHandler("onClientRender", getRootElement(), HUD) function OnStop () setPlayerHudComponentVisible("armour", true) setPlayerHudComponentVisible("wanted", true) setPlayerHudComponentVisible("weapon", true) setPlayerHudComponentVisible("money", true) setPlayerHudComponentVisible("health", true) setPlayerHudComponentVisible("clock", true) setPlayerHudComponentVisible("breath", true) setPlayerHudComponentVisible("ammo", true) end addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), OnStop) function OnStart () setPlayerHudComponentVisible("armour", false) setPlayerHudComponentVisible("wanted", false) setPlayerHudComponentVisible("weapon", false) setPlayerHudComponentVisible("money", false) setPlayerHudComponentVisible("health", false) setPlayerHudComponentVisible("clock", false) setPlayerHudComponentVisible("breath", false) setPlayerHudComponentVisible("ammo", false) end addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), OnStart ) local hudTable = { "ammo", "armour", "clock", "health", "money", "weapon", "wanted", "area_name", "vehicle_name", "breath", "clock" } addEventHandler("onClientResourceStart", resourceRoot, function() for id, hudComponents in ipairs(hudTable) do showPlayerHudComponent(hudComponents, false) end end ) addEventHandler("onClientResourceStop", resourceRoot, function() for id, hudComponents in ipairs(hudTable) do showPlayerHudComponent(hudComponents, true) end end ) Link to comment
DNL291 Posted August 16, 2019 Share Posted August 16, 2019 Faça uma função exportada para remover/mostrar o dx; painel de login você chama ela para desativar a hud. @Sparta 1 Link to comment
Sparta Posted August 16, 2019 Author Share Posted August 16, 2019 1 hour ago, DNL291 said: Faça uma função exportada para remover/mostrar o dx; painel de login você chama ela para desativar a hud. @Sparta Cara vc pode me ajudar Pq Já tentei e não consegui so um pouco leigo no assunto Link to comment
DNL291 Posted August 16, 2019 Share Posted August 16, 2019 Crie outro script do lado server e cole o seguinte código: addEventHandler( "onPlayerLogin", root, function() triggerClientEvent( source, "onRequestShowPlayerHUD", source, true ) end, true, "low" ) No meta.xml deixe como type="server", exemplo: <script src="script.Lua" type="server"/> O script client que você postou, substitua por este novo: local screenH, screenW = guiGetScreenSize() local x, y = (screenH/1366), (screenW/768) local fonte = dxCreateFont("files/fonts/fonte.ttf", 10) local rendering = false --[[ dxDrawRectangle(451, 298, 186, 97, tocolor(0, 0, 0, 122), false) dxDrawRectangle(461, 308, 166, 77, tocolor(229, 112, 17, 208), false) ]] function HUD () if getElementData(getLocalPlayer(), "isPolice") then jobPolice = "Policial" else jobPolice = nil end local showammo1 = getPedAmmoInClip (localPlayer,getPedWeaponSlot(localPlayer)) local showammo2 = getPedTotalAmmo(localPlayer)-getPedAmmoInClip(localPlayer) local showammo3 = getPedTotalAmmo(getLocalPlayer()) local clip = getPedAmmoInClip (getLocalPlayer()) local weapon = getPedWeapon ( getLocalPlayer() ) local arma = getWeaponNameFromID ( weapon ) local SaldoBanco = getElementData(localPlayer,"banco:Saldo") or 0 local Procurado = getPlayerWantedLevel(localPlayer) local Level = getElementData(localPlayer,"Level") or 0 local Emp = jobPolice or (getElementData(getLocalPlayer(), "Emprego") or "Desempregado") local dinheiro1 = ("%008d"):format(getPlayerMoney(getLocalPlayer())) local color1 = tocolor(0,0,0,178) local color2 = tocolor(0,0,0,178) local color3 = tocolor(0,0,0,178) dxDrawImage(x*920, y*-25, x*215, y*112, "files/img/RetanguloHud.png", 0, 0, 0, tocolor(0, 0, 0, 255), true) dxDrawImage(x*1110, y*-25, x*215, y*112, "files/img/RetanguloHud.png", 0, 0, 0, tocolor(0, 0, 0, 255), true) dxDrawImage(x*1110, y*25, x*215, y*112, "files/img/RetanguloHud.png", 0, 0, 0, tocolor(0, 0, 0, 255), true) dxDrawImage(x*920, y*25, x*215, y*112, "files/img/RetanguloHud.png", 0, 0, 0, tocolor(0, 0, 0, 255), true) dxDrawImage(x*1020, y*70, x*215, y*112, "files/img/RetanguloHud.png", 0, 0, 0, tocolor(0, 0, 0, 255), false) dxDrawImage(x*944, y*18, x*26, y*30, "files/img/IconeMala.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(x*1134, y*15, x*31, y*38, "files/img/IconeDinheiro.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(x*1139, y*70, x*23, y*26, "files/img/IconeCartao.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawImage(x*1050, y*116, x*23, y*21, "files/img/EstrelaIcone.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawText("Level: "..Level, x*944, y*-9, x*1202, y*173, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) dxDrawText(""..SaldoBanco, x*1175, y*40, x*1195, y*128, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) dxDrawText(""..Procurado, x*1090, y*36, x*1189, y*219, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) dxDrawText("$"..dinheiro1, x*1175, y*-16, x*1195, y*82, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) dxDrawText(Emp, x*985, y*-16, x*1195, y*82, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) dxDrawText("Arma: "..arma.. " || Pente: " ..tostring (showammo1).." / "..tostring (showammo2), x*1075, y*250, x*1195, y*82, tocolor(255, 255, 255, 255), x*0.9, fonte, "left", "center", false, false, true, false, false) end -- função exportada function setPlayerDXHudVisible( bool ) if bool == rendering then return end -- if bool == true then addEventHandler("onClientRender", getRootElement(), HUD) rendering = bool elseif bool == false then removeEventHandler("onClientRender", getRootElement(), HUD) rendering = bool end end addEvent( "onRequestShowPlayerHUD", true ) addEventHandler( "onRequestShowPlayerHUD", root, setPlayerDXHudVisible ) function OnStop () setPlayerHudComponentVisible("armour", true) setPlayerHudComponentVisible("wanted", true) setPlayerHudComponentVisible("weapon", true) setPlayerHudComponentVisible("money", true) setPlayerHudComponentVisible("health", true) setPlayerHudComponentVisible("clock", true) setPlayerHudComponentVisible("breath", true) setPlayerHudComponentVisible("ammo", true) end addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), OnStop) function OnStart () setPlayerHudComponentVisible("armour", false) setPlayerHudComponentVisible("wanted", false) setPlayerHudComponentVisible("weapon", false) setPlayerHudComponentVisible("money", false) setPlayerHudComponentVisible("health", false) setPlayerHudComponentVisible("clock", false) setPlayerHudComponentVisible("breath", false) setPlayerHudComponentVisible("ammo", false) end addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), OnStart ) local hudTable = { "ammo", "armour", "clock", "health", "money", "weapon", "wanted", "area_name", "vehicle_name", "breath", "clock" } addEventHandler("onClientResourceStart", resourceRoot, function() for id, hudComponents in ipairs(hudTable) do showPlayerHudComponent(hudComponents, false) end end ) addEventHandler("onClientResourceStop", resourceRoot, function() for id, hudComponents in ipairs(hudTable) do showPlayerHudComponent(hudComponents, true) end end ) Adicione a função no meta.xml para exportá-la: <export function="setPlayerDXHudVisible" type="client"/> Vai ser útil se você precisar ocultar o hud quando necessário. Obs: não testei o código; lembre-se de fazer o teste com o debug ativado (/debugscript 3). Link to comment
Sparta Posted August 17, 2019 Author Share Posted August 17, 2019 (edited) Só mais uma dúvida, para configurar o sistema de banco a hud, no caso quando deposita aparecer na hud. Eu consegui configurar o sistema de level que é separado utilizando local Level = getElementData(localPlayer,"Level") or 0 mas o de banco não consigo! Sistema da hud! local SaldoBanco = getElementData(localPlayer,"banco:Saldo") or 0 dxDrawText(""..SaldoBanco, x*1175, y*107, x*1195, y*128, tocolor(255, 255, 255, 255), x*1.00, fonte, "left", "center", false, false, true, false, false) Sistema do banco! addEvent("paraYatirPara",true) addEventHandler("paraYatirPara",root, function (miktar) local acc = getPlayerAccount (source) if (miktar) then local para = getPlayerMoney (source) if (para >= tonumber(miktar)) then local bankaParasi = getAccountData (acc,"BankaPara") takePlayerMoney (source,miktar) setAccountData (acc,"BankaPara",tonumber(bankaParasi) + tonumber (miktar)) local bankaParasi2 = getAccountData (acc,"BankaPara") local para = getPlayerMoney (source) triggerClientEvent(source, "paraYatirParaC", source,bankaParasi2,para,""..tostring(miktar).." $ foi DEPOSITADO!") local pName = getPlayerName (source) local BankMiktar = getAccountData (acc,"BankaPara") else local bankaParasi2 = getAccountData (acc,"BankaPara") local para = getPlayerMoney (source) triggerClientEvent(source, "paraYatirParaC", source,bankaParasi2,para,"Dinheiro insuficiente!") addEvent("paraCekPara",true) addEventHandler("paraCekPara",root, function (miktar) local acc = getPlayerAccount (source) if (miktar) then local bankaParasi = getAccountData (acc,"BankaPara") if (tonumber(bankaParasi) >= tonumber(miktar)) then givePlayerMoney (source,tonumber(miktar)) setAccountData (acc,"BankaPara",tonumber(bankaParasi) - tonumber (miktar)) local bankaParasi2 = getAccountData (acc,"BankaPara") triggerClientEvent(source, "paraCekParaC", source,bankaParasi2,""..tostring(miktar).." $ Foi retirado!") local pName = getPlayerName (source) local BankMiktar = getAccountData (acc,"BankaPara") else local bankaParasi2 = getAccountData (acc,"BankaPara") triggerClientEvent(source, "paraCekParaC", source,bankaParasi2,"Você não tem dinheiro suficiente no banco!") end OBS: não é todo o script do banco! Edited August 17, 2019 by Sparta Link to comment
DNL291 Posted August 17, 2019 Share Posted August 17, 2019 Tem que atualizar a elementData quando depositar/sacar. Link to comment
Sparta Posted August 18, 2019 Author Share Posted August 18, 2019 Sim eu atualizei, mesmo assim não tinha funcionado, mas eu troquei o script do banco e deu certo! 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