Raised This Month: $ Target: $400
 0% 

Writing good code, solving problems.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
nosoop
Veteran Member
Join Date: Aug 2014
Old 07-17-2019 , 06:08   Re: Writing good code, solving problems.
Reply With Quote #7

Code:
PrintToChat(iClient, "Yay, you're in the %sTerrorist team!", iTeam == 3 ? "Counter-" : "");
That is perfectly fine up until you want localizations (check out the Russian localization of team names on CS:GO), or different phrases depending on the team. At the very least I'd rather keep the entire team name in the third parameter to avoid these sorts of phrase concatenations.

Additionally, Menu_Top_Menu_Handler is in poor form -- the third parameter is not always going to be a client index, per the MenuAction documentation. You've gated off MenuAction_End, where the parameter in question is the MenuEnd reason, and so you're now always leaking handles (because the values that you think are clients are either 0 or negative). That said, I'd also take that approach to simplifying the query setup.

As far as clear code goes, I'm a fan of "Avoid Else, Return Early" to keep indentation to a minimum, but that's mostly a matter of opinion and not a strict style to adhere to.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 07-17-2019 at 08:50.
nosoop is offline
 



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 23:31.


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