long GM - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: long GM (
/showthread.php?tid=327745)
long GM -
Bleach79 - 22.03.2012
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!!
Re: long GM -
Bleach79 - 22.03.2012
pls anyone??
Re: long GM -
Reklez - 22.03.2012
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
Re: long GM -
Rob_Maate - 22.03.2012
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)
Re: long GM -
Babul - 22.03.2012
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
Re: long GM -
Spooky - 22.03.2012
The best thing is use the link on my signature, formatted gamemode.