Jump to content

Trigger a client side event handler


..:D&G:..

Recommended Posts

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?

Link to comment
  • Moderators
  
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()) 

Link to comment

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) 
  

Link to comment
  
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() ) 
  

Link to comment
  • Moderators

[quote name=..:D&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?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...