Question
#1

In the case of this function, or any other like it:
Код:
if(!IsPlayerConnected(userid))
What does the ! in it do?
Reply
#2

if(!IsPlayerConnected(userid)) - would be if player isn't connected.
Reply
#3

! means the word "not", or can be compared to the English word "opposite". Let's say you have a boolean that is true. If you do ! in front of it it means it's false:

Код:
bool x = true;

while(!x) //while x is not true, aka while x is false
{
}
Basically will turn anything into the opposite:
Код:
int x;
if(!(x < 10)) //means the opposite of if x is smaller than 10, = x is bigger than 10

if(x != 10) //if x is not 10
//or
if(!(x == 10)) //would do the same thing but != is much easier to write
Reply
#4

The "!" indicates the oppositional value of that function, in this case if the statement is 1, it will check the opposite (0).

Hansrutger explained it perfectly.
Reply
#5

Thanks for all of the responses guys, really cleared it up for me. Thanks again!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)