Little question (about "if")
#1

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 :\
Reply
#2

? 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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)