SA-MP Forums Archive
Question - 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: Question (/showthread.php?tid=486497)



Question - K9IsGodly - 09.01.2014

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


Re: Question - xser12 - 09.01.2014

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


Re: Question - Hansrutger - 09.01.2014

! 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



Re: Question - Emmet_ - 09.01.2014

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.


Re: Question - K9IsGodly - 09.01.2014

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