Braces - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Braces (
/showthread.php?tid=73978)
Braces -
StrickenKid - 19.04.2009
Are braces needed in all if statements and or will it cause problems to not have them?
hears an example where i don't use braces:
pawn Код:
if(PlayerToPlayer(i, CurrentPresident(), 50))
SetPlayerWantedLevel(i, 1);
else if(PlayerToPlayer(i, CurrentPresident(), 40))
SetPlayerWantedLevel(i, 2);
else if(PlayerToPlayer(i, CurrentPresident(), 30))
SetPlayerWantedLevel(i, 3);
else if(PlayerToPlayer(i, CurrentPresident(), 20))
SetPlayerWantedLevel(i, 4);
else if(PlayerToPlayer(i, CurrentPresident(), 10))
SetPlayerWantedLevel(i, 5);
else
SetPlayerWantedLevel(i, 0);
Re: Braces -
Redirect Left - 19.04.2009
I don't use braces, and they work fine for me.
Re: Braces -
Rks25 - 19.04.2009
This should work fine though.
Re: Braces -
Danut - 19.04.2009
The braces are used when there are more than 1 function.
If you use 1 function , you can use or not Braces ( same thing )
e.g.
pawn Код:
if(PlayerLevel[playerid] > 1) return SendClientMessage(playerid,COLOR_WHITE,"ETC");
it's equal with:
pawn Код:
if(PlayerLevel[playerid] > 1) { return SendClientMessage(playerid,COLOR_WHITE,"ETC"); }
************************************************** ***************************
If you use 2 functions ore more , you must use the Braces, or you'll get errors.
e.g.
pawn Код:
if(PlayerLevel[playerid] > 1)
{
Kick(playerid);
return SendClientMessage(playerid,COLOR_WHITE,"ETC");
}