Jump to content

Make My Code , Short


Max+

Recommended Posts

Posted

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 ,

Posted

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.

Posted

i dont know about sql and i dont want to use it at all ,

i want like i posted above tables, if you know about tabel please show me ,

Posted

Google "lua tables" and "lua for loop". Read about how they work, and then try it yourself. There's no better way of learning than by trial and error.

Posted

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 

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...