SA-MP Forums Archive
Little question (about "if") - 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: Little question (about "if") (/showthread.php?tid=159954)



Little question (about "if") - MrDeath537 - 15.07.2010

Hi guys, my questions is the next:
When you use ">>", "?", ":", or "<<", in "if", what that will do?


Example:

MidoStream:
pawn Код:
public MoveTimer(id2,xadd,yadd,zadd,bool:xisbigger,bool:yisbigger,bool:zisbigger)
{
    new bool:reached = false;
    reached = xisbigger ? ((Objects[id2][xpos] >= Objects[id2][movx]) ? true : false) : ((Objects[id2][xpos] <= Objects[id2][movx]) ? true : false);
    if (reached)
    {
        reached = yisbigger ? ((Objects[id2][ypos] >= Objects[id2][movy]) ? true : false) : ((Objects[id2][ypos] <= Objects[id2][movy]) ? true : false);
        if (reached)
        {
            reached = zisbigger ? ((Objects[id2][zpos] >= Objects[id2][movz]) ? true : false) : ((Objects[id2][zpos] <= Objects[id2][movz]) ? true : false);
        }
    }

Thanks, and sorry for my bad english :\


Re: Little question (about "if") - bigcomfycouch - 15.07.2010

? and : are used in conjunction with each other. They're an if-else statement.
pawn Код:
IsAZero(a = 1) return a == 0 ? 1 : 0;
is the same as
pawn Код:
IsAZero(a = 1)
{
    if(a == 0) return 1;
    else return 0;
}
>> and << are bitwise shift operators

http://en.wikipedia.org/wiki/Bitwise_operation