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)