Jump to content

addEventHandler in function


Xwad

Recommended Posts

Hi. Is it possible to add an event in a function like this? I mean that the event will only be activated when the function starts, and will not work until i enter the command.

Function event (commandName)

addEventHandler ("onClientPlayerVehicleEnter", root, function)

End

addCommandHandler ("test", event)

Link to comment

Its not working:/ Bad usage @ 'onClientRender' ['onClientRender' with this function is already handled']

  
function onExit(theElement) 
removeEventHandler("onClientRender", getRootElement(), rotate)  
end 
  
  
  
function bindFire () 
  addEventHandler("onClientRender", getRootElement(), rotate) 
end 
addEvent( "bindFire", true ) 
addEventHandler( "bindFire", localPlayer, bindFire ) 
  
  
  
  
function rotate() 
setElementRotation(weapon, 0, 3.2, 96.92 - getPedCameraRotation(localPlayer)) 
setElementRotation(localPlayer, 0, 0, 0 - getPedCameraRotation(localPlayer)) 
end 
  

Link to comment

addEventHandler( "bindFire", localPlayer, bindFire )

try changing it to

addEventHandler( "bindFire", resourceRoot, bindFire )

if it's being triggered from the server, use triggerClientEvent(thePlayer,"bindFire",resourceRoot) make sure thePlayer is defined, or use source.

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...