Raised This Month: $ Target: $400
 0% 

General Question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-05-2012 , 21:30   General Question
Reply With Quote #1

Hi guys,

I always wondered:

When I have something like this:

PHP Code:
if(g_Mode && cs_get_user_team(i)) { ... } 
When g_Mode isnt True, will this scirpt continue with cs_get_user_team(), or will it just skip it?

So: Is it bether to do:
PHP Code:
if(g_Mode && cs_get_user_team(i)) { ... } 
or
PHP Code:
if(g_Mode)
{
   if(
cs_get_user_team(i))
   { ... }

__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 05-05-2012 , 23:12   Re: General Question
Reply With Quote #2

you try to filtre "is user spectated or unassigned team"?
cs_get_user_team return team index
if teamindex>0 then it will be true
__________________
The functional way is the right way

Last edited by GordonFreeman (RU); 05-05-2012 at 23:13.
GordonFreeman (RU) is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-06-2012 , 02:18   Re: General Question
Reply With Quote #3

I asked this before and IIRC, execution does not continue across an AND if the first condition is false. You could try to find my post and see what the answer was for sure.

You could even test it. Change "i" to an invalid player and run the code with g_mode = 0. If you get an error then it does execute, if no error then it doesn't execute.

Quote:
Originally Posted by GordonFreeman (RU) View Post
you try to filtre "is user spectated or unassigned team"?
cs_get_user_team return team index
if teamindex>0 then it will be true
Nothing you said has anything to do with his question.
__________________
fysiks is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 05-06-2012 , 04:49   Re: General Question
Reply With Quote #4

(Operation1 && Operation2) | True && False = Does Not pass
(Operation1 && Operation2) | False && True = Does Not Pass
(Operation1 && Operation2) | False && False = Does Not Pass
(Operation1 && Operation2) | True && True = Pass.

(Operation1 || Operation2) | True || False = Pass
(Operation1 || Operation2) | False || True = Pass
(Operation1 || Operation2) | False || False = Does Not Pass
(Operation1 || Operation2) | True || True = Pass.
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-06-2012 , 05:13   Re: General Question
Reply With Quote #5

Quote:
Originally Posted by ProIcons View Post
(Operation1 && Operation2) | True && False = Does Not pass
(Operation1 && Operation2) | False && True = Does Not Pass
(Operation1 && Operation2) | False && False = Does Not Pass
(Operation1 && Operation2) | True && True = Pass.

(Operation1 || Operation2) | True || False = Pass
(Operation1 || Operation2) | False || True = Pass
(Operation1 || Operation2) | False || False = Does Not Pass
(Operation1 || Operation2) | True || True = Pass.
It is not his question.

Fysiks is right, on a && check, if 1st check is false, other ones are not checked, on a || check, if 1st condition is true, other ones are not checked.
That's why it's better to put fast checks (vars checks) before checks that imply natives calls or lot of compute.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-06-2012 , 12:21   Re: General Question
Reply With Quote #6

Thank you fysiks and Connor

Btw: The Post fysiks was talking about: http://forums.alliedmods.net/showthread.php?t=85522
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers

Last edited by mottzi; 05-06-2012 at 12:28.
mottzi is offline
Send a message via MSN to mottzi
Reply


Thread Tools
Display Modes

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 00:24.


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