Facebook
From Idiotic Partdridge, 7 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 255
  1. #include <amxmodx>
  2.  
  3. #define PLUGIN "BestPlayer"
  4. #define VERSION "1.0"
  5. #define AUTHOR "KaMaZZ"
  6.  
  7. new g_iKills[33]
  8. new g_iDeaths[33]
  9. new g_hs[33]
  10.  
  11. new bestplayer = 0, g_iMaxPlayers;
  12.  
  13. public plugin_init()
  14. {
  15.         register_plugin(PLUGIN, VERSION, AUTHOR)
  16.         register_event("DeathMsg", "death_event", "a", "1>0");
  17.         register_event("HLTV", "eHLTV", "a", "1=0", "2=0");
  18.         register_logevent("wiadomosc",2,"1=Round_End")
  19.         g_iMaxPlayers = get_maxplayers();
  20. }
  21.  
  22. /*============================================ ============================================= =======*/
  23. /*************************************** [Color Chat] *********************************************/
  24. /*============================================ =================================R=E=Y=M=O=N= =A=R=G=*/
  25.  
  26.  
  27. enum Color
  28. {
  29.         NORMAL = 1, // clients scr_concolor cvar color
  30.         GREEN, // Green Color
  31.         TEAM_COLOR, // Red, grey, blue
  32.         GREY, // grey
  33.         RED, // Red
  34.         BLUE, // Blue
  35. }
  36.  
  37. new TeamName[][] =
  38. {
  39.         "",
  40.         "TERRORIST",
  41.         "CT",
  42.         "SPECTATOR"
  43. }
  44.  
  45. ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
  46. {
  47.         new message[256];
  48.  
  49.         switch(type)
  50.         {
  51.         case NORMAL: // clients scr_concolor cvar color
  52.                 {
  53.                         message[0] = 0x01;
  54.                 }
  55.         case GREEN: // Green
  56.                 {
  57.                         message[0] = 0x04;
  58.                 }
  59.         default: // White, Red, Blue
  60.                 {
  61.                         message[0] = 0x03;
  62.                 }
  63.         }
  64.  
  65.         vformat(message[1], 251, msg, 4);
  66.  
  67.         // Make sure message is not longer than 192 character. Will crash the server.
  68.         message[192] = '^0';
  69.  
  70.         new team, ColorChange, index, MSG_Type;
  71.  
  72.         if(id)
  73.         {
  74.                 MSG_Type = MSG_ONE;
  75.                 index = id;
  76.         } else {
  77.                 index = FindPlayer();
  78.                 MSG_Type = MSG_ALL;
  79.         }
  80.  
  81.         team = get_user_team(index);
  82.         ColorChange = ColorSelection(index, MSG_Type, type);
  83.  
  84.         ShowColorMessage(index, MSG_Type, message);
  85.  
  86.         if(ColorChange)
  87.         {
  88.                 Team_Info(index, MSG_Type, TeamName[team]);
  89.         }
  90. }
  91.  
  92. ShowColorMessage(id, type, message[])
  93. {
  94.         static bool:saytext_used;
  95.         static get_user_msgid_saytext;
  96.         if(!saytext_used)
  97.         {
  98.                 get_user_msgid_saytext = get_user_msgid("SayText");
  99.                 saytext_used = true;
  100.         }
  101.         message_begin(type, get_user_msgid_saytext, _, id);
  102.         write_byte(id)
  103.         write_string(message);
  104.         message_end();
  105. }
  106.  
  107. Team_Info(id, type, team[])
  108. {
  109.         static bool:teaminfo_used;
  110.         static get_user_msgid_teaminfo;
  111.         if(!teaminfo_used)
  112.         {
  113.                 get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
  114.                 teaminfo_used = true;
  115.         }
  116.         message_begin(type, get_user_msgid_teaminfo, _, id);
  117.         write_byte(id);
  118.         write_string(team);
  119.         message_end();
  120.  
  121.         return 1;
  122. }
  123.  
  124. ColorSelection(index, type, Color:Type)
  125. {
  126.         switch(Type)
  127.         {
  128.         case RED:
  129.                 {
  130.                         return Team_Info(index, type, TeamName[1]);
  131.                 }
  132.         case BLUE:
  133.                 {
  134.                         return Team_Info(index, type, TeamName[2]);
  135.                 }
  136.         case GREY:
  137.                 {
  138.                         return Team_Info(index, type, TeamName[0]);
  139.                 }
  140.         }
  141.  
  142.         return 0;
  143. }
  144.  
  145. FindPlayer()
  146. {
  147.         new i = -1;
  148.  
  149.         while(i <= get_maxplayers())
  150.         {
  151.                 if(is_user_connected(++i))
  152.                 return i;
  153.         }
  154.  
  155.         return -1;
  156. }
  157.  
  158. public client_connect(id)
  159. {
  160.         g_iKills[id] = 0
  161.         g_iDeaths[id] = 0
  162. }
  163.  
  164. public death_event()
  165. {
  166.         new iKiller = read_data(1), iVictim = read_data(2), iHitplace = read_data(3);
  167.  
  168.         if (iKiller == iVictim)
  169.         {
  170.                 g_iDeaths[iKiller]++;
  171.                 return;
  172.         }
  173.  
  174.         g_iKills[iKiller]++;
  175.         g_iDeaths[iVictim]++;
  176.  
  177.         if(iHitplace)
  178.         {
  179.                 g_hs[iKiller]++;
  180.         }
  181. }
  182.  
  183. public wiadomosc()
  184. {
  185.         if(get_playersnum() < 2)
  186.         return
  187.  
  188.         for(new i=1; i <= g_iMaxPlayers; i++)
  189.         {
  190.                 if (g_iKills[i] > g_iKills[bestplayer] || g_iKills[i] == g_iKills[bestplayer] && g_iDeaths[i] < g_iDeaths[bestplayer] || g_iKills[i] == g_iKills[bestplayer] && g_hs[i] > g_hs[bestplayer])
  191.                 {
  192.                         bestplayer = i;
  193.                 }
  194.         }
  195.  
  196.         new name[32];
  197.         get_user_name(bestplayer, name, 31);
  198.  
  199.         new iKills = g_iKills[bestplayer]
  200.         new iHS = g_hs[bestplayer]
  201.  
  202.         ColorChat(0, GREEN,"^x03 [How2Kill.PL]: Najlepszy gracz w tej rundzie: %s", name)
  203.         if(iKills >= 5 || iKills == 0)
  204.         {
  205.                 ColorChat(0, GREEN, "^x03 [How2Kill.PL]: Zdobyl %d fragow", iKills)
  206.         }
  207.         else if(iKills > 1 && iKills < 5)
  208.         {
  209.                 ColorChat(0, GREEN, "^x03 [How2Kill.PL]: Zdobyl %d fragi", iKills)
  210.         }
  211.         else if(iKills == 1)
  212.         {
  213.                 ColorChat(0, GREEN, "^x03 [How2Kill.PL]: Zdobyl 1 fraga")
  214.         }
  215.         ColorChat(0, GREEN, "^x03 [PGC24.PL]: Ustrzelil %d hsow", iHS)
  216. }
  217.  
  218. public eHLTV()
  219. {
  220.         for( new i = 1 ; i <= g_iMaxPlayers ; i++ )
  221.         {
  222.                 g_iKills[ i ] = 0;
  223.                 g_iDeaths[ i ] = 0;
  224.                 g_hs[ i ] = 0;
  225.         }
  226. }
  227. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  228. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
  229. */
  230.