SA-MP Forums Archive
multiple functions in one "if" line - 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: multiple functions in one "if" line (/showthread.php?tid=476446)



multiple functions in one "if" line - Voxel - 18.11.2013

Hello,

i was wondering if it would be possible to do something like this:
pawn Код:
if(User[playerid][USER_EXP] == 0) return User[playerid][USER_RANK] = 0 (PlayerTextDrawTextSize(playerid, expb[playerid], 222.761901, 0.000000)(UpdateTextDraw(playerid));
but how do i do this properly?
or must it be:
pawn Код:
if(User[playerid][USER_EXP] == 0)
{
    User[playerid][USER_RANK] = 0;
    PlayerTextDrawTextSize(playerid, expb[playerid], 222.761901, 0.000000);
    UpdateTextDraw(playerid); //i have this forwarded (it hides and shows the exp bar to update it)
    return 1;
}
The reason i am asking is because if the first way can be done it will be shorter code.


Respuesta: multiple functions in one "if" line - adri1 - 18.11.2013

pawn Код:
if(User[playerid][USER_EXP] == 0) return PlayerTextDrawTextSize(playerid,expb[playerid], 222.761901, 0.000000), UpdateTextDraw(playerid), User[playerid][USER_RANK] = 0;



Re: multiple functions in one "if" line - Voxel - 18.11.2013

thanks man!


Re: multiple functions in one "if" line - Vince - 18.11.2013

Shorter code does not always equal better code. For the sake of clarity I'd still write the compound block instead of resorting to commas.