Bean666 Posted January 30, 2021 Posted January 30, 2021 Hi, its me again lol i want to make a non-messy code, how do I make all DX disappear in just one line, like i dont have to put 2 removeEventHandlers or more just to remove each one of them on one click. i only want 1 removeEventHandler for all of them to disappear instead of adding 1 by one, how to do that? function welcome() dxDrawText("Welcome to the Weapon Shop, please choose a category", (930/1920)*sx, (424/1080)*sy, (1254/1920)*sx, (452/1080)*sy, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) end function drawpistol() dxDrawImage((879/1920)*sx, (328/1080)*sy, (162/1920)*sx, (142/1080)*sy, ":guieditor/images/colt45icon.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage((997/1920)*sx, (556/1080)*sy, (157/1920)*sx, (144/1080)*sy, ":guieditor/images/desert_eagleicon.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage((1120/1920)*sx, (330/1080)*sy, (160/1920)*sx, (140/1080)*sy, ":guieditor/images/silencedicon.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end addEventHandler("onClientGUIClick", root,function() if ( source == close) then removeEventHandler("onClientPreRender", getRootElement(), drawmypistol); removeEventHandler("onClientPreRender", getRootElement(), welcome); removeEventHandler("onClientPreRender", getRootElement(), draw); guiSetVisible(close, false) showCursor(false) end end )
SpecT Posted January 30, 2021 Posted January 30, 2021 If they are supposed to run at the same time you can merge the functions into one then you will need only one add/removeEventHandler. And also your idea of non-messy code and at the same time all the stuff done in one lane are kinda opposite things (in my opinion). Your main goal should be to optimize your code as good as possible not to make it "beautiful" lol.
Moderators IIYAMA Posted January 30, 2021 Moderators Posted January 30, 2021 Locked, this post has a double. That one is unlocked.
Recommended Posts