Jump to content

Make My Code , Short


Max+

Recommended Posts

Hello , i made a gameMode , it has a lot of buttons , labels , dxdraw

What iam Asking about is , can i make a tabel , to improt them and loop the table and it will automaticly make the buttons and labels and dxdraw ,

same thing with events

can i make a table have like 3 events , and each event will do something ,

because my gameMode has like 120 lines of codes ,

Link to comment

120 isn't BAD, but if you want it shorter you could externally store buttons and whatnot into SQLite, removing them staticly and replacing them dynamically reduces lines of code A LOT.

Find more efficient code, efficient code usually decreases the amount of lines used to write the code.

You can do a lot to reduce coding.

Link to comment

ex :

local table = {  
  labels = { 100, 100, 100, 100, 200, 200, 200, 200 }, 
  buttons = { 300, 300, 300, 300, 500, 500, 500, 500 }, 
  ["onClientResourceStart"] = { function1, function2 }, 
} 
  
CreateLabels = guiCreateLabel( table[1][1], table[1][2], table[1][3], table[1][4] ) 
for i = 1, #table["onClientResourceStart"] do 
    addEventHandler( "onClientResourceStart", resourceRoot, table["onClientResourceStart"][i] ) 
end 
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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