Thread: Heart Health
View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-18-2016 , 23:36   Re: Heart Health
Reply With Quote #24

I took a quick look and found the below items that should be addressed:
  1. Define gHealthEntity[] as a constant. You do this for the string defined above this but not for this one.
  2. gTimes[] does not need to be defined with a value of 0.0, this happens automatically. You only need this if you want a default value other than 0.
  3. In cmd_lives_reset(), you do not need to use get_players() and a for-loop to set all values in the array to 0. Just use arrayset().
  4. In hh_hook(), you should store the value of get_pcvar_num( CVS[HEALTH_LIMIT] ) in a variable. You should never call a get_[p]cvar_() native more than once for the same cvar in a function.
  5. This is more of a preference thing, but try to be consistent with your bracketing. If you have an if-else and you bracket the code in the if{}, you should also do it for the else{} code. Again, not required but IMO it looks nicer.
  6. In respawn_hook(), same issue with cvar CVS[RESPAWN_LIVES] as in #4. above. Store the value in a variable.
  7. You should move plugin_precache() and plugin_end() closer to plugin_init(). It's more organized keeping these plugin-oriented functions together.
  8. In client_authorized() and client_disconnect(), you can reduce the size of szData[] since a 10 digit number will likely never happen. 3 or 4 will probably be more than enough. In client_authorized(), you are better off using nvault_get() since this returns an integer. You can then eliminate the szData[11] and iTs variables and do not have to use str_to_num().
  9. You should define a max-players value and use that to size player arrays (#DEFINE MAX_PLAYERS 32) then do gArray[ MAX_PLAYERS + 1 ]) You define gLives at 33 and then gAuthId at 35 when they should be the same.
__________________

Last edited by Bugsy; 12-18-2016 at 23:41.
Bugsy is offline