..:D&G:.. Posted December 26, 2013 Share Posted December 26, 2013 Hey, I recently made a hud, and I want to hide it while the player is on the login screen. There is already a function to hide the default hud: function hideInterfaceComponents() --triggerEvent("hideHud", getLocalPlayer()) showPlayerHudComponent("weapon", false) showPlayerHudComponent("ammo", false) showPlayerHudComponent("vehicle_name", false) showPlayerHudComponent("money", false) showPlayerHudComponent("clock", false) showPlayerHudComponent("health", false) showPlayerHudComponent("armour", false) showPlayerHudComponent("breath", false) showPlayerHudComponent("area_name", false) showPlayerHudComponent("radar", false) --triggerEvent("hideHud", getLocalPlayer()) loadSettings() saveLanguageInformation() end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), hideInterfaceComponents) But I need to hide the hud using its function (function hud....) as I can't use showPlayerHudComponent Link to comment
Sasu Posted December 26, 2013 Share Posted December 26, 2013 You have to create your own function. Link to comment
..:D&G:.. Posted December 26, 2013 Author Share Posted December 26, 2013 [quote name=..&G:..] (function hud....) The function is called hud Link to comment
johny46 Posted December 27, 2013 Share Posted December 27, 2013 Nobody can help you without knowing what custom HUD do you use, or how does it work if you wrote it yourself. I guess it uses the dx function, and thus it can be easily hidden by either removing the event handler for the time the player logs in, or creating a variable that would be checked before the drawing functions, and if it doesn't match, then don't draw the HUD. Link to comment
Leonard.DC Posted December 27, 2013 Share Posted December 27, 2013 cancelEvent onPlayerJoin or removeEventHandler onPlayerJoin There is the most i can say you, if you don't show the code Link to comment
..:D&G:.. Posted December 27, 2013 Author Share Posted December 27, 2013 I don't really know why you want to see a function with some dx lines... But anyway here is the code: function hudComponents ( ) munitie = getPedTotalAmmo ( getLocalPlayer() ) clip = getPedAmmoInClip ( getLocalPlayer() ) IDarma = getPedWeapon(getLocalPlayer()) arma = getWeaponNameFromID(IDarma) viata = getElementHealth (localPlayer) armura = getPedArmor (localPlayer) bani = getPlayerMoney(thePlayer) dxDrawRectangle(15, 240, 264, 78, tocolor(0, 0, 0, 209), false) dxDrawLine(15, 260, 278, 260, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(15, 279, 278, 279, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(15, 296, 278, 296, tocolor(255, 255, 255, 255), 1, false) dxDrawText("World Gaming Roleplay Hud", 14, 213, 277, 233, tocolor(255, 255, 255, 255), 0.90, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("Bani: "..bani.." Lei",21.0,244.0,474.0,272.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Viata: "..tostring(math.floor(viata+0.5)).." %",20.0,264.0,296.0,280.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Armura: "..tostring(math.floor(armura+0.5)).." %",20.0,281.0,296.0,280.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Arma: "..arma.." | Munitie: "..clip.." / "..munitie,20.0,296.0,296.0,301.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) end addEventHandler("onClientRender",getRootElement(),hudComponents) addEventHandler("onClientPlayerSpawn",getRootElement(),) Link to comment
Leonard.DC Posted December 27, 2013 Share Posted December 27, 2013 Client: function hudComponents ( ) munitie = getPedTotalAmmo ( getLocalPlayer() ) clip = getPedAmmoInClip ( getLocalPlayer() ) IDarma = getPedWeapon(getLocalPlayer()) arma = getWeaponNameFromID(IDarma) viata = getElementHealth (localPlayer) armura = getPedArmor (localPlayer) bani = getPlayerMoney(thePlayer) end addEventHandler("loginHudShow",getRootElement(), hudComponents) addEvent ("loginHudShow", true) addEventHandler("onClientRender",getRootElement(), dxDrawRectangle(15, 240, 264, 78, tocolor(0, 0, 0, 209), false) dxDrawLine(15, 260, 278, 260, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(15, 279, 278, 279, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(15, 296, 278, 296, tocolor(255, 255, 255, 255), 1, false) dxDrawText("World Gaming Roleplay Hud", 14, 213, 277, 233, tocolor(255, 255, 255, 255), 0.90, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("Bani: "..bani.." Lei",21.0,244.0,474.0,272.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Viata: "..tostring(math.floor(viata+0.5)).." %",20.0,264.0,296.0,280.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Armura: "..tostring(math.floor(armura+0.5)).." %",20.0,281.0,296.0,280.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Arma: "..arma.." | Munitie: "..clip.." / "..munitie,20.0,296.0,296.0,301.0,tocolor(0,255,0,255),0.5,"bankgothic","left","top",false,false,false) end ) Server: function showHudOnLogin () triggerClientEvent (source, "loginHudShow", source) end addEventHandler ("onPlayerLogin", getRootElement(), showHudOnLogin) (Not tested) Link to comment
..:D&G:.. Posted December 27, 2013 Author Share Posted December 27, 2013 (edited) EDITED! Found another way but I don't know how to set the alpha or to disable the dx drawn parts... Edited December 27, 2013 by Guest Link to comment
johny46 Posted December 27, 2013 Share Posted December 27, 2013 To hide the HUD: removeEventHandler("onClientRender",getRootElement(),hudComponents) To show the HUD: addEventHandler("onClientRender",getRootElement(),hudComponents) Of course it's not the best solution at all, but it should do the trick. Link to comment
..:D&G:.. Posted December 27, 2013 Author Share Posted December 27, 2013 Ok, now how do I use triggerEvent to add and remove the event of the hud from the login script, do I need to make a function hudComponents for each remove and add events? Link to comment
Leonard.DC Posted December 28, 2013 Share Posted December 28, 2013 Why you ignore my post? I have added a event and triggered it from server side, like if player join the hud doesn't show, but onPlayerLogin the hud shows, if you need to remove the hud when the login panel opens, you must add it to the login panel script, or use the function Call Link to comment
..:D&G:.. Posted December 28, 2013 Author Share Posted December 28, 2013 Look, onPlayerLogin is useless, is not a login like the ones on play servers, or LIKE the default /login... So this won't really work, this login is only a window where you put some details and click a button to close the window and be able to play (something like that) Doesn't matter anyway, did it which what johny46 recommended me. Thanks. Link to comment
Moderators IIYAMA Posted December 28, 2013 Moderators Share Posted December 28, 2013 Don't forget to make your variables local, especially when you use render functions. It simply will start lagging if you don't. local renderHud = function () local munitie = getPedTotalAmmo ( localPlayer) local clip = getPedAmmoInClip ( localPlayer) local IDarma = getPedWeapon(localPlayer) local arma = getWeaponNameFromID(IDarma) local viata = getElementHealth (localPlayer) local armura = getPedArmor (localPlayer) local bani = getPlayerMoney()-- "thePlayer" this shouldn't be there. -- put your dx stuff here-- -------------------------------- end local handler = true addEventHandler("onClientRender",root,renderHud) addCommandHandler("showhud", function () if handler then removeEventHandler("onClientRender",root,renderHud) handler = false else addEventHandler("onClientRender",root,renderHud) handler = true end end) Link to comment
..:D&G:.. Posted December 29, 2013 Author Share Posted December 29, 2013 It simply will start lagging if you don't. Noticed that, thanks 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