SA-MP Forums Archive
difference between.... - 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: difference between.... (/showthread.php?tid=239207)



difference between.... - b.rock - 13.03.2011

Quote:

if(IsPlayerConnected(playerid)) GivePlayerMoney(playerid,100);

and

Quote:

if(IsPlayerConnected(playerid))
{
GivePlayerMoney(playerid,100);
}

whats the difference??


Re: difference between.... - Tommy_Mandaz - 13.03.2011

First one wont work the other one will

The
Код:
{
after the
Код:
if(IsPlayerConnected(playerid))
Tells the if statement what to do... So without it, you get nothing.


Re: difference between.... - b.rock - 13.03.2011

stock IsPlayerAdminLevel(playerid, level)
{

new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
new file[256], tmp, tmp2;

format(file,256,"/ladmin/users/%s.sav",udb_encode(name));
tmp = dini_Int(file,"level");
tmp2 = dini_Int(file,"loggedin");

if( (IsPlayerConnected(playerid)) && (tmp >= level) && (tmp2 != 0) )
return true;
else return false;


}

this function is from ladmin and see the line bold
it doesn't have "{","}" and works well


Re: difference between.... - Tommy_Mandaz - 13.03.2011

Wow no idea... Maybe I got it all wrong...


Re: difference between.... - JamesC - 13.03.2011

Quote:
Originally Posted by Tommy_Mandaz
Посмотреть сообщение
Wow no idea... Maybe I got it all wrong...
Yes, indeed you did.

Parenthesis are meant to be used when you have more than one instruction after a conditional statement.

The example in bold works fine because there is only one instruction, either return true or false.