RandomRambo Posted September 6, 2022 Share Posted September 6, 2022 (edited) I asked for help to hide button and @#\_oskar_/# helped me,thanks but now I need that this image with buttons doesn't show before I pressed "K" because at this moment it shows even if someone connected to server (it shows when player connected and he should press "K" to hide it). function AttachDxToGuiElement( GUIElement , img ) if ( guiGetVisible ( GUIElement ) ) then local x, y = guiGetPosition ( GUIElement , false ) local width , Height = guiGetSize ( GUIElement , false ) dxDrawImage(x, y, width , Height ,img, 0, 0, 0,SetImagecolor or tocolor(255, 0, 0, 255), true) dxDrawText(guiGetText ( GUIElement ) or tostring '',x, y, width + x , Height + y,SetTextcolor or tocolor(55,55,55,255),1,"default-bold","center","center",false,false,true) guiBringToFront ( GUIElement ) guiSetAlpha ( GUIElement , 0) end end ------------------ event = guiCreateButton(16, 20, 250, 40, "Take", false) addEventHandler ("onClientRender", root, function () AttachDxToGuiElement( event ,'img/event.png' ) end) bindKey( "k", "down",function( ) guiSetVisible( event , not guiGetVisible( event )) showCursor( guiGetVisible( event )) end ) Help please.I tried everything I know but it didn't help. Edited September 9, 2022 by Vinyard added the solved tag Link to comment
AngelAlpha Posted September 7, 2022 Share Posted September 7, 2022 17 hours ago, RandomRambo said: I asked for help to hide button and @#\_oskar_/# helped me,thanks but now I need that this image with buttons doesn't show before I pressed "K" because at this moment it shows even if someone connected to server (it shows when player connected and he should press "K" to hide it). function AttachDxToGuiElement( GUIElement , img ) if ( guiGetVisible ( GUIElement ) ) then local x, y = guiGetPosition ( GUIElement , false ) local width , Height = guiGetSize ( GUIElement , false ) dxDrawImage(x, y, width , Height ,img, 0, 0, 0,SetImagecolor or tocolor(255, 0, 0, 255), true) dxDrawText(guiGetText ( GUIElement ) or tostring '',x, y, width + x , Height + y,SetTextcolor or tocolor(55,55,55,255),1,"default-bold","center","center",false,false,true) guiBringToFront ( GUIElement ) guiSetAlpha ( GUIElement , 0) end end ------------------ event = guiCreateButton(16, 20, 250, 40, "Take", false) addEventHandler ("onClientRender", root, function () AttachDxToGuiElement( event ,'img/event.png' ) end) bindKey( "k", "down",function( ) guiSetVisible( event , not guiGetVisible( event )) showCursor( guiGetVisible( event )) end ) Help please.I tried everything I know but it didn't help. function AttachDxToGuiElement( GUIElement , img ) if ( guiGetVisible ( GUIElement ) ) then local x, y = guiGetPosition ( GUIElement , false ) local width , Height = guiGetSize ( GUIElement , false ) dxDrawImage(x, y, width , Height ,img, 0, 0, 0,SetImagecolor or tocolor(255, 0, 0, 255), true) dxDrawText(guiGetText ( GUIElement ) or tostring '',x, y, width + x , Height + y,SetTextcolor or tocolor(55,55,55,255),1,"default-bold","center","center",false,false,true) guiBringToFront ( GUIElement ) guiSetAlpha ( GUIElement , 0) end end ------------------ event = guiCreateButton(16, 20, 250, 40, "Take", false) guiSetVisible (event, false) addEventHandler ("onClientRender", root, function () AttachDxToGuiElement( event ,'img/event.png' ) end) bindKey( "k", "down",function( ) guiSetVisible( event , not guiGetVisible( event )) showCursor( guiGetVisible( event )) end ) 1 Link to comment
RandomRambo Posted September 8, 2022 Author Share Posted September 8, 2022 (edited) 16 hours ago, AngelAlpha said: function AttachDxToGuiElement( GUIElement , img ) if ( guiGetVisible ( GUIElement ) ) then local x, y = guiGetPosition ( GUIElement , false ) local width , Height = guiGetSize ( GUIElement , false ) dxDrawImage(x, y, width , Height ,img, 0, 0, 0,SetImagecolor or tocolor(255, 0, 0, 255), true) dxDrawText(guiGetText ( GUIElement ) or tostring '',x, y, width + x , Height + y,SetTextcolor or tocolor(55,55,55,255),1,"default-bold","center","center",false,false,true) guiBringToFront ( GUIElement ) guiSetAlpha ( GUIElement , 0) end end ------------------ event = guiCreateButton(16, 20, 250, 40, "Take", false) guiSetVisible (event, false) addEventHandler ("onClientRender", root, function () AttachDxToGuiElement( event ,'img/event.png' ) end) bindKey( "k", "down",function( ) guiSetVisible( event , not guiGetVisible( event )) showCursor( guiGetVisible( event )) end ) wow,thanks And one more question.How I can do if player hit the marker this image and buttons will show to him ("K" button should be removed then) I tried to do smth like that: (server side) marker1 = createMarker(2094.8940429688,-838.72570800781,52.3, "corona", 1.5, 230, 251, 3, 153) function event(player) triggerClientEvent (hitPlayer,"openWindow",getRootElement(),hitPlayer) end addEventHandler("onMarkerHit", root, event) And added function openWindow in client side but it didn't work Edited September 8, 2022 by RandomRambo Link to comment
AngelAlpha Posted September 8, 2022 Share Posted September 8, 2022 2 hours ago, RandomRambo said: wow,thanks And one more question.How I can do if player hit the marker this image and buttons will show to him ("K" button should be removed then) I tried to do smth like that: (server side) marker1 = createMarker(2094.8940429688,-838.72570800781,52.3, "corona", 1.5, 230, 251, 3, 153) function event(player) triggerClientEvent (hitPlayer,"openWindow",getRootElement(),hitPlayer) end addEventHandler("onMarkerHit", root, event) And added function openWindow in client side but it didn't work marker1 = createMarker(2094.8940429688,-838.72570800781,52.3, "corona", 1.5, 230, 251, 3, 153) function event(el) if getElementType(el) ~= "player" then return end triggerClientEvent (el,"openWindow",getRootElement(),el) end addEventHandler("onMarkerHit", resourceRoot, event) 1 Link to comment
RandomRambo Posted September 8, 2022 Author Share Posted September 8, 2022 4 hours ago, AngelAlpha said: marker1 = createMarker(2094.8940429688,-838.72570800781,52.3, "corona", 1.5, 230, 251, 3, 153) function event(el) if getElementType(el) ~= "player" then return end triggerClientEvent (el,"openWindow",getRootElement(),el) end addEventHandler("onMarkerHit", resourceRoot, event) thank u very much,but can u write a client side?xd Link to comment
AngelAlpha Posted September 8, 2022 Share Posted September 8, 2022 9 hours ago, RandomRambo said: thank u very much,but can u write a client side?xd marker1 = createMarker(2094.8940429688,-838.72570800781,52.3, "corona", 1.5, 230, 251, 3, 153) function event(el) if getElementType(el) ~= "player" then return end if el ~= localPlayer then return end -- function open a window end addEventHandler("onClientMarkerHit", resourceRoot, event) 1 Link to comment
#\_oskar_/# Posted September 8, 2022 Share Posted September 8, 2022 data,_add = { },addEventHandler function SColor(e,r,g,b) if getElementType(e) == 'gui-button' then guiSetProperty(e, 'NormalTextColour', string.format("%.2X%.2X%.2X%.2X",r,g,b,255)) end end dxDrawImage_ = dxDrawImage local dxDrawImage = function (...) local a = {...} if isElement( a[1] ) and getElementType( a[1] ) == 'gui-button' and guiGetVisible (a[1]) then data [ a[1] ] = true local posX, posY = guiGetPosition ( a[1] , false ) local width , Height = guiGetSize ( a[1] , false ) dxDrawImage_ (posX , posY, width,Height,a[2], a[3],a[4],a[5], a[6] , a[7]) local r, g, b = getColorFromString("#"..guiGetProperty(a[1], "NormalTextColour")) dxDrawText(guiGetText ( a[1] ) or tostring '',posX, posY, width + posX , Height + posY,SetTextcolor or tocolor(r, g, b,255),1,"default-bold","center","center",false,false,true) guiSetAlpha( a[1] , 0) end if not isElement( a[1] ) then return dxDrawImage_ (...) end end local function Enter() if data [ source ] == true then SColor(source,0 ,255, 0) end end local function Leave() if data [ source ] == true then SColor(source,255, 124,124) end end _add ( "onClientMouseEnter",resourceRoot,Enter) _add ( "onClientGUIMouseUp", resourceRoot,Enter) _add ( "onClientMouseLeave",resourceRoot,Leave) _add ( "onClientGUIMouseDown",resourceRoot,Leave) -----------------\\\\\\\\\\\\\\\\\\\\----------------- event = guiCreateButton(16, 20, 250, 40, "Take", false) guiSetVisible (event, false) addEventHandler ("onClientRender", root, function () dxDrawImage(event ,'img/event.png', 0, 0, 0,tocolor(255, 255, 255, 255), true) -- attach to Button -- dxDrawImage(160, 200, 250, 40 ,'img/event.png', 0, 0, 0,tocolor(255, 255, 255, 255), true) -- dx Image end) bindKey( "k", "down",function( ) guiSetVisible( event , not guiGetVisible( event )) showCursor( guiGetVisible( event )) end ) try this 1 Link to comment
RandomRambo Posted September 9, 2022 Author Share Posted September 9, 2022 3 hours ago, #\_oskar_/# said: data,_add = { },addEventHandler function SColor(e,r,g,b) if getElementType(e) == 'gui-button' then guiSetProperty(e, 'NormalTextColour', string.format("%.2X%.2X%.2X%.2X",r,g,b,255)) end end dxDrawImage_ = dxDrawImage local dxDrawImage = function (...) local a = {...} if isElement( a[1] ) and getElementType( a[1] ) == 'gui-button' and guiGetVisible (a[1]) then data [ a[1] ] = true local posX, posY = guiGetPosition ( a[1] , false ) local width , Height = guiGetSize ( a[1] , false ) dxDrawImage_ (posX , posY, width,Height,a[2], a[3],a[4],a[5], a[6] , a[7]) local r, g, b = getColorFromString("#"..guiGetProperty(a[1], "NormalTextColour")) dxDrawText(guiGetText ( a[1] ) or tostring '',posX, posY, width + posX , Height + posY,SetTextcolor or tocolor(r, g, b,255),1,"default-bold","center","center",false,false,true) guiSetAlpha( a[1] , 0) end if not isElement( a[1] ) then return dxDrawImage_ (...) end end local function Enter() if data [ source ] == true then SColor(source,0 ,255, 0) end end local function Leave() if data [ source ] == true then SColor(source,255, 124,124) end end _add ( "onClientMouseEnter",resourceRoot,Enter) _add ( "onClientGUIMouseUp", resourceRoot,Enter) _add ( "onClientMouseLeave",resourceRoot,Leave) _add ( "onClientGUIMouseDown",resourceRoot,Leave) -----------------\\\\\\\\\\\\\\\\\\\\----------------- event = guiCreateButton(16, 20, 250, 40, "Take", false) guiSetVisible (event, false) addEventHandler ("onClientRender", root, function () dxDrawImage(event ,'img/event.png', 0, 0, 0,tocolor(255, 255, 255, 255), true) -- attach to Button -- dxDrawImage(160, 200, 250, 40 ,'img/event.png', 0, 0, 0,tocolor(255, 255, 255, 255), true) -- dx Image end) bindKey( "k", "down",function( ) guiSetVisible( event , not guiGetVisible( event )) showCursor( guiGetVisible( event )) end ) try this thanks but @AngelAlpha already solved my question Link to comment
Moderators Vinyard Posted September 9, 2022 Moderators Share Posted September 9, 2022 Locking this due to the issue being solved. Link to comment
Recommended Posts