What's new

C/C++ While, and Logical NOT

  • Thread starter DatBoiJay53
  • Start date
  • Views 195
D

DatBoiJay53

Enthusiast
Messages
634
Reaction score
120
Why on earth is there a "while" and logical "NOT" operator in this piece of code??
1. I thought "while" were for loops?
2. And the "!" were for true and false?

Code:
REQUEST_MODEL(MODEL_ORACLE);
                            while (!HAS_MODEL_LOADED(MODEL_ORACLE));
                            CREATE_CAR(0x506434F6,0.0,0.0,5.0,&pveh,true);
                            ATTACH_CAR_TO_OBJECT(&pveh,otmp, 0, 0, 0, 0, 0, 0,0);
                        }
                    return;
 
X

Xeren

♦♦♦ God Complex ♦♦♦
Premium
Messages
5,671
Reaction score
2,119
Why on earth is there a "while" and logical "NOT" operator in this piece of code??
1. I thought "while" were for loops?
2. And the "!" were for true and false?

Code:
REQUEST_MODEL(MODEL_ORACLE);
                            while (!HAS_MODEL_LOADED(MODEL_ORACLE));
                            CREATE_CAR(0x506434F6,0.0,0.0,5.0,&pveh,true);
                            ATTACH_CAR_TO_OBJECT(&pveh,otmp, 0, 0, 0, 0, 0, 0,0);
                        }
                    return;

Since the while loop is closed, that means while the oracle has not been loaded(! means opposite), don't do anything. So when it is loaded, then the code would generate a car.
 
D

DatBoiJay53

Enthusiast
Messages
634
Reaction score
120
Since the while loop is closed, that means while the oracle has not been loaded(! means opposite), don't do anything. So when it is loaded, then the code would generate a car.
What do you mean closed? Because of this?
while (!HAS_MODEL_LOADED(MODEL_ORACLE))->;<-

And ok, sooo like, while (has this model not loaded yet??(MODEL_ORACLE));
CREATE_CAR.........
 
X

Xeren

♦♦♦ God Complex ♦♦♦
Premium
Messages
5,671
Reaction score
2,119
What do you mean closed? Because of this?
while (!HAS_MODEL_LOADED(MODEL_ORACLE))->;<-

And ok, sooo like, while (has this model not loaded yet??(MODEL_ORACLE));
CREATE_CAR.........

Yes for the first part, since there are no braces. For the second part, take this for example:
Code:
bool someVal = false;
someVal = !someVal; //make someVal equal to the opposite of someVal
//now someVal = true
 
D

DatBoiJay53

Enthusiast
Messages
634
Reaction score
120
Yes for the first part, since there are no braces. For the second part, take this for example:
Code:
bool someVal = false;
someVal = !someVal; //make someVal equal to the opposite of someVal
//now someVal = true
Ok, 1 more question. In the native.h it says "REQUEST_MODEL(uint model);"
i put "REQUEST_MODEL(MODEL_ORACLE);"
but ive seen other coders put the hash code instead of the uint model. why? because for other native functions it says put the hash. For example...
CREATE_CAR(uint nameHash.
why did the other coder put the hash instead of the uint model?
 
X

Xeren

♦♦♦ God Complex ♦♦♦
Premium
Messages
5,671
Reaction score
2,119
Ok, 1 more question. In the native.h it says "REQUEST_MODEL(uint model);"
i put "REQUEST_MODEL(MODEL_ORACLE);"
but ive seen other coders put the hash code instead of the uint model. why? because for other native functions it says put the hash. For example...
CREATE_CAR(uint nameHash.
why did the other coder put the hash instead of the uint model?

By hash code, you mean hex, such as 0x125689AB? That's because MODEL_ORACLE is just a variable name for a uint, or hash code as you put it.
Code:
uint TEST_ORACLE = 0x33;
int main()
{
    int a;
    int b;
    a = doNothing(TEST_ORACLE);
    b = doNothing(0x33);
    //both a and b are the same(0x34) after the program finishes
}
 
int addOne(uint number)
{
    return 1 + number;
}
Why he put it is just personal preference.
 
Top Bottom