iPollo Posted March 1, 2020 Share Posted March 1, 2020 (edited) Hello everyone, I started recently, so I'm really a layman, with very little knowledge in the MTA area, I'm triggering an event, and it seems to call correctly, but the dxDrawText functions are not being executed, nor the showCursor Function calling the event in another script triggerClientEvent(source,"onLogin",source) And here's the eventHandler in another script local screenW, screenH = guiGetScreenSize() addEventHandler("onLogin", getRootElement(), function() GUIEditor.pImg[1] = guiCreateStaticImage(0.32, 0.32, 0.19, 0.35, ":player/player_Sexo/IMG/IMG_Masculino.png", true) guiSetAlpha(GUIEditor.pImg[1], 0.85) GUIEditor.pImg[2] = guiCreateStaticImage(0.50, 0.32, 0.19, 0.35, ":player/player_Sexo/IMG/IMG_Feminino.png", true) guiSetAlpha(GUIEditor.pImg[2], 0.86) dxDrawText("MASCULINO", screenW * 0.3602, screenH * 0.3083, screenW * 0.4586, screenH * 0.3431, tocolor(255, 255, 255, 255), 1.00, "default", "center", "top", false, false, false, false, false) dxDrawText("FEMININO", screenW * 0.5406, screenH * 0.3083, screenW * 0.6391, screenH * 0.3431, tocolor(255, 255, 255, 255), 1.00, "default", "center", "top", false, false, false, false, false) showCursor(source) outputChatBox("FUNÇÃO CHAMADA") end ) Edited March 1, 2020 by iPollo Link to comment
_Ace Posted March 1, 2020 Share Posted March 1, 2020 I think you need to register the event, use addEvent("onLogin",true) on line 2, also Im not sure how you are using triggerClientEvent, if it will fire for all players or only the source of (?), you need to check it, I tested it inside a command and firing at resource root and its working Link to comment
Moderators Patrick Posted March 1, 2020 Moderators Share Posted March 1, 2020 Dx functions, like dxDrawText shows only once (for 1 frame). You need to use these function in a render function, like onClientRender what call it in every frame. function renderFunction() dxDrawText("MASCULINO", screenW * 0.3602, screenH * 0.3083, screenW * 0.4586, screenH * 0.3431, tocolor(255, 255, 255, 255), 1.00, "default", "center", "top", false, false, false, false, false) dxDrawText("FEMININO", screenW * 0.5406, screenH * 0.3083, screenW * 0.6391, screenH * 0.3431, tocolor(255, 255, 255, 255), 1.00, "default", "center", "top", false, false, false, false, false) end And you can start the render with onClientRender event, attach it to `renderFunction`. addEventHandler("onClientRender", root, renderFunction) -- and stop it with: removeEventHandler("onClientRender", root, renderFunction) Link to comment
iPollo Posted March 2, 2020 Author Share Posted March 2, 2020 43 minutes ago, Patrick said: Dx functions, like dxDrawText shows only once (for 1 frame). You need to use these function in a render function, like onClientRender what call it in every frame. function renderFunction() dxDrawText("MASCULINO", screenW * 0.3602, screenH * 0.3083, screenW * 0.4586, screenH * 0.3431, tocolor(255, 255, 255, 255), 1.00, "default", "center", "top", false, false, false, false, false) dxDrawText("FEMININO", screenW * 0.5406, screenH * 0.3083, screenW * 0.6391, screenH * 0.3431, tocolor(255, 255, 255, 255), 1.00, "default", "center", "top", false, false, false, false, false) end And you can start the render with onClientRender event, attach it to `renderFunction`. addEventHandler("onClientRender", root, renderFunction) -- and stop it with: removeEventHandler("onClientRender", root, renderFunction) Using this way you showed it worked, but it appears on the login screen, how can i put, to show at specific times, as if I had the ability to "hide" them and "show" them again Link to comment
Moderators Patrick Posted March 2, 2020 Moderators Share Posted March 2, 2020 (edited) 19 hours ago, iPollo said: Using this way you showed it worked, but it appears on the login screen, how can i put, to show at specific times, as if I had the ability to "hide" them and "show" them again You can show it if attach function to the onClientRender Event and hide it if you remove the handler. (like in example) But you can use gui label, its works like other gui elements. => https://wiki.multitheftauto.com/wiki/GuiCreateLabel Edited March 2, 2020 by Patrick 1 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