Raizel Posted June 22, 2023 Share Posted June 22, 2023 hello, im trying to make the panel pop up by command. the open function works but the close function doesnt work. loadstring(exports.dgs:dgsImportFunction())() local IsOn = false local sW, sH = dgsGetScreenSize() function OpenClosePhone() if IsOn == false then addEventHandler("onClientRender", getRootElement(), phone1) elseif IsOn == true then removeEventHandler("onClientRender", getRootElement(), phone1) end end bindKey("n", "down", OpenClosePhone) function phone1() if IsOn == false then -- components rrn = dgsCreateRoundRect(30,false, tocolor(0,0,0,255)) phone = dgsCreateImage( sW * 0.7, sH * 0.5, sW * 0.20, sH * 0.50, rrn, false) app_texture1 = dxCreateTexture("ohnoe.jpg") app1 = dgsCreateRoundRect(30,false, tocolor(255,255,255,255)) app = dgsCreateImage( sW * 0.750, sH * 0.650, sW * 0.10, sH * 0.15, app1, false) app_button = dgsCreateButton( sW * 0.750, sH * 0.650, sW * 0.10, sH * 0.15, "", false, _, tocolor(0,0,0,0) ) dgsRoundRectSetTexture(app1, app_texture1) dgsSetLayer (app_button,"top") dgsSetAlpha(app_button, 0) IsOn = true addEventHandler ( "onDgsMouseClickDown", app_button, app1Func ) -- animations end end function app1Func () outputChatBox("hey") end idk how to fix it, please help me Link to comment
Moderators Vinyard Posted June 22, 2023 Moderators Share Posted June 22, 2023 Moving this to the scripting section. 1 Link to comment
_SAXI_ Posted June 22, 2023 Share Posted June 22, 2023 The creation components in DGS are not to be used by the "onClientRender" event. If you want to remove the components you must use the destroyElement function 1 Link to comment
Raizel Posted June 23, 2023 Author Share Posted June 23, 2023 17 hours ago, _SAXI_ said: The creation components in DGS are not to be used by the "onClientRender" event. If you want to remove the components you must use the destroyElement function how do i make it be able to open and close anytime i want to? because rn when i close it i cant open it again Link to comment
βurak Posted June 23, 2023 Share Posted June 23, 2023 (edited) loadstring(exports.dgs:dgsImportFunction())() local IsOn = false local sW, sH = dgsGetScreenSize() function doPhone() if(IsOn) then return end rrn = dgsCreateRoundRect(30,false, tocolor(0,0,0,255)) phone = dgsCreateImage( sW * 0.7, sH * 0.5, sW * 0.20, sH * 0.50, rrn, false) app_texture1 = dxCreateTexture("ohnoe.jpg") app1 = dgsCreateRoundRect(30,false, tocolor(255,255,255,255)) app = dgsCreateImage( sW * 0.750, sH * 0.650, sW * 0.10, sH * 0.15, app1, false) app_button = dgsCreateButton( sW * 0.750, sH * 0.650, sW * 0.10, sH * 0.15, "", false, _, tocolor(0,0,0,0) ) dgsRoundRectSetTexture(app1, app_texture1) dgsSetLayer (app_button,"top") dgsSetAlpha(app_button, 0) addEventHandler("onDgsMouseClickDown", app_button, app1Func) IsOn = true -- animations end function removePhone() if(not IsOn) then return end removeEventHandler("onDgsMouseClickDown", app_button, app1Func) destroyElement(rrn) destroyElement(phone) destroyElement(app_texture1) destroyElement(app1) destroyElement(app) destroyElement(app_button) IsOn = false end function togglePhone() if(IsOn) then removePhone() else doPhone() end end bindKey("n", "down", togglePhone) function app1Func() outputChatBox("hey") end I didn't test it but can you try this Edited June 23, 2023 by Burak5312 1 Link to comment
Raizel Posted June 23, 2023 Author Share Posted June 23, 2023 57 minutes ago, Burak5312 said: loadstring(exports.dgs:dgsImportFunction())() local IsOn = false local sW, sH = dgsGetScreenSize() function doPhone() if(IsOn) then return end rrn = dgsCreateRoundRect(30,false, tocolor(0,0,0,255)) phone = dgsCreateImage( sW * 0.7, sH * 0.5, sW * 0.20, sH * 0.50, rrn, false) app_texture1 = dxCreateTexture("ohnoe.jpg") app1 = dgsCreateRoundRect(30,false, tocolor(255,255,255,255)) app = dgsCreateImage( sW * 0.750, sH * 0.650, sW * 0.10, sH * 0.15, app1, false) app_button = dgsCreateButton( sW * 0.750, sH * 0.650, sW * 0.10, sH * 0.15, "", false, _, tocolor(0,0,0,0) ) dgsRoundRectSetTexture(app1, app_texture1) dgsSetLayer (app_button,"top") dgsSetAlpha(app_button, 0) addEventHandler("onDgsMouseClickDown", app_button, app1Func) IsOn = true -- animations end function removePhone() if(not IsOn) then return end removeEventHandler("onDgsMouseClickDown", app_button, app1Func) destroyElement(rrn) destroyElement(phone) destroyElement(app_texture1) destroyElement(app1) destroyElement(app) destroyElement(app_button) IsOn = false end function togglePhone() if(IsOn) then removePhone() else doPhone() end end bindKey("n", "down", togglePhone) function app1Func() outputChatBox("hey") end I didn't test it but can you try this thank you, it works perfectly 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