04.04.2012, 15:44
I know this entirely depends on the coder's personal preference, but I'm just going to note this down as a small suggestion for you.
Instead of doing:
You can easily do:
When I got introduced to commands back in 2007, I wasn't really familiar with scripting or programming, so I couldn't even think some more readability could be introduced. I remember having a really heavy scope-in-scope structure :P
Instead of doing:
pawn Код:
if(Player[playerid][pAdmin] >= 1)
{
new string[128], carid, carcolor1, carcolor2;
if(!sscanf(params, "iii", carid, carcolor1, carcolor2))
{
if(carid >= 400 && carid <= 611)
{
if(carcolor2 >= 0 && carcolor2 <= 252)
{
// ...
}
else return SendClientMessage(playerid, COLOR_RED, "Неверный ID цвета!Используйте числа от 0 до 252.");
}
else return SendClientMessage(playerid, COLOR_RED, "Неверный ID транспорта!Используйте от 400 до 611.");
}
else return SendClientMessage(playerid, COLOR_GREEN, "Используйте: /car [ID] [цвет 1][цвет 2].");
}
pawn Код:
if(Player[playerid][pAdmin] == 0)
return SendClientMessage(playerid, COLOR_RED, "У Вас недостаточно высокий уровень,для использования этой команды!");
new carid, carcolor1, carcolor2;
if(sscanf(params, "iii", carid, carcolor1, carcolor2))
return SendClientMessage(playerid, COLOR_GREEN, "Используйте: /car [ID] [цвет 1][цвет 2].");
if(!(400 <= carid <= 611)) // this is the same as if(carid < 400 || carid > 600)!
return SendClientMessage(playerid, COLOR_RED, "Неверный ID транспорта!Используйте от 400 до 611.");
if(!(0 <= carcolor1 <= 252) || !(0 <= carcolor2 <= 252))
return SendClientMessage(playerid, COLOR_RED, "Неверный ID цвета!Используйте числа от 0 до 252.");
// Now rest of the code
return true;