jingzhi Posted April 19, 2015 Share Posted April 19, 2015 I am trying to make a custom cursor: function drawCursor(status) if status == true then showCursor(true) setCursorAlpha(0) Rx,Ry = guiGetScreenSize() addEventHandler("onClientPreRender",root, function() local cursorX,cursorY = getCursorPosition() posX = math.floor(cursorX * Rx) posY = math.floor(cursorY * Ry) dxDrawImage(posX,posY,32,32,"cursor.png",_,_,_,_,true) end) elseif status == false then removeEventHandler("onClientPreRender",root, function() local cursorX,cursorY = getCursorPosition() posX = math.floor(cursorX * Rx) posY = math.floor(cursorY * Ry) dxDrawImage(posX,posY,32,32,"cursor.png",_,_,_,_,true) end) showCursor(false) end end It works, but there is some bug: 1. The cursor is always behind the all the GUI 2. After I hide the cursor using removeEventHandler, it keeps showing error every frame: attempt to perform arithmetic on local "cursorX" (a boolean value) which i think means the removeEventHandler didn't stop the arithmetic action, and I don't know why Please help if you know the problem, thank you very much! Link to comment
WhoAmI Posted April 19, 2015 Share Posted April 19, 2015 (edited) Rx,Ry = guiGetScreenSize ( ); function renderCursor ( ) local cursorX,cursorY = getCursorPosition( ) posX = math.floor(cursorX * Rx) posY = math.floor(cursorY * Ry) dxDrawImage(posX,posY,32,32,"cursor.png",0,0,0,tocolor(255,255,255,255),true) end function drawCursor(status) if status then showCursor(true) setCursorAlpha(0) addEventHandler("onClientPreRender",root,renderCursor) else removeEventHandler("onClientPreRender",root,renderCursor) showCursor(false) end end Edited April 19, 2015 by Guest Link to comment
Enargy, Posted April 19, 2015 Share Posted April 19, 2015 Rx,Ry = guiGetScreenSize ( ); function renderCursor ( ) local cursorX,cursorY = getCursorPosition( ) posX = math.floor(cursorX * Rx) posY = math.floor(cursorY * Ry) dxDrawImage(posX,posY,32,32,"cursor.png",0,0,0,tocolor(255,255,255,255),true) end function drawCursor(status) if status then showCursor(true) setCursorAlpha(0) addEventHandler("onClientPreRender",root,renderCursor) else then removeEventHandler("onClientPreRender",root,renderCursor) showCursor(false) end end You wrote 'then' at line 15. 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