Advertisement
CheezPuff

Round Cash for a winning team v1.8.2

May 12th, 2019
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.75 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.     Requirements: Amx Mod X v1.8.2
  8. */
  9.  
  10. /* Plugin generated by AMXX-Studio */
  11.  
  12. #include < amxmodx>  
  13. #include < cstrike>  
  14. #include < hamsandwich >  
  15. #include < ColorChat >
  16.  
  17. #define PLUGIN "Round Cash"
  18. #define VERSION "1.0"
  19. #define AUTHOR "CheezPuff"
  20.  
  21. enum Teams  
  22. {  
  23.     Team_T ,  
  24.     Team_CT  
  25. }  
  26.  
  27. enum WinInfo
  28. {
  29.     Teams:wiTeam,
  30.     wiMoney
  31. }
  32.  
  33. new const TeamNames[ Teams ][] =  
  34. {
  35.     "Terrorist",
  36.     "CT"
  37. };
  38.  
  39. new pcvar_CT_Cash , pcvar_T_Cash;  
  40. new g_LastWinner[ WinInfo ];
  41.  
  42. new const Prefix[] = "^x04[Round Cash]^x01"
  43.  
  44. //native get_user_cash( Index ) // get the amount of cash a player have  
  45. //native set_user_cash( Index, amount ) // set the amount of cash for a player  
  46.  
  47. #define get_user_cash(%1)    cs_get_user_money(%1)  
  48. #define set_user_cash(%1,%2)    cs_set_user_money(%1,%2)
  49.  
  50. public plugin_init()  
  51. {  
  52.     register_plugin(PLUGIN, VERSION, AUTHOR)
  53.      
  54.     pcvar_T_Cash = register_cvar( "amx_cash_tero" , "5000" );
  55.     pcvar_CT_Cash = register_cvar( "amx_cash_counter" , "5000" );
  56.      
  57.     register_logevent( "CT_Win_Event" , 6 , "3=CTs_Win" , "3=All_Hostages_Rescued" );
  58.     register_logevent( "TE_Win_Event" , 6 , "3=Terrorists_Win" , "3=Target_Bombed" );
  59.      
  60.     register_clcmd( "say /last" , "ShowLastWinner" );
  61.     register_clcmd( "say_team /last" , "ShowLastWinner" );
  62. }          
  63.  
  64. public TE_Win_Event()  
  65. {  
  66.     MessageWon( Team_T );
  67. }  
  68.  
  69. public CT_Win_Event()  
  70. {  
  71.     MessageWon( Team_CT );  
  72. }  
  73.  
  74. public MessageWon( Teams:tTeam )  
  75. {  
  76.     new iPlayers[ 32 ], iNumPlayers , iNumEnemies , Index , iTotalMoney;  
  77.      
  78.     get_players( iPlayers , iNumEnemies , "e" , tTeam == Team_T ? "CT" : "TERRORIST" );  
  79.     iTotalMoney = iNumEnemies * ( get_pcvar_num( tTeam == Team_T ? pcvar_T_Cash : pcvar_CT_Cash ) );  
  80.      
  81.     g_LastWinner[ wiTeam ] = tTeam;
  82.     g_LastWinner[ wiMoney ] = iTotalMoney;
  83.      
  84.     get_players( iPlayers , iNumPlayers , "e" , tTeam == Team_T ? "TERRORIST" : "CT" );  
  85.      
  86.     ColorChat( 0 , NORMAL , "%s - %s's Won the round, Awarded $%d (%d x %d)", Prefix, TeamNames[ tTeam ] , iTotalMoney , iNumEnemies , get_pcvar_num( tTeam == Team_T ? pcvar_T_Cash : pcvar_CT_Cash ) );  
  87.      
  88.     for ( new i = 0 ; i < iNumPlayers ; i++ )  
  89.     {  
  90.         Index = iPlayers[ i ];
  91.         set_user_cash( Index , get_user_cash( Index ) + iTotalMoney );  
  92.     }
  93. }  
  94.  
  95. public ShowLastWinner( Index )
  96. {
  97.     if ( !g_LastWinner[ wiTeam ] && !g_LastWinner[ wiMoney ] )
  98.     {
  99.         ColorChat( Index , NORMAL , "* No team has won yet." );
  100.     }
  101.     else
  102.     {
  103.         ColorChat( Index , NORMAL , "* The last winner was %s's, winning $%d!" , TeamNames[ g_LastWinner[ wiTeam ] ] , g_LastWinner[ wiMoney ] );
  104.     }
  105.     return PLUGIN_HANDLED;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement