Drakath Posted February 4, 2014 Posted February 4, 2014 So, I'm making a Speedometer script and I keep getting this error: "addEventHandler: 'onClientRender' with this function is already handled" function speed ( ) addEventHandler ( "onClientRender", root, draw ) end addEventHandler ("onClientVehicleEnter", root, speed) function hideSpeed ( ) removeEventHandler ( "onClientRender", root, draw ) end addEventHandler("onClientVehicleExit", root, hideSpeed) function draw ( ) --this is where I have dxdraw stuff. end
TAPL Posted February 4, 2014 Posted February 4, 2014 function speed (player) if player == localPlayer then addEventHandler ( "onClientRender", root, draw ) end end addEventHandler ("onClientVehicleEnter", root, speed) function hideSpeed (player) if player == localPlayer then removeEventHandler ( "onClientRender", root, draw ) end end addEventHandler("onClientVehicleExit", root, hideSpeed) function draw ( ) --this is where I have dxdraw stuff. end
K4stic Posted February 4, 2014 Posted February 4, 2014 why can't do it easyer? :3 function draw() if ( isPedInVehicle ( localPlayer ) == false ) then return end --this is where I have dxdraw stuff. end addEventHandler ( "onClientRender", root, draw )
Moderators IIYAMA Posted February 4, 2014 Moderators Posted February 4, 2014 why can't do it easyer? :3 function draw() if ( isPedInVehicle ( localPlayer ) == false ) then return end --this is where I have dxdraw stuff. end addEventHandler ( "onClientRender", root, draw ) Simply because it uses more memory. The easy way isn't always the best way. Even so, his version can get bugged, while yours can't. So the best result will be: onVehicleEnter + render check if he is in the vehicle else remove the handler. A combination would be the best.
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