..:D&G:.. Posted January 19, 2014 Posted January 19, 2014 How do I trigger this event: addCommandHandler("showhud", function () if handler then removeEventHandler("onClientRender",root,renderHud) handler = false else addEventHandler("onClientRender",root,renderHud) handler = true end So its handler = false like ONLY AN EXAMPLE: triggerEvent("hideHud", getLocalPlayer()) Or do I need to make an event? MTA:Rust Pre-Alpha Build v.0.3: https://forum.mtasa.com/viewtopic.php?f=114&t=97848 2Pac: ''Only God can judge me!''
Moderators IIYAMA Posted January 19, 2014 Moderators Posted January 19, 2014 local handler = false function myHudFunction () if handler then removeEventHandler("onClientRender",root,renderHud) handler = false else addEventHandler("onClientRender",root,renderHud) handler = true end end addCommandHandler("showhud",myHudFunction) addEvent("hideHud",true) addEventHandler("hideHud",root,myHudFunction) triggerEvent("hideHud", getLocalPlayer()) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
..:D&G:.. Posted January 19, 2014 Author Posted January 19, 2014 Doesn't work Here is what I did in the other script that triggers the event function hideInterfaceComponents() triggerEvent("hideHud", getLocalPlayer()) loadSettings() saveLanguageInformation() end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), hideInterfaceComponents) MTA:Rust Pre-Alpha Build v.0.3: https://forum.mtasa.com/viewtopic.php?f=114&t=97848 2Pac: ''Only God can judge me!''
Anubhav Posted January 19, 2014 Posted January 19, 2014 addEvent ( "hideHud", true ) addCommandHandler("showhud", function () if handler then removeEventHandler("onClientRender",root,renderHud) handler = false else addEventHandler("onClientRender",root,renderHud) handler = true end addEventHandler ( "hideHud", root, myHudFunction ) triggerEvent ( "hideHud", root, getLocalPlayer() ) See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Moderators IIYAMA Posted January 19, 2014 Moderators Posted January 19, 2014 [quote name=..&G:..]Doesn't work Here is what I did in the other script that triggers the event function hideInterfaceComponents() triggerEvent("hideHud", getLocalPlayer()) loadSettings() saveLanguageInformation() end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), hideInterfaceComponents) 1 That other script was already running before you triggered the event? 2 And what happens when you do: triggerEvent("hideHud", getLocalPlayer()) triggerEvent("hideHud", root) 3 Both are 100% clientside? 4 And what will happen when you put the event in the same script? Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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