MAB Posted July 27, 2015 Share Posted July 27, 2015 attempt to call global "isMouseInPosition" ( a nil value ) at line 22.. what to do?! sx,sy = guiGetScreenSize() x,y = (sx/1280),(sy/768) function add (player) addEventHandler( "onClientRender", root, edit ) addEventHandler ( "onClientClick", root, join ) end marker = createMarker ( -2187.50439, 708.30951, 52.89063, "cylinder", 1.5, 255, 255, 255, 255 ) createBlipAttachedTo ( marker, 56 ) addEventHandler ( "onClientMarkerHit", marker, add ) function edit () showCursor(true,true) dxDrawRectangle(x*391, y*99, x*526, y*470, tocolor(0, 0, 0, 100), false) dxDrawRectangle(x*393, y*150, x*524, y*4, tocolor(255, 255, 255, 255), false) dxDrawRectangle(x*391, y*512, x*524, y*4, tocolor(255, 255, 255, 255), false) dxDrawText("Counter Strike", x*532, y*106, x*755, y*150, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Join", x*450, y*522, x*564, y*552, color, 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Close", x*756, y*522, x*870, y*552, color2, 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Counter Strike is an event that was meant\n as a mini game. \n In this event you will be in a team of two\n teams and there will be players with you in\n the same team and others in the other team.\n You and your team mates must eliminate all\n the other team players to win.\n All the winner team members will be given\n rewards.", 402, 163, 907, 506, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) if ( isMouseInPosition ( 450, 522, 564, 552 ) ) then color = 255,255,0,255 else color = 255,255,255,255 end if ( isMouseInPosition ( 450, 522, 870, 552 ) ) then color2 = 255,255,0,255 else color2 = 255,255,255,255 end end function join (button,state) if ( isMouseInPosition ( 450, 522, 870, 552 ) ) then if ( button == "left" and state == "up" ) then showCursor(false) removeEventHandler("onClientRender", player, edit) end end end Link to comment
GTX Posted July 27, 2015 Share Posted July 27, 2015 You need isMouseInPosition function. function isMouseInPosition(a, b, c, d) if not isCursorShowing() then return end local x, y = getCursorPosition() x, y = x*sx, y*sy if x >= a and y >= b and x <= a+c and y <= b+d then return true end return false end Link to comment
MAB Posted July 27, 2015 Author Share Posted July 27, 2015 didn't understand that can you please give me an example with numbers?! Link to comment
Buffalo Posted July 27, 2015 Share Posted July 27, 2015 Copy given code into your script. sx,sy = guiGetScreenSize() x,y = (sx/1280),(sy/768) function add (player) addEventHandler( "onClientRender", root, edit ) addEventHandler ( "onClientClick", root, join ) end marker = createMarker ( -2187.50439, 708.30951, 52.89063, "cylinder", 1.5, 255, 255, 255, 255 ) createBlipAttachedTo ( marker, 56 ) addEventHandler ( "onClientMarkerHit", marker, add ) function edit () showCursor(true,true) dxDrawRectangle(x*391, y*99, x*526, y*470, tocolor(0, 0, 0, 100), false) dxDrawRectangle(x*393, y*150, x*524, y*4, tocolor(255, 255, 255, 255), false) dxDrawRectangle(x*391, y*512, x*524, y*4, tocolor(255, 255, 255, 255), false) dxDrawText("Counter Strike", x*532, y*106, x*755, y*150, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Join", x*450, y*522, x*564, y*552, color, 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Close", x*756, y*522, x*870, y*552, color2, 1.30, "pricedown", "left", "top", false, false, false, false, false) dxDrawText("Counter Strike is an event that was meant\n as a mini game. \n In this event you will be in a team of two\n teams and there will be players with you in\n the same team and others in the other team.\n You and your team mates must eliminate all\n the other team players to win.\n All the winner team members will be given\n rewards.", 402, 163, 907, 506, tocolor(255, 255, 255, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) if ( isMouseInPosition ( 450, 522, 564, 552 ) ) then color = 255,255,0,255 else color = 255,255,255,255 end if ( isMouseInPosition ( 450, 522, 870, 552 ) ) then color2 = 255,255,0,255 else color2 = 255,255,255,255 end end function join (button,state) if ( isMouseInPosition ( 450, 522, 870, 552 ) ) then if ( button == "left" and state == "up" ) then showCursor(false) removeEventHandler("onClientRender", player, edit) end end end function isMouseInPosition(a, b, c, d) if not isCursorShowing() then return end local x, y = getCursorPosition() x, y = x*sx, y*sy if x >= a and y >= b and x <= a+c and y <= b+d then return true end return false end 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