laurentiuarion

Reser score 3.3

Feb 11th, 2020
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <cstrike>
  3. #include <fun>
  4.  
  5. #pragma semicolon 1
  6. #define ADMIN_ACCESS ADMIN_IMMUNITY
  7.  
  8. enum Color { NORMAL = 1, GREEN, TEAM_COLOR, GREY, RED, BLUE};
  9. new TeamName[][] = { "", "TERRORIST", "CT", "SPECTATOR" };
  10. new cvar_chat, cvar_on, cvar_dead, cvar_tag, cvar_time, g_Tag;
  11.  
  12. public plugin_init() {
  13.     register_plugin("Reset score", "3.2", "Ex3cuTioN");
  14.    
  15.     register_clcmd("say /resetscore", "cmdReset");
  16.     register_clcmd("say /rs", "cmdReset");
  17.     register_clcmd("say_team /resetscore", "cmdReset");
  18.     register_clcmd("resetscore", "cmdReset");
  19.    
  20.     register_concmd("amx_resetscore", "conReset", ADMIN_ACCESS, "- reseteaza scorul tuturor");
  21.    
  22.     cvar_chat = register_cvar("amx_reset_chat", "1");
  23.     cvar_on = register_cvar("amx_reset_plugin", "1");
  24.     cvar_dead = register_cvar("amx_reset_dead","1");
  25.     cvar_tag = register_cvar("amx_reset_tag","ResetScore");
  26.     cvar_time = register_cvar("amx_reset_time","60");
  27.    
  28.     if(get_pcvar_num(cvar_chat) == 1) {
  29.         new Float:timp = get_pcvar_float(cvar_time);
  30.         set_task(timp, "chatmsgshow", _, _, _, "b", 0);
  31.     }
  32.     new tag[32];
  33.     g_Tag = get_pcvar_string(cvar_tag, tag, 31);
  34. }
  35.  
  36. public cmdReset(id) {
  37.     if(get_pcvar_num(cvar_on) == 0) {
  38.         ColorChat(id, GREEN,"[%s]^x01 Pluginul este dezactivat", g_Tag);
  39.         return PLUGIN_HANDLED;
  40.     }
  41.     if(get_pcvar_num(cvar_dead) == 0 && !is_user_alive(id)) {
  42.         ColorChat(id, GREEN, "[%s]^x01 Poti folosii comanda numai atunci cand esti viu.", g_Tag);
  43.         return PLUGIN_HANDLED;
  44.     }
  45.    
  46.     new frags = get_user_frags(id);
  47.     new deaths = get_user_deaths(id);
  48.    
  49.     if(frags == 0 && deaths == 0)
  50.         ColorChat(id, GREEN, "[%s]^x01 Scorul tau este deja^x04 0",g_Tag);
  51.     else {
  52.         for(new i = 0; i < 2; i++) {
  53.             cs_set_user_deaths(id, 0);
  54.             set_user_frags(id, 0);
  55.         }
  56.        
  57.         new name[32];
  58.         get_user_name(id, name, 31);
  59.        
  60.         ColorChat(id, GREEN, "[%s]^x01 Scorul tau s-a resetat.", g_Tag);
  61.         ColorChat(0, GREEN,"[%s]^x01 si-a resetat scorul.", name);
  62.     }
  63.     return PLUGIN_HANDLED;
  64. }
  65.  
  66. public conReset(id) {
  67.     if(get_user_flags(id)&ADMIN_ACCESS) {
  68.         new players[32], num, player;
  69.         get_players(players, num, "c");
  70.        
  71.         for(new i = 0; i < num; i++) {
  72.             player = players;
  73.             if(get_user_frags(player) != 0 && get_user_deaths(player) != 0) {
  74.                 cs_set_user_deaths(player, 0);
  75.                 set_user_frags(player, 0);
  76.             }
  77.         }
  78.        
  79.         new name[32];
  80.         get_user_name(id, name, 31);
  81.        
  82.         ColorChat(0, GREEN, "[%s]^x03 %s^x01 a resetat scorul tuturor.", g_Tag, name);
  83.     }
  84.     else
  85.         console_print(id, "Nu ai acces la aceasta comanda.");
  86.        
  87.     return PLUGIN_HANDLED;
  88. }
  89.  
  90. public chatmsgshow(id)
  91.     ColorChat(id, GREEN, "[%s]^x01 Daca vrei sa iti resetezi scorul, foloseste comanda^x04 /resetscore^x01 sau^x04 /rs !", g_Tag);
  92.  
  93. ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...) {
  94.     if(!get_playersnum())
  95.         return;
  96.    
  97.     new message[256];
  98.  
  99.     switch(type) {
  100.         case NORMAL:
  101.         {
  102.             message[0] = 0x01;
  103.         }
  104.         case GREEN:
  105.         {
  106.             message[0] = 0x04;
  107.         }
  108.         default:
  109.         {
  110.             message[0] = 0x03;
  111.         }
  112.     }
  113.  
  114.     vformat(message[1], 251, msg, 4);
  115.  
  116.     // Make sure message is not longer than 192 character. Will crash the server.
  117.     message[192] = '^0';
  118.  
  119.     new team, ColorChange, index, MSG_Type;
  120.    
  121.     if(id) {
  122.         MSG_Type = MSG_ONE;
  123.         index = id;
  124.     }
  125.     else {
  126.         index = FindPlayer();
  127.         MSG_Type = MSG_ALL;
  128.     }
  129.    
  130.     team = get_user_team(index);
  131.     ColorChange = ColorSelection(index, MSG_Type, type);
  132.  
  133.     ShowColorMessage(index, MSG_Type, message);
  134.        
  135.     if(ColorChange)
  136.         Team_Info(index, MSG_Type, TeamName[team]);
  137. }
  138.  
  139. ShowColorMessage(id, type, message[]) {
  140.     static bool:saytext_used;
  141.     static get_user_msgid_saytext;
  142.    
  143.     if(!saytext_used) {
  144.         get_user_msgid_saytext = get_user_msgid("SayText");
  145.         saytext_used = true;
  146.     }
  147.    
  148.     message_begin(type, get_user_msgid_saytext, _, id);
  149.     write_byte(id);
  150.     write_string(message);
  151.     message_end()
  152. }
  153.  
  154. Team_Info(id, type, team[]) {
  155.     static bool:teaminfo_used;
  156.     static get_user_msgid_teaminfo;
  157.    
  158.     if(!teaminfo_used) {
  159.         get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
  160.         teaminfo_used = true;
  161.     }
  162.    
  163.     message_begin(type, get_user_msgid_teaminfo, _, id);
  164.     write_byte(id);
  165.     write_string(team);
  166.     message_end();
  167.  
  168.     return 1;
  169. }
  170.  
  171. ColorSelection(index, type, Color:Type) {
  172.     switch(Type) {
  173.         case RED:
  174.         {
  175.             return Team_Info(index, type, TeamName[1]);
  176.         }
  177.         case BLUE:
  178.         {
  179.             return Team_Info(index, type, TeamName[2]);
  180.         }
  181.         case GREY:
  182.         {
  183.             return Team_Info(index, type, TeamName[0]);
  184.         }
  185.     }
  186.  
  187.     return 0;
  188. }
  189.  
  190. FindPlayer() {
  191.     new i = -1;
  192.  
  193.     while(i <= get_maxplayers()) {
  194.         if(is_user_connected(++i))
  195.             return i;
  196.     }
  197.  
  198.     return -1;
  199. }
RAW Paste Data