JeViCo Posted March 25, 2018 Share Posted March 25, 2018 Hello everyone! I have some code below(open a dx window on marker hit): function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function dx_() col_1 = 255, 255, 255, 190 col_2 = 255, 255, 255, 255 ret_1 = 0,0,0,190 ret_2 = 0,0,0,255 if not info and not give then if isMouseInPosition( 329, 336, 387, 87 ) then bt_1 = col_2 else bt_1 = col_1 end outputChatBox("Done!") dxDrawImage(201, 279, 512, 208, "button.png", 0, 0, 0, tocolor(0, 0, 0, 255), false) dxDrawImage(207, 278, 512, 208, "button.png", 0, 0, 0, tocolor(bt_1), false) dxDrawText("Some text", 388, 348, 696, 402, tocolor(0, 0, 0, 255), 1.40, "pricedown", "center", "center", false, false, false, false, false) end end This part of code outputs in chat "Done!" so it work, however images and text are not drawing. Any ideas? Link to comment
Captain Cody Posted March 25, 2018 Share Posted March 25, 2018 Make sure it is linked to an onClientRender event. Link to comment
JeViCo Posted March 25, 2018 Author Share Posted March 25, 2018 (edited) 25 minutes ago, CodyJ(L) said: Make sure it is linked to an onClientRender event. Thank you for reply! I have already done it. I can see my output text in chat function window() if not veh then if not wind then addEventHandler("onClientRender",getRootElement(),dx_) wind = true showCursor (true) elseif wind then removeEventHandler("onClientRender",getRootElement(),dx_) wind = false showCursor(false) end end end addEvent("open_w", true) addEventHandler("open_w", root, window ) maybe something wrong in addEventHandler? Edited March 25, 2018 by Juuve Link to comment
Captain Cody Posted March 25, 2018 Share Posted March 25, 2018 Looks just fine Run this function dx_() col_1 = 255, 255, 255, 190 col_2 = 255, 255, 255, 255 ret_1 = 0,0,0,190 ret_2 = 0,0,0,255 if not info and not give then print(math.random(0,1000)) if isMouseInPosition( 329, 336, 387, 87 ) then bt_1 = col_2 else bt_1 = col_1 end outputChatBox("Done!") dxDrawImage(201, 279, 512, 208, "button.png", 0, 0, 0, tocolor(0, 0, 0, 255), false) dxDrawImage(207, 278, 512, 208, "button.png", 0, 0, 0, tocolor(bt_1), false) dxDrawText("Some text", 388, 348, 696, 402, tocolor(0, 0, 0, 255), 1.40, "pricedown", "center", "center", false, false, false, false, false) end end And see if multiple numbers are outputted in chat box. Link to comment
JeViCo Posted March 26, 2018 Author Share Posted March 26, 2018 (edited) 10 hours ago, CodyJ(L) said: Looks just fine Run this function dx_() col_1 = 255, 255, 255, 190 col_2 = 255, 255, 255, 255 ret_1 = 0,0,0,190 ret_2 = 0,0,0,255 if not info and not give then print(math.random(0,1000)) if isMouseInPosition( 329, 336, 387, 87 ) then bt_1 = col_2 else bt_1 = col_1 end outputChatBox("Done!") dxDrawImage(201, 279, 512, 208, "button.png", 0, 0, 0, tocolor(0, 0, 0, 255), false) dxDrawImage(207, 278, 512, 208, "button.png", 0, 0, 0, tocolor(bt_1), false) dxDrawText("Some text", 388, 348, 696, 402, tocolor(0, 0, 0, 255), 1.40, "pricedown", "center", "center", false, false, false, false, false) end end And see if multiple numbers are outputted in chat box. evething works perfectly with the exception of words starting with dxDraw... if not info and not give | - works print | - works everywhere outputChatBox | - works too Your code also works. Maybe i should divede all render into pieces Edited March 26, 2018 by Juuve Link to comment
JeViCo Posted March 26, 2018 Author Share Posted March 26, 2018 i fixed it somehow. I pasted all conditions below this outputChatBox("Done!") dxDrawImage(201, 279, 512, 208, "button.png", 0, 0, 0, tocolor(0, 0, 0, 255), false) dxDrawImage(207, 278, 512, 208, "button.png", 0, 0, 0, tocolor(bt_1), false) dxDrawText("Some text", 388, 348, 696, 402, tocolor(0, 0, 0, 255), 1.40, "pricedown", "center", "center", false, false, false, false, false) and it works. I don't even understand why Link to comment
Discord Moderators Pirulax Posted March 28, 2018 Discord Moderators Share Posted March 28, 2018 You should use the local sx, sy = guiGetScreenSize() function, otherwise it will only work for you, and others with the same screensize. Link to comment
myonlake Posted April 7, 2018 Share Posted April 7, 2018 (edited) The reason why it doesn't work is because you are essentially passing 1 integer value to the tocolor function, hence printing out a black image. You need to either pass in all RGBA values as their own variables, or use tocolor in the variable value itself like so: function dx_() -- You were passing only the first 255 to col_1 col_1 = tocolor(255, 255, 255, 190) -- You were passing only the first 255 to col_2 col_2 = tocolor(255, 255, 255, 255) -- You were passing only the first 0 to ret_1 ret_1 = tocolor(0, 0, 0, 190) -- You were passing only the first 0 to ret_2 ret_2 = tocolor(0, 0, 0, 255) if not info and not give then if isMouseInPosition(329, 336, 387, 87) then bt_1 = col_2 else bt_1 = col_1 end dxDrawImage(201, 279, 512, 208, "button.png", 0, 0, 0, tocolor(0, 0, 0, 255)) dxDrawImage(207, 278, 512, 208, "button.png", 0, 0, 0, bt_1) -- Use bt_1 as a converted color value now dxDrawText("Some text", 388, 348, 696, 402, tocolor(0, 0, 0, 255), 1.4, "pricedown", "center", "center") end end If you wanted to pass them as their own variables then it would be like the following: -- Put them in variables col_1_r, col_1_g, col_1_b, col_1_a = 255, 255, 255, 190 -- Now to use tocolor you'd pass them in separately col_1 = tocolor(col_1_r, col_1_g, col_1_b, col_1_a) Edited April 7, 2018 by myonlake 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