Raised This Month: $ Target: $400
 0% 

Constant in if statements?


Post New Thread Reply   
 
Thread Tools Display Modes
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 08-04-2011 , 16:10   Re: Constant in if statements?
Reply With Quote #11

doesnt should be 'stock bool:' or isnt required?
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 08-04-2011 , 16:48   Re: Constant in if statements?
Reply With Quote #12

Quote:
Originally Posted by lucas_7_94 View Post
doesnt should be 'stock bool:' or isnt required?
true = 1
false = 0
__________________
Hi.
Kreation is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-04-2011 , 17:12   Re: Constant in if statements?
Reply With Quote #13

Quote:
Originally Posted by lucas_7_94 View Post
doesnt should be 'stock bool:' or isnt required?
Fixed.

Quote:
Originally Posted by Kreation View Post
true = 1
false = 0
true = bool:1
false = bool:0
__________________
fysiks is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 08-04-2011 , 18:16   Re: Constant in if statements?
Reply With Quote #14

Ah ok , thanks for the info , really i think i was wrong!
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-04-2011 , 18:57   Re: Constant in if statements?
Reply With Quote #15

Quote:
Originally Posted by lucas_7_94 View Post
Ah ok , thanks for the info , really i think i was wrong!
You were correct.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-04-2011 , 20:29   Re: Constant in if statements?
Reply With Quote #16

The "should it be stock" part of your post isn't necessarily correct. You should only declare a variable or function as stock if you are not 100% sure that the function/variable will be used somewhere in your code. If an item declared as stock isn't used in code then it does not get compiled into the binary (.amxx). This is why include files contain stocks since a person may use only one function in an include file containing hundreds of functions. It would be wasteful to compile a lot of code that is never used.

Declaring like this or as public would be more proper.
PHP Code:
boolnum_is_in_array()
{


__________________

Last edited by Bugsy; 08-04-2011 at 20:41.
Bugsy is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 08-04-2011 , 20:38   Re: Constant in if statements?
Reply With Quote #17

Quote:
Originally Posted by Bugsy View Post
The "should it be stock" part of your post isn't necessarily correct. You should only declare a variable or function as stock if you are not 100% sure that the function/variable will be used somewhere in your code. If an item declared as stock isn't used in code then it does not get compiled into the binary (.amxx). This is why include files contain stocks since a person may use only one function in an include file containing hundreds of functions. It would be wasteful to compile a lot of code that is never used.

Declaring like this or as public would be more proper.
PHP Code:
boolnum_is_in_array()
{


thanks bugsy for the explain !.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-04-2011 , 22:57   Re: Constant in if statements?
Reply With Quote #18

I use stock often when I create functions. Why? Because when I debug I need to be able to compile without errors.
__________________
fysiks is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 08-04-2011 , 23:01   Re: Constant in if statements?
Reply With Quote #19

right, there is no critical standard to tag a function to stock or public. and Bugsy just well explained to others what the difference between them.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 08-05-2011 , 05:12   Re: Constant in if statements?
Reply With Quote #20

I use public only when needed ( when the function/variable is called from somewhere else than the specific plugin ) and stock only in include files ( few exceptions ). I disagree with Fysiks at least in large plugins and rather use pragma unused because this way I can keep a list of the functions. With stock you would probably find couple of three-year-old never used functions in your latest release.
SnoW is offline
Send a message via MSN to SnoW
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 10:50.


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