HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Copyright 2015 Safety1st
  2.  
  3. 'Money as Frag Counter' is free software;
  4. you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18.  
  19. #include <amxmodx>
  20. #include <fakemeta>
  21. #include <hamsandwich>
  22.  
  23. #define PLUGIN "Money as Frag Counter"
  24. #define VERSION "0.1"
  25. #define AUTHOR "Safety1st"
  26.  
  27. const PDATA_SAFE = 2
  28. const m_iHideHUD = 361
  29. const m_iClientHideHUD = 362
  30. const HIDEHUD_MONEY = 1<<5
  31.  
  32. const MAX_CLIENTS = 32
  33. new giFrags[MAX_CLIENTS + 1]
  34.  
  35. new giMsgMoney
  36.  
  37. public plugin_init() {
  38. register_plugin( PLUGIN, VERSION, AUTHOR )
  39.  
  40. giMsgMoney = get_user_msgid( "Money" )
  41.  
  42. set_msg_block( giMsgMoney, BLOCK_SET )
  43.  
  44. register_event( "DeathMsg", "Event_DeathMessage", "a", "1!0" ) // killed by a player ('1')
  45.  
  46. RegisterHam( Ham_Spawn, "player", "OnCBasePlayer_Spawn_Post", .Post = 1 )
  47. }
  48.  
  49. public client_putinserver(id) {
  50. giFrags[id] = 0
  51.  
  52. // to hide money from client's HUD when entering to a game
  53. if( pev_valid(id) == PDATA_SAFE )
  54. // must have check for bots, for safety for players
  55. set_pdata_int( id, m_iHideHUD, get_pdata_int( id, m_iHideHUD ) | HIDEHUD_MONEY )
  56. }
  57.  
  58. public OnCBasePlayer_Spawn_Post(id) {
  59. if( is_user_alive(id) )
  60. SendMoneyMsg( id, giFrags[id] = 0, .flag = 0 )
  61. }
  62.  
  63. public Event_DeathMessage() {
  64. const KillerID = 1
  65. const VictimID = 2
  66.  
  67. new iKiller = read_data(KillerID)
  68. new iVictim = read_data(VictimID)
  69.  
  70. if( iKiller != iVictim /* except suicides; BTW death due to amx_slay is a suicide too */ )
  71. SendMoneyMsg( iKiller, ++giFrags[iKiller], .flag = 1 )
  72. }
  73.  
  74. stock SendMoneyMsg( player, money, flag ) {
  75. // if 'flag' = 1 then display the additional new-old amount difference
  76.  
  77. message_begin( MSG_ONE_UNRELIABLE, giMsgMoney, _, player )
  78. write_long(money)
  79. write_byte(flag)
  80. message_end()
  81. }