Code - 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: Code (
/showthread.php?tid=601084)
Code -
Day_Jons - 16.02.2016
What distinguishes this code
For example:
Код:
new test1;
new test2;
new qwerty[100];
public OnPlayerSpawn(playerid)
{
if(playerid == 0)
{
SetPlayerPos(....);
SetFacingAngle(....);
SetPlayerInterior(.....);
SetPlayerVirtualWorld(....);
if(...)
{
SendClientMessage(....);
return 1;
}
return 1;
}
else
{
SetPlayerPos(....);
SetFacingAngle(....);
SetPlayerInterior(.....);
SetPlayerVirtualWorld(....);
if(...)
{
SendClientMessage(....);
return 1;
}
return 1;
}
}
From this:
Код:
new test[2], qwerty[100];
public OnPlayerSpawn(playerid)
{
if(playerid == 0)
{
SetPlayerPos(....);
SetFacingAngle(....);
SetPlayerInterior(.....);
SetPlayerVirtualWorld(....);
if(...)
{
SendClientMessage(....);
}
}
else
{
SetPlayerPos(....);
SetFacingAngle(....);
SetPlayerInterior(.....);
SetPlayerVirtualWorld(....);
if(...)
{
SendClientMessage(....);
}
}
return 1;
}
Does the first example of what a burden or something like that?
Re: Code -
Riddy - 16.02.2016
The second one is more readable than the first one, PAWN isn't a language which cares about how much whitespace is in the file but the main point would be that it's readable and doesn't look stupid in this case. Indentation is a good way to help distinguish what is what in the piece of code and well makes it easier to read, and well it looks more clean..