Jump to content

Another question lol


Recommended Posts

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)

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)

addEventHandler("onClientGUIClick", root,function()
 if ( source == close) then
           removeEventHandler("onClientPreRender", getRootElement(), drawmypistol);
           removeEventHandler("onClientPreRender", getRootElement(), welcome);
           removeEventHandler("onClientPreRender", getRootElement(), draw);
            guiSetVisible(close, false)
   end )  
Link to comment

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.

Link to comment
  • IIYAMA locked this topic
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...