Raised This Month: $ Target: $400
 0% 

admin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alphad
Senior Member
Join Date: Jun 2014
Old 07-17-2014 , 03:37   admin
Reply With Quote #1

PHP Code:
if ( !is_user_aliveid ) || cs_get_user_teamid ) != CS_TEAM_CT || get_user_flagsid ) & ADMIN_BAN 
Why is this not working?
Alphad is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-17-2014 , 03:53   Re: admin
Reply With Quote #2

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.
__________________

Last edited by Flick3rR; 07-17-2014 at 03:54.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-17-2014 , 06:03   Re: admin
Reply With Quote #3

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 ).
HamletEagle is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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