long GM
#1

i have a very long Gamemode. can anybody give me tips to reduce the size and make it more beautiful for reading

thnxx 4 de helpp!!
Reply
#2

pls anyone??
Reply
#3

one tip if your code is something like this

pawn Код:
if(TestVariable[playerid][Testing] == 1)
{
     if(IsPlayerConnected(playerid))
     {
           //codes
     }
}
else
{
    //codes
}
just do

pawn Код:
if(TestVariable[playerid][Testing] == 1) {
      if(IsPlayerConnected(playerd)) {
      //codes
      }
} else {
     //codes
}
this will make your long codes shorter. it defends if you add many efforts in your code
Reply
#4

To be honest, length isn't a problem.
Spacing out your work makes it not only easier to read, but easier also to maintain.
Locating problems in a switch such as this:

pawn Код:
switch(MyVar)
{
    case 1:
    {
        //Action
    }

    case 2:
    {
        //Action
    }

    case 3:
    {
        //Action
    }
}
is much easier than trying to locate the same problem in this:

pawn Код:
switch(MyVar) { case 1: { /*Action*/ } case 2: { /*Action*/ } case 3: { /*Action*/ } }
Also, by spreading out your code, you allow yourself the opportunity to add comments at each stage of your script. This may seem like nothing, but a few months down the track, it's almost essential to consistent scripting (knowing what you meant by various chunks of code and what you were trying to achieve)
Reply
#5

to make it easier for reading, you can use an editor capable of "code collapsing":

not bad: 6000 lines's code in about 30 lines, easy to open some certain callbacks for editing hehe
Reply
#6

The best thing is use the link on my signature, formatted gamemode.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)