CheezPuff

Round Cash for a winning team v1.8.3+

May 12th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.80 KB | None | 0 0
  1. /*      
  2.     Asking Plugin and the idea of: LordShot
  3.     Built By: CheezPuff
  4.  
  5.     - Public Release v1.0 (12/5/2019)
  6.    
  7.     Thanks for - http://www.amxmodx.org/api/amxmisc/get_playersnum_ex
  8.  
  9.     Requirements: Amx Mod X v1.8.3+
  10. */
  11.  
  12. /* Plugin generated by AMXX-Studio */
  13.  
  14. #include < amxmodx >
  15. #include < amxmisc >
  16. #include < cstrike >
  17. #include < hamsandwich >
  18.  
  19. #define PLUGIN "Round Cash"
  20. #define VERSION "1.0"
  21. #define AUTHOR "CheezPuff"
  22.  
  23. new PlayerValue
  24. new const Prefix[] = "^x04[Round Cash]^x01"
  25. new szMessage[60]
  26.  
  27. native get_user_cash( client ) // get the amount of cash a player have
  28. native set_user_cash( client, amount ) // set the amount of cash for a player
  29.  
  30. public plugin_init()
  31. {
  32.     register_plugin(PLUGIN, VERSION, AUTHOR)
  33.  
  34.     register_event("SendAudio", "EventTRWin","a", "2&%!MRAD_terwin")
  35.     register_event("SendAudio", "EventCTWin","a", "2&%!MRAD_ctwin")
  36.     register_clcmd("say /last", "lastTeamWinner")
  37.     new pCvar
  38.     pCvar = register_cvar("test_cvar","5000", .description = "The value of every player.")
  39.     bind_pcvar_num(pCvar, PlayerValue)
  40. }
  41.  
  42. public EventTRWin()
  43. {
  44.     SendCash(true)
  45. }
  46.  
  47. public EventCTWin()
  48. {
  49.     SendCash(false)
  50. }
  51.  
  52. SendCash(bool:TeamTvictory)
  53. {
  54.     if(TeamTvictory)
  55.     {
  56.         new iNumTeamCT = get_playersnum_ex(GetPlayers_ExcludeAlive | GetPlayers_MatchTeam, "CT")
  57.         new iNumTeamT = get_playersnum_ex(GetPlayers_MatchTeam, "TERRORIST")
  58.         new iReward = (PlayerValue * iNumTeamCT / iNumTeamT)
  59.        
  60.         new iPlayers[MAX_PLAYERS], iNum
  61.         get_players_ex(iPlayers, iNum, GetPlayers_ExcludeBots | GetPlayers_ExcludeHLTV | GetPlayers_MatchTeam, "TERRORIST")
  62.         for(new i = 0; i < iNum; i++)
  63.         {
  64.             if(!is_user_connected(iPlayers[i]))
  65.                 continue
  66.                
  67.             set_user_cash(iPlayers[i], get_user_cash(iPlayers[i]) + iReward)
  68.         }
  69.         formatex(szMessage, charsmax(szMessage), "%s The last Team winner was Terrorists, winning^x04 %i^x01 cash.", Prefix, iReward)
  70.     }
  71.     else
  72.     {
  73.         new iNumTeamT = get_playersnum_ex(GetPlayers_ExcludeAlive | GetPlayers_MatchTeam, "TERRORIST")
  74.         new iNumTeamCT = get_playersnum_ex(GetPlayers_MatchTeam, "CT")
  75.         new iReward = (PlayerValue * iNumTeamT / iNumTeamCT)
  76.            
  77.         new iPlayers[MAX_PLAYERS], iNum
  78.         get_players_ex(iPlayers, iNum, GetPlayers_ExcludeBots | GetPlayers_ExcludeHLTV| GetPlayers_MatchTeam, "CT")
  79.         for(new i = 0; i < iNum; i++)
  80.         {
  81.             if(!is_user_connected(iPlayers[i]))
  82.                 continue
  83.            
  84.             set_user_cash(iPlayers[i], get_user_cash(iPlayers[i]) + iReward)
  85.         }
  86.         formatex(szMessage, charsmax(szMessage), "%s The last Team winner was CT, winning^x04 %i^x01 cash.", Prefix, iReward)
  87.     }
  88. }
  89.  
  90. public lastTeamWinner(Index)
  91. {
  92.     if(szMessage[0])
  93.     {
  94.         client_print_color(Index, print_team_default, "%s", szMessage)
  95.         return PLUGIN_HANDLED
  96.     }
  97.     else
  98.     {
  99.         client_print_color(Index, print_team_default, "%s No team victory yet.", Prefix)
  100.         return PLUGIN_HANDLED
  101.     }
  102. }
Add Comment
Please, Sign In to add comment