Guest User

Untitled

a guest
Apr 19th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 8.60 KB | None | 0 0
  1.  
  2. #include <amxmodx>
  3. #include <amxmisc>
  4. #include <cstrike>
  5. #include <fun>
  6. #include <hamsandwich>
  7.  
  8. /* -------------------------------------------------------------------- */
  9.  
  10. //
  11. //   (.*-> Mod Loup Garou <-*.)
  12. //
  13. //   Date de commencement : 25/09/2010
  14. //
  15. //   Dernière mise à jour : 30/09/2010
  16.  
  17. /* -------------------------------------------------------------------- */
  18.  
  19. /* -------------------------------------------------------------------- */
  20. /* -----                    CONSTANTES & MACROS                   ----- */
  21. /* -------------------------------------------------------------------- */
  22.  
  23. #define VERSION "1.0"
  24.  
  25. enum {HUMAIN, LOUP};
  26.  
  27. /* -------------------------------------------------------------------- */
  28. /* -----                         VARIABLES                        ----- */
  29. /* -------------------------------------------------------------------- */
  30.  
  31. new Type[33];
  32. new NbJoueur;
  33. new Joueurs[32];
  34.  
  35. new gmsgTextMsg;
  36. new gmsgScreenFade;
  37.  
  38. /* -------------------------------------------------------------------- */
  39. /* -----                           CVARS                          ----- */
  40. /* -------------------------------------------------------------------- */
  41.  
  42. /* -------------------------------------------------------------------- */
  43. /* -----                  INITIALISATION & CFG                    ----- */
  44. /* -------------------------------------------------------------------- */
  45.  
  46. public plugin_init()
  47. {
  48.     register_plugin("Amx_Loup_Garou", VERSION, "Mariko <3")
  49.    
  50.     //Hamsandwich
  51.     RegisterHam(Ham_Spawn, "player", "Spawn_Joueur", 1);
  52.    
  53.     //Events
  54.     register_event("SendAudio", "Message_Grenade", "b", "2=%!MRAD_FIREINHOLE");
  55.     register_event("HLTV", "Nouveau_Round", "a", "1=0", "2=0");
  56.     register_event("DeathMsg", "Joueur_Mort", "a");
  57.    
  58.     //Messages
  59.     register_message(get_user_msgid("DeathMsg"), "Message_Mort");
  60.     register_message(get_user_msgid("TextMsg"), "Message_Tk");
  61.    
  62.     set_msg_block(get_user_msgid("Radar"), BLOCK_SET); // Bloque le radar
  63.     gmsgTextMsg = get_user_msgid("TextMsg");
  64.     gmsgScreenFade = get_user_msgid("ScreenFade");
  65. }
  66.  
  67. public plugin_cfg()
  68. {
  69.     set_cvar_string("mp_playerid", "2"); // On ne voit pas les pseudos
  70.     set_cvar_string("mp_friendlyfire", "1"); // Tir allié autorisé
  71.     set_cvar_string("mp_limitteams","0");
  72.     set_cvar_string("mp_autoteambalance","0");
  73.     set_cvar_string("mp_autokick","0");
  74.     set_cvar_string("mp_freezetime","2");
  75. }
  76.  
  77. public client_connect(id)
  78. {
  79.     Type[id] = HUMAIN;
  80.    
  81.     return PLUGIN_CONTINUE;
  82. }
  83.  
  84. public client_disconnect(id)
  85. {
  86.     Type[id] = HUMAIN;
  87.    
  88.     return PLUGIN_CONTINUE;
  89. }
  90.  
  91. /* -------------------------------------------------------------------- */
  92. /* -----                      EVENTS & MSG                        ----- */
  93. /* -------------------------------------------------------------------- */
  94.  
  95. // ---------------------------------------------
  96. // Répartit les rôles (Loup, Humain .. )
  97.  
  98. public Nouveau_Round()
  99. {  
  100.     get_players(Joueurs, NbJoueur);
  101.    
  102.     End = 0;
  103.    
  104.     new lg = Joueurs[random(NbJoueur)];
  105.    
  106.     for(new id, i = 0 ; i < NbJoueur ; i++)
  107.     {
  108.         id = Joueurs[i];
  109.        
  110.         Type[id] = (id == lg) ? LOUP : HUMAIN;
  111.     }
  112. }
  113.  
  114. // ---------------------------------------------
  115. // Spawn du joueur
  116.  
  117. public Spawn_Joueur(id)
  118. {
  119.     if(is_user_alive(id))
  120.     {
  121.         cs_set_user_team(id ,CS_TEAM_CT, CS_CT_GIGN);
  122.    
  123.         client_cmd(id,"hideradar");
  124.    
  125.         strip_user_weapons(id);
  126.         give_item(id, "weapon_knife");
  127.         give_item(id, "weapon_deagle");
  128.         cs_set_user_bpammo(id, CSW_DEAGLE,70);
  129.         give_item(id, "weapon_m4a1");
  130.         cs_set_user_bpammo(id, CSW_M4A1, 150);
  131.         give_item(id, "weapon_ak47");
  132.         cs_set_user_bpammo(id, CSW_AK47, 150);
  133.         cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM);
  134.        
  135.         switch(Type[id])
  136.         {
  137.             case LOUP:
  138.             {
  139.                 print_color(id, id, 0,"^x04[Loup-Garou]^x01 Vous etes le Loup-Garou !");
  140.                 print_color(id, id, 0,"^x04[Loup-Garou]^x01 Eliminez vos ennemis sans vous faire remarquer !");
  141.                 FadeEffect(id, 0x00FF0000, 128, 2);
  142.             }
  143.             case HUMAIN:
  144.             {
  145.                 print_color(id, id, 0,"^x04[Loup-Garou]^x01 Un traitre se cache parmis vous ...");
  146.                 print_color(id, id, 0,"^x04[Loup-Garou]^x01 Eliminez-le !");
  147.                 FadeEffect(id, 0x000000FF, 128, 2);
  148.             }
  149.         }
  150.     }
  151. }
  152.  
  153. // ---------------------------------------------
  154. // Gère les kills et le score
  155.  
  156. public Joueur_Mort()
  157. {  
  158.     if(End) return PLUGIN_CONTINUE;
  159.    
  160.     get_players(Joueurs, NbJoueur);
  161.    
  162.     new idT = read_data(1);
  163.     new idV = read_data(2);
  164.    
  165.     if(is_user_connected(idT) && is_user_connected(idV) && idT != idV)
  166.     {
  167.         if(Type[idT] == LOUP && Type[idV] == HUMAIN)
  168.         {
  169.             new NomV[32];
  170.        
  171.             get_user_name(idV, NomV, charsmax(NomV));
  172.        
  173.             print_color(0, idV, 0,"^x04[Loup-Garou]^x01 %s s'est fait avoir !", NomV);
  174.        
  175.             set_user_frags(idT, get_user_frags(idT) + 1); // -1 pour le frag, donc +1 - 1 = 0
  176.         }
  177.        
  178.         else if(Type[idT] == HUMAIN && Type[idV] == LOUP)
  179.         {
  180.             new NomT[32];
  181.        
  182.             get_user_name(idT, NomT, charsmax(NomT));
  183.        
  184.             set_user_frags(idT, get_user_frags(idT) + 6); // -1 pour le frag, donc +6 - 1 = +5
  185.        
  186.             print_color(0, idT, 0,"^x04[Loup-Garou]^x01 %s vient d'eliminer le traitre ! On ne l'a lui fait pas !", NomT);
  187.         }  
  188.    
  189.         else if(Type[idT] == Type[idV])
  190.         {
  191.             new NomV[32];
  192.            
  193.             get_user_name(idV, NomV, charsmax(NomV));
  194.        
  195.             print_color(0, idV, 0,"^x04[Loup-Garou]^x01 %s s'est fait avoir !", NomV);
  196.        
  197.             set_user_frags(idT, get_user_frags(idT) + 1); // -1 pour le frag, donc +1 - 1 = 0
  198.        
  199.             print_color(idT, idT, 0,"^x04[Loup-Garou]^x01 Tu as perdu ...");
  200.             user_kill(idT);
  201.         }
  202.     }
  203.    
  204.     new nbA = 0;
  205.    
  206.     for(new i = 0, id ; i < NbJoueur ; i++)
  207.     {
  208.         id = Joueurs[i];
  209.        
  210.         if(is_user_alive(id)) nbA++;
  211.         else if(Type[id] == LOUP) End = 1;
  212.     }
  213.    
  214.     if(nbA < 2) End = 1;
  215.     if(End) Fin_Round();
  216.    
  217.     return PLUGIN_CONTINUE;
  218. }
  219.  
  220. // ---------------------------------------------
  221. // Cache les kills du loup
  222.  
  223. public Message_Mort()
  224. {
  225.     new idT = get_msg_arg_int(1);
  226.    
  227.     if (is_user_alive(idT) && Type[idT] == LOUP)
  228.     {
  229.         new idV = get_msg_arg_int(2);
  230.            
  231.         set_msg_arg_int(1, ARG_BYTE, idV);
  232.     }
  233.     return PLUGIN_CONTINUE;
  234. }
  235.  
  236. // ---------------------------------------------
  237. // Cache les messages TK
  238.  
  239. public Message_Tk(iMsgId, iMsgDest, id)
  240. {
  241.     if(id && get_msg_arg_int(1) == print_chat)
  242.     {
  243.         new szMessage[23]; // #Game_teammate_attack
  244.         get_msg_arg_string(2, szMessage, charsmax(szMessage));
  245.        
  246.         if(equal(szMessage, "#Game_teammate_attack"))
  247.         {
  248.             return PLUGIN_HANDLED;
  249.         }
  250.     }
  251.        
  252.     return PLUGIN_CONTINUE;
  253. }
  254.  
  255. // ---------------------------------------------
  256. // Bloque le message grenade
  257.  
  258. public Message_Grenade()
  259. {
  260.     if(get_msg_block(gmsgTextMsg) != BLOCK_SET)
  261.     {
  262.         set_msg_block(gmsgTextMsg, BLOCK_ONCE);
  263.     }
  264.    
  265.     return PLUGIN_CONTINUE;
  266. }
  267.  
  268. /* -------------------------------------------------------------------- */
  269. /* -----                       FONCTIONS                          ----- */
  270. /* -------------------------------------------------------------------- */
  271.  
  272. public FadeEffect(id, color, alpha, time)
  273. {
  274.     message_begin(MSG_ONE_UNRELIABLE,gmsgScreenFade,{0,0,0},id);
  275.     write_short(4096 * time);
  276.     write_short(4096 * time);
  277.     write_short(4096);
  278.     write_byte((color & 0x00FF0000) >> 16);
  279.     write_byte((color & 0x0000FF00) >> 8);
  280.     write_byte((color & 0x000000FF));
  281.     write_byte(alpha);
  282.     message_end();
  283. }
  284.  
  285. // ---------------------------------------------
  286. // Termine le round
  287.  
  288. public Fin_Round()
  289. {
  290.     get_players(Joueurs, NbJoueur, "ah");
  291.    
  292.     print_color(0, 1, 0,"^x04[Loup-Garou]^x01 Nouvelle partie en preparation ...");
  293.    
  294.     for(new i = 0, id ; i < NbJoueur ; i++)
  295.     {
  296.         id = Joueurs[i];
  297.        
  298.         user_kill(id);
  299.     }
  300. }
  301.  
  302. /* -------------------------------------------------------------------- */
  303. /* -----                    CHAT EN COULEUR                       ----- */
  304. /* -------------------------------------------------------------------- */
  305.    
  306. public print_color(id, cid, color, const message[], any:...)
  307. {
  308.     new msg[192];
  309.     vformat(msg, charsmax(msg), message, 5);
  310.     new param;
  311.     if (!cid) return;
  312.     else param = cid;
  313.     new team[32];
  314.     get_user_team(param, team, 31);
  315.     switch (color)
  316.     {
  317.         case 0: msg_teaminfo(param, team);
  318.         case 1: msg_teaminfo(param, "TERRORIST");
  319.         case 2: msg_teaminfo(param, "CT");
  320.         case 3: msg_teaminfo(param, "SPECTATOR");
  321.     }
  322.    
  323.     if(id) msg_saytext(id, param, msg);
  324.     else msg_saytext(0, param, msg);
  325.     if (color != 0) msg_teaminfo(param, team);
  326. }
  327.  
  328. msg_saytext(id, cid, msg[])
  329. {
  330.     message_begin(id?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, id);
  331.     write_byte(cid);
  332.     write_string(msg);
  333.     message_end();
  334. }
  335.  
  336. msg_teaminfo(id, team[])
  337. {
  338.     message_begin(MSG_ONE, get_user_msgid("TeamInfo"), {0,0,0}, id);
  339.     write_byte(id);
  340.     write_string(team);
  341.     message_end();
  342. }
Add Comment
Please, Sign In to add comment