SA-MP Forums Archive
Kinda useless question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: Kinda useless question (/showthread.php?tid=222975)



Kinda useless question - Mean - 08.02.2011

Why do some scripters put ALOT of spaces in their code? xD, I always wanted to know that!


Re: Kinda useless question - Finn - 08.02.2011

What do you mean?


Re: Kinda useless question - weedarr - 08.02.2011

Its called indentation and it makes the code easier to read and it looks better.


Re: Kinda useless question - Mean - 08.02.2011

Quote:
Originally Posted by Finn
Посмотреть сообщение
What do you mean?
Some people do like this:
pawn Код:
if ( sscanf ( params, "u", id ) )
    return SendClientMessage ( playerid, 0xAAAAAA, "Message" );
That's what I wanted to ask, why so much spaces? It makes the line LONG, and you can get error for "input line too long" if you do a long line...
I prefer no un-needed spaces like this:
pawn Код:
if(sscanf(params, "u", id))
    return SendClientMessage(playerid, 0xAAAAAA, "Message");



Re: Kinda useless question - Donny_k - 08.02.2011

It's easy to read, looks neater to me also, I format my code always like that when I'm writing a samp script. When I write something for c# or c++ (visual IDE) I don't as it formats for me but when writing some code in an editor which doesn't auto format then it will look like that.

It's just a style like indentation, everyone has thier own, like you put spaces between your parameters.


Re: Kinda useless question - DeathOnaStick - 08.02.2011

Quote:
Originally Posted by Donny_k
Посмотреть сообщение
It's easy to read, looks neater to me also, I format my code always like that when I'm writing a samp script. When I write something for c# or c++ (visual IDE) I don't as it formats for me but when writing some code in an editor which doesn't auto format then it will look like that.

It's just a style like indentation, everyone has thier own, like you put spaces between your parameters.
That's 100% my opinion. It's just the same thing with the brackets

pawn Код:
if(ble==1){
...
}
and
pawn Код:
if(ble==2)
{
...
}
does not matter which you use, but everyone uses his own style. I like the version with less spaces and the bracket directly behind the if-statement, which is the most common way of scripting, i guess, due to the fact, that it is the fastest one (which i know), although I began with putting the bracket into a new line, which makes it harder for me to now switch over to the, in my opinion better style.


Re: Kinda useless question - mamorunl - 08.02.2011

I much rather have the second one. I then have a good overview of the brackets and can see if I am missing one (open or close resp)


Re: Kinda useless question - Hal - 09.02.2011

Quote:
Originally Posted by mamorunl
Посмотреть сообщение
I much rather have the second one. I then have a good overview of the brackets and can see if I am missing one (open or close resp)
Yea i like it more for the readability. And since i do that much indentation, i do not count lines. I do not believe more lines = a good script. Neither does less lines = a good script


Re: Kinda useless question - ev0lution - 09.02.2011

I'm definitely someone who likes to compact code as much as possible.
Usually it's just more convenient for me, as I hardly ever use the mouse, so using arrow keys when I need to fix something becomes a pain when you're going past 800 spaces in one line.


Re: Kinda useless question - Mean - 09.02.2011

Well, abt the brackets, I put them in a new line, it's easier to find a missing bracket then.
Compare this
pawn Код:
public Something(sthing) {
    for(new i; i < MAX_PLAYERS; i++) {
        DoSomethin
    }
    return true;
}
It's easier to find a missing bracket like this:
pawn Код:
public Something(sthing)
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        DoSomethin
    }
    return true;
}
Isn't it?

Abt the spaces, I might start scripting with spaces. LoL!