Xwad Posted January 30, 2016 Share Posted January 30, 2016 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
SpecT Posted January 30, 2016 Share Posted January 30, 2016 Yeah, of course it will work! That's how the DX panels work - when you click a button => addEventHandler("onClientRender", root, function) or removeEventHandler("onClientRender", root, function) Link to comment
Xwad Posted January 30, 2016 Author Share Posted January 30, 2016 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
Drakath Posted January 30, 2016 Share Posted January 30, 2016 function bindFire () removeEventHandler("onClientRender", getRootElement(), rotate) addEventHandler("onClientRender", getRootElement(), rotate) end addEvent( "bindFire", true ) addEventHandler( "bindFire", localPlayer, bindFire ) Link to comment
SpecT Posted January 30, 2016 Share Posted January 30, 2016 Add: removeEventHandler("onClientRender", getRootElement(), rotate) before the addEventHandler. Link to comment
Xwad Posted January 30, 2016 Author Share Posted January 30, 2016 same. not working:( Link to comment
Xwad Posted January 30, 2016 Author Share Posted January 30, 2016 What could be the problem?? Link to comment
Tails Posted January 30, 2016 Share Posted January 30, 2016 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
KariiiM Posted January 30, 2016 Share Posted January 30, 2016 Show a full code because the problem is on onClientRender event the error says ,this event is already handled Link to comment
Xwad Posted January 30, 2016 Author Share Posted January 30, 2016 Hi now its working! I dont dont how, i didnt do anythink.. Thanks to all answers! 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