Slim. Posted March 14, 2012 Share Posted March 14, 2012 Er, so. I want to make my own custom crosshair. I've managed to disappear the default crosshair. but now, i need to add my own. My concept is to make a red dot display in right CENTER of the screen. The red dot will be a Dxline (or call it a dot ) So, i need help with 2 things. : 1. How can i make it appear always? like, i don't need the crosshair only when we aim, i want it to be their everytime. 2. What are the co ordinates of the Center of the screen? (0,0) ? Thanks in Advance. ~Slim Link to comment
Gr0x Posted March 14, 2012 Share Posted March 14, 2012 1, use onClientRender() 2, sX,sY = guiGetScreenSize() Absolute center: sX-sX/2, sY-sY/2 Relative center: 0.5,0.5 (if i know good) Link to comment
Slim. Posted March 14, 2012 Author Share Posted March 14, 2012 Erm, Thanks for the position, but i really didnt get why in Render needed here. Link to comment
Absence2 Posted March 14, 2012 Share Posted March 14, 2012 Slim. said: Erm, Thanks for the position, but i really didnt get why in Render needed here. OnClientRender keeps it visible example: dxDrawText Link to comment
Slim. Posted March 14, 2012 Author Share Posted March 14, 2012 Oh, so you mean, the DxdrawText comes under onClientRender() ? Link to comment
Absence2 Posted March 14, 2012 Share Posted March 14, 2012 Slim. said: Oh, so you mean, the DxdrawText comes under onClientRender() ? no I mean, onClientRender keeps dxDrawText visible, so whatever you're drawing, use onClientRender like this within the main function/eventhandler function createText ( ) -- add your code here function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. end addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) Link to comment
Slim. Posted March 14, 2012 Author Share Posted March 14, 2012 Thank you very much, i appreciate your help Link to comment
denny199 Posted March 14, 2012 Share Posted March 14, 2012 Idjot said: Slim. said: Oh, so you mean, the DxdrawText comes under onClientRender() ? no I mean, onClientRender keeps dxDrawText visible, so whatever you're drawing, use onClientRender like this within the main function/eventhandler function createText ( ) -- add your code here function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. end addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) ... function createText ( ) -- add your code here -- ur forgot a END end function TheRendering ( ) addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. end addEventHandler ( "onClientResourceStart", resourceRoot, TheRendering ) and if u wanna stop rendering function stopTheRendering ( ) removeEventHandler ( "onClientRender", root, createText ) --now removing the eventhandler end addCommandHamdler ( "stoprender", stopTheRendering ) Link to comment
Absence2 Posted March 14, 2012 Share Posted March 14, 2012 denny, I just copied the Wiki's example as he didn't understand my first post and deleted it's mid content. I didn't read thru it at all. and function createText ( ) -- add your code here -- ur forgot a END end function TheRendering ( ) addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. end addEventHandler ( "onClientResourceStart", resourceRoot, TheRendering ) --and if u wanna stop rendering function stopTheRendering ( ) removeEventHandler ( "onClientRender", root, createText ) --now removing the eventhandler end addCommandHamdler ( "stoprender", stopTheRendering ) Link to comment
denny199 Posted March 14, 2012 Share Posted March 14, 2012 i only forgot -- ... let's stop the fight Link to comment
Castillo Posted March 14, 2012 Share Posted March 14, 2012 function createText ( ) -- add your code here end function TheRendering ( ) addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. end addEventHandler ( "onClientResourceStart", resourceRoot, TheRendering ) --And if you want to stop rendering. function stopTheRendering ( ) removeEventHandler ( "onClientRender", root, createText ) --now removing the eventhandler end addCommandHandler ( "stoprender", stopTheRendering ) -- You had 'addCommandHamdler', that's wrong. 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