Raised This Month: $51 Target: $400
 12% 

my very first simple plugin.


Post New Thread Reply   
 
Thread Tools Display Modes
Blunted1
Senior Member
Join Date: Jun 2004
Old 08-21-2004 , 20:11  
Reply With Quote #11

Quote:
Originally Posted by Peli
Yea , whenever you use and if statement and your going to do some code in their , like maybe getting the cvar num , and setting a hud message , you need to use { and }.
Not true. You do NOT always need brackets for an if/else statement, only if you have multiple lines/commands that should be affected.

Code:
public test() {     if(amx_testmode > 0)     client_print(1,print_center,"This is -Snort- Leader's First Plugin")     else     console_print(0,"%s is not set to 0", "amx_testmode")     return PLUGIN_HANDLED       }

Especially so without the else,

Code:
public test() {     if(amx_testmode > 0)          client_print(1,print_center,"This is -Snort- Leader's First Plugin")     console_print(0,"%s is not set to 0", "amx_testmode")     return PLUGIN_HANDLED       }

in this code, if amx_testmode is greater than zero then it will print "This is -Snort- Leader's First Plugin", however, regardless of wether it is or is not greater than zero it will still always print the second message in console.

Regardless, I still highly recommend useing brackets anyways (even if it is only for a single line and not multiple commands)
Blunted1 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 12:19.


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