AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] If statements (https://forums.alliedmods.net/showthread.php?t=277145)

Depresie 01-03-2016 12:34

[HELP] If statements
 
Okay, so, im getting a little confused lately with a particular case of if statements, more exactly the following, i know what "!" means, but i cant process it in this sittuation..
can anyone explain it to me please?

PHP Code:


if(!user_is_arab(id) || !user_is_belgian(id))
{
        do 
this
}

if(!
user_is_arab && !user_is_belgian(id))
{
        do 
this



wickedd 01-03-2016 12:36

Re: [HELP] If statements
 
PHP Code:

if(!user_is_arab(id) Or !user_is_belgian(id)) 

PHP Code:

if(!user_is_arab(id) And !user_is_belgian(id)) 

|| = Or

&& = And


Hope this helps

Depresie 01-03-2016 12:41

Re: [HELP] If statements
 
i know that.. here is what i need...

how do i write these two examples into one?

PHP Code:

if(!is_user_arab(id))
{
         
1
}

if(!
is_user_belgian(id))
{
          
1



wickedd 01-03-2016 12:51

Re: [HELP] If statements
 
PHP Code:

if(!user_is_arab(id) || !user_is_belgian(id))
{
        


Use this one if only 1 of them needs to be true
PHP Code:

if(!user_is_arab && !user_is_belgian(id))
{
        


Use this one if both of them needs to be true

Depending on what you want to do both of them is correct.

Depresie 01-03-2016 13:23

Re: [HELP] If statements
 
as in the first case, if any of that is true, i dont want it executed further
i just digged in my pc and found an older test server and managed a quick test with client prints, and it resulted that your second code is what i wanted

sorry for the idiot question, im scripting without testing, i have pc problems...

siriusmd99 01-03-2016 13:39

Re: [HELP] If statements
 
How how can be arab and belgian at the same time?? Oh.. Anyway, use this:

if(user_is_arab(id) || user_is_belgian(id) && (!user_is_arab(id) || !user_is_belgian(id)))

This means that action will be executed only if he's not both belgian and arab.

This means that

fysiks 01-03-2016 14:38

Re: [HELP] If statements
 
Testing your own code is a critical part of learning. I highly recommend that you always test your code before asking a question on the forums.

Depresie 01-03-2016 15:49

Re: [HELP] If statements
 
@sirius, well, you can have double nationality, also it was just an example
im sorry, i didnt explain well, i wanted the following written differently with !

PHP Code:

public function(id)
{
if(
is_user_belgian(id) || is_user_arab(id))
{
         return;
}
do 
this


@fysiks, i usualy do, but now i cant, my windows is realy messed up... anti virus went crazy.. sorry

addons_zz 01-03-2016 18:14

Re: [HELP] If statements
 
Quote:

Originally Posted by Depresie (Post 2379605)
my windows is realy messed up... anti virus went crazy.. sorry

Just do not use anti virus, except the computer's user, which is best anti virus ever.

Depresie 01-03-2016 21:07

Re: [HELP] If statements
 
too late bro... xD


All times are GMT -4. The time now is 09:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.