Advertisement
wopox3

TOP Awards Safety1st

Oct 22nd, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.96 KB | None | 0 0
  1. /**
  2. *   Simple plugin to award first TOP players in stats by bonus flags
  3. *     Players already having all bonus flags or having IGNORE_FLAG (disabled by default) are ignored.
  4. *     An awarded player gets informed by color chat.
  5. *
  6. *   Last update:
  7. *     9/24/2016
  8. *
  9. *   Support forum:
  10. *     https://goldsrc.ru/
  11. *
  12. *   Changes:
  13. *   - rewritten from scratch; all options are set in the source now
  14. *   - plugin uses data from stats plugins by SKAJIbnEJIb
  15. *   - added external colorchat support (native for AMXX 1.8.3, stock for earlier versions)
  16. *       you could download stock here: http://aghl.ru/forum/viewtopic.php?p=21539#p21539
  17. *
  18. *   Credits:
  19. *   - original plugin's authors SimonLogic & RoleX
  20. *   - c-s.net.ua users 3aB}{o3 & cs-portal for the idea and link
  21. *
  22. *   Notes:
  23. *   - it is transitional version, I hope there will be all-in-one version soon
  24. *   - 'cs' in version means 'chat version, SKAJIbnEJIb edition'
  25. */
  26.  
  27. /*  Copyright 2016 Safety1st
  28.  
  29.     Top Awards is free software;
  30.     you can redistribute it and/or modify
  31.     it under the terms of the GNU General Public License as published by
  32.     the Free Software Foundation; either version 2 of the License, or
  33.     (at your option) any later version.
  34.  
  35.     This program is distributed in the hope that it will be useful,
  36.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  37.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  38.     GNU General Public License for more details.
  39.  
  40.     You should have received a copy of the GNU General Public License
  41.     along with this program; if not, write to the Free Software
  42.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  43.    
  44.     - 22.10.2016
  45.         wopox1337: добавил dhud сообщение
  46. */
  47.  
  48. #include <amxmodx>
  49. #include <csstats_mysql>
  50.  
  51. #define PLUGIN "Top Awards"
  52. #define VERSION "0.2 Csstats_RBS"
  53. #define AUTHOR "Safety1st"
  54.  
  55. /*----------------------------------EDIT ME----------------------------------*/
  56. const TOP_MAX       = 10                // how many first TOP players will be given bonus flags
  57. const ADD_FLAGS     = ADMIN_LEVEL_H | ADMIN_LEVEL_A     // which flags we will add as a bonus; flag 't' by default
  58. // #define IGNORE_FLAG   ADMIN_LEVEL_A  // which players will not have bonus flags; uncomment to enable; flag 'm' by default
  59. /*-------------------------------STOP EDIT HERE-------------------------------*/
  60.  
  61. #if AMXX_VERSION_NUM < 183
  62.     // AMXX 1.8.3-dev since hg185 has its own colorchat support
  63.     #include <colorchat>
  64.     #define print_team_default  DontChange
  65.     #define print_team_grey     Grey
  66.     #define print_team_red      Red
  67.     #define print_team_blue     Blue
  68.    
  69.     #include <dhudmessage>
  70. #endif
  71.  
  72. #define TASK_DELAY 5.0  // Задержка при показе сообщения о получении TOP привелгеий
  73.  
  74. public plugin_init() {
  75.     register_plugin( PLUGIN, VERSION, AUTHOR )
  76.     register_dictionary( "top_awards.txt" )
  77. }
  78.  
  79. public csstats_putinserver( id, bool:wasbefore ) {
  80.     // forward is called when stats is loaded for entered player
  81.  
  82.     if( !wasbefore )
  83.         // a new player
  84.         return
  85.  
  86.     if( is_user_bot(id) || is_user_hltv(id) )
  87.         // dunno whether it is still needed...
  88.         return
  89.  
  90.     new iFlags = get_user_flags(id)
  91.  
  92.     if ( iFlags & ADD_FLAGS == ADD_FLAGS )
  93.         // ignore player having all additional flags
  94.         return
  95.  
  96. #if defined IGNORE_FLAG
  97.     if ( iFlags & IGNORE_FLAG )
  98.         return
  99. #endif
  100.  
  101.     new iRank = csstats_get_user_place(id)
  102.  
  103.     if ( iRank && iRank <= TOP_MAX ) {
  104.         // 1st check for safety. may be player not ranked at all yet
  105.         set_user_flags( id, ADD_FLAGS )     // function adds the flags using a bitwise-or operation
  106.  
  107.         set_task( TASK_DELAY, "PrintMessage", id )
  108.     }
  109. }
  110.  
  111. public PrintMessage(id) {
  112.     if ( !is_user_connected(id) )
  113.         return
  114. // Сообщение в чат
  115.     client_print_color( id, print_team_default, "%L", id, "TOP_AWARDS", TOP_MAX )
  116.  
  117. // Сообщение в DHUD
  118.     set_dhudmessage( random(200) + 25, random(200) + 25, random(200) + 25, -1.0, 0.35, .holdtime = 12.0 )
  119.     show_dhudmessage( id, "%L", id, "TOP_AWARDS", TOP_MAX)
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement