AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   admin (https://forums.alliedmods.net/showthread.php?t=244349)

Alphad 07-17-2014 03:37

admin
 
PHP Code:

if ( !is_user_aliveid ) || cs_get_user_teamid ) != CS_TEAM_CT || get_user_flagsid ) & ADMIN_BAN 

Why is this not working?

Flick3rR 07-17-2014 03:53

Re: admin
 
Well, if you tell us what should it do. I can't see anything wrong with the check, probably you don't know it's right purpose. This chekcs if the player is alive OR if his team isn't CT OR if he has ban access. Maybe you want all these conditions to be true at the same time. If so, you will have to replace || operators with &&. Simply explained in this case, || means that it is enough one of the conditions to be true, and && means that they all have to be true, so the function will be executed.

HamletEagle 07-17-2014 06:03

Re: admin
 
Here is how your if will think:

1. Let's translate it:
PHP Code:

if ( !is_user_aliveid ) ||   cs_get_user_teamid ) != CS_TEAM_CT ||  get_user_flagsid ) &ADMIN_BAN 

If ( user is dead ) OR ( he is not in the ct team ) OR ( he has acces to ban ) do something.

2. Let's see what we will receive: think that first and the second condition are false and the last one true ( or whatever you want ).

PHP Code:

false OR false OR true true 

If at last one of this conditons is true it will go to next step ( the one from { } ).

If we cange it to && ( mean AND ):

PHP Code:

if ( !is_user_aliveid ) && cs_get_user_teamid ) != CS_TEAM_CT  && get_user_flagsid ) & ADMIN_BAN 

If ( user is dead ) AND ( he is not in ct team ) AND ( he has acces to ban ) do something.
Now, think that just one is false. We will receive :

PHP Code:

true && true && false false 

If at last one of this conditions is false it won't do the instruction from { } and will probably go to the else ( if it's there ).


All times are GMT -4. The time now is 13:11.

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