Advertisement
GiorTheLegend

LR Manager

Aug 25th, 2016
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 16.98 KB | None | 0 0
  1. /* TODO List:
  2. *   1. Add ShowInfo
  3. *   2. add selection to go to war
  4. *   3. Add stop lr + native
  5. *   4. Add infinate ammo to war
  6. *   5. Check No Scope
  7. *   6. Add hook and unhook to SDKHooks
  8. *   7. Give always knife so model wont fuck up and block where u cant use knife
  9. */
  10.  
  11. #pragma semicolon 1
  12.  
  13. #define DEBUG
  14.  
  15. #include <sourcemod>
  16. #include <sdktools>
  17. #include <cstrike>
  18. #include <sdkhooks>
  19. #include <smlib>
  20.  
  21. EngineVersion g_Game;
  22.  
  23. #define MOVES 5
  24. #define MAXBUTTONS 11
  25. #define MAX_BUTTONS 25
  26.  
  27. int g_LastButtons[MAXPLAYERS + 1];
  28. int ComboMoves[MOVES] = {0, ...};
  29. int PlayerPos[MAXPLAYERS + 1] = {0, ...};
  30.  
  31. //maybe enum
  32. // need defines whatever
  33. char sButtons[][] = { // maybe add walk
  34.     "Attack",
  35.     "Attack2",
  36.     "Jump",
  37.     "Duck",
  38.     "Forward",
  39.     "Back",
  40.     "Use",
  41.     "Moveleft",
  42.     "Moveright",
  43.     "Reload",
  44.     "Score"
  45. };
  46.  
  47. int Buttons[MAXBUTTONS] = {
  48.     IN_ATTACK,
  49.     IN_ATTACK2,
  50.     IN_JUMP,
  51.     IN_DUCK,
  52.     IN_FORWARD,
  53.     IN_BACK,
  54.     IN_USE,
  55.     IN_MOVELEFT,
  56.     IN_MOVERIGHT,
  57.     IN_RELOAD,
  58.     IN_SCORE
  59. };
  60.  
  61. enum LastRequest
  62. {
  63.     LR_DUEL = 0,
  64.     LR_S4S,
  65.     LR_GUNTOSS,
  66.     LR_POWERDEAGLE,
  67.     LR_COMBO,
  68.     LR_RAMBO
  69. };
  70.  
  71. #define MAXWEAPONS 7
  72.  
  73. enum WeaponInfo {
  74.     String:WeaponName[64],
  75.     String:WeaponClassname[64],
  76.     HP
  77. }
  78.  
  79. new Weapons[MAXWEAPONS][WeaponInfo] = {
  80.     { "Knife", "weapon_knife", 500 },
  81.     { "Deagle", "weapon_deagle", 700 },
  82.     { "M4A1", "weapon_m4a1", 1500},
  83.     { "AK-47", "weapon_ak47", 1500},
  84.     { "Nova", "weapon_nova", 1000},
  85.     { "Scout", "weapon_ssg08", 800},
  86.     { "AWP", "weapon_awp", 1000}
  87. };
  88.  
  89. #define MAXSWEAPONS 4
  90.  
  91. enum SWeaponInfo {
  92.     String:WeaponName[64],
  93.     String:WeaponClassname[64]
  94. }
  95.  
  96. new SWeapons[MAXSWEAPONS][SWeaponInfo] = {
  97.     { "Deagle", "weapon_deagle" },
  98.     { "P250", "weapon_p250" },
  99.     { "Nova", "weapon_nova"},
  100.     { "Scout [No Scope]", "weapon_ssg08" }
  101. };
  102.  
  103. //Integers
  104. LastRequest LRType;
  105. int Prisoner = 0;
  106. int Guard = 0;
  107. int PWep = 0;
  108. int GWep = 0;
  109. int DuelWep = 0;
  110.  
  111. //bool Gravity = false;
  112. //bool HP = false;
  113. //bool Speed = false;
  114. bool NoScope = false;
  115. bool Armor = false;
  116. //bool Jump = false;
  117. //bool HS = false;
  118.  
  119. //Bools
  120. bool IsActive = false;
  121.  
  122. //Natives
  123. //native int GetPlayerCash(id);
  124. //native int SetPlayerCash(id, amount);
  125.  
  126. public Plugin myinfo =
  127. {
  128.     name = "",
  129.     author = "Gior",
  130.     description = "",
  131.     version = "1.0",
  132.     url = ""
  133. };
  134.  
  135. public void OnPluginStart()
  136. {
  137.     g_Game = GetEngineVersion();
  138.     if(g_Game != Engine_CSGO && g_Game != Engine_CSS)
  139.     {
  140.         SetFailState("This plugin is for CSGO/CSS only.")
  141.     }
  142.    
  143.     AddCommandListener(BlockDrop, "drop");
  144.    
  145.     HookEvent("player_death", EventPlayerDeath, EventHookMode_Post);
  146.     HookEvent("weapon_fire", EventWeaponFire);
  147.     HookEvent("player_hurt", PlayerHurt);
  148.     HookEvent("round_end", RoundEnd);
  149.    
  150.     RegConsoleCmd("sm_lr", LRMenu);
  151. }
  152.  
  153. public Action BlockDrop(int id, const char[] command, int argc)
  154. {
  155.     if(IsActive)
  156.     {
  157.         if(id == Prisoner || id == Guard)
  158.         {
  159.             switch(LRType)
  160.             {
  161.                 case LR_S4S, LR_POWERDEAGLE, LR_DUEL:return Plugin_Handled;
  162.             }
  163.         }
  164.     }
  165.    
  166.     return Plugin_Continue;
  167. }
  168.  
  169. public OnClientPutInServer(id)
  170. {
  171.     SDKHook(id, SDKHook_WeaponCanUse, WeaponCanUse);
  172. }
  173.  
  174. public Action WeaponCanUse(id, wep)
  175. {
  176.     if(IsActive)
  177.     {
  178.         if(id == Prisoner || id == Guard)
  179.         {
  180.             switch(LRType)
  181.             {
  182.                 case LR_S4S, LR_DUEL, LR_POWERDEAGLE:return Plugin_Handled;
  183.             }
  184.         }
  185.     }
  186.    
  187.     return Plugin_Continue;
  188. }
  189.  
  190. public Action LRMenu(id, args) // TODO: maybe put all in one line, why to give so much information?
  191. {
  192.     if(!IsClientInGame(id))
  193.         return;
  194.    
  195.     if(!IsPlayerAlive(id))
  196.     {
  197.         PrintToChat(id, "You must be Alive to use Last Request!");
  198.         return;
  199.     }
  200.    
  201.     else if(GetClientTeam(id) != CS_TEAM_T)
  202.     {
  203.         PrintToChat(id, "You must be a Prisoner to use Last Request!");
  204.         return;
  205.     }
  206.        
  207.     else if(IsActive)
  208.     {
  209.         PrintToChat(id, "There is already an Active Last Request!");
  210.         return;
  211.     }
  212.    
  213.     else if(GetAliveTerror() > 1)
  214.     {
  215.         PrintToChat(id, "There are %d Prisoners left before you can use Last Request!", (GetAliveTerror() - 1));
  216.         return;
  217.     }
  218.    
  219.     else if(GetAliveTerror() != 1)
  220.     {
  221.         PrintToChat(id, "There are no Alive Prisoners!");
  222.         return;
  223.     }
  224.    
  225.     else if(GetAliveCT() <= 0)
  226.     {
  227.         PrintToChat(id, "There are no Alive Guards!");
  228.         return;
  229.     }
  230.    
  231.     Handle menu = CreateMenu(LRMenuHandler);
  232.     SetMenuTitle(menu, "Choose a Last Request:");
  233.    
  234.     AddMenuItem(menu, "duel", "Duels [High HP]");
  235.     AddMenuItem(menu, "s4s", "Shot4Shot");
  236.     AddMenuItem(menu, "gt", "Gun Toss");
  237.     AddMenuItem(menu, "pd", "Power Deagle");
  238.     AddMenuItem(menu, "cc", "Combo Contest");
  239.     AddMenuItem(menu, "ra", "Rambo Mode");
  240.    
  241.     DisplayMenu(menu, id, MENU_TIME_FOREVER);
  242. }
  243.  
  244. public LRMenuHandler(Menu menu, MenuAction action, int id, int pos)
  245. {
  246.     if(action == MenuAction_Select)
  247.     {
  248.         char info[16];
  249.         GetMenuItem(menu, pos, info, 16);
  250.        
  251.         if(StrEqual(info, "duel"))
  252.         {
  253.             LRType = LR_DUEL;
  254.             ChooseWeapon(id);
  255.         }
  256.        
  257.         else if(StrEqual(info, "s4s"))
  258.         {
  259.             LRType = LR_S4S;
  260.             ChooseWeapon(id);
  261.         }
  262.        
  263.         else if(StrEqual(info, "gt"))
  264.         {
  265.             LRType = LR_GUNTOSS;
  266.             ChooseGuard(id);
  267.         }
  268.        
  269.         else if(StrEqual(info, "pd"))
  270.         {
  271.             LRType = LR_POWERDEAGLE;
  272.             ChooseGuard(id);
  273.         }
  274.        
  275.         else if(StrEqual(info, "cc"))
  276.         {
  277.             LRType = LR_COMBO;
  278.             ChooseGuard(id);
  279.         }
  280.        
  281.         else if(StrEqual(info, "ra"))
  282.         {
  283.             LRType = LR_RAMBO;
  284.             Prisoner = id;
  285.             InitiateLR();
  286.         }
  287.        
  288.         //TODO: maybe LRType = LastRequest:pos
  289.        
  290.         //ChooseGuard(id); // TODO: Add here if pos != rebel, then menu
  291.     }
  292.    
  293.     else if(action == MenuAction_End)
  294.         CloseHandle(menu);
  295. }
  296.  
  297. ChooseWeapon(id)
  298. {
  299.     if(GetAliveCT() <= 0 || GetAliveTerror() != 1 || IsActive)
  300.     {
  301.         PrintToChat(id, "You can't use LR now!");
  302.         return;
  303.     }
  304.    
  305.     Handle menu = CreateMenu(WeaponsHandler);
  306.     SetMenuTitle(menu, "Choose a Weapon for the %s:", LRType == LR_DUEL ? "Duel" : "Shot4Shot");
  307.    
  308.     char temp[5];
  309.    
  310.     if(LRType == LR_DUEL)
  311.     {
  312.         for (int i = 0; i < MAXWEAPONS; i++)
  313.         {
  314.             Format(temp, 5, "%d", i);
  315.             AddMenuItem(menu, temp, Weapons[i][WeaponName]);
  316.         }
  317.     }
  318.    
  319.     else if(LRType == LR_S4S)
  320.     {
  321.         for (int i = 0; i < MAXSWEAPONS; i++)
  322.         {
  323.             Format(temp, 5, "%d", i);
  324.             AddMenuItem(menu, temp, SWeapons[i][WeaponName]);
  325.         }
  326.     }
  327.    
  328.     DisplayMenu(menu, id, MENU_TIME_FOREVER);
  329. }
  330.  
  331. public WeaponsHandler(Menu menu, MenuAction action, int id, int pos)
  332. {
  333.     if(action == MenuAction_Select)
  334.     {
  335.         char temp[5];
  336.         GetMenuItem(menu, pos, temp, 5);
  337.        
  338.         DuelWep = StringToInt(temp);
  339.        
  340.         if(LRType == LR_DUEL)
  341.             ChooseSettings(id);
  342.        
  343.         else if(LRType == LR_S4S)
  344.             ChooseGuard(id);
  345.     }
  346.    
  347.     else if(action == MenuAction_End)
  348.         CloseHandle(menu);
  349. }
  350.  
  351. ChooseSettings(id)
  352. {
  353.     if(GetAliveCT() <= 0 || GetAliveTerror() != 1 || IsActive)
  354.     {
  355.         PrintToChat(id, "You can't use LR now!");
  356.         return;
  357.     }
  358.    
  359.     Handle menu = CreateMenu(SettingsHandler);
  360.     SetMenuTitle(menu, "Choose Settings for the Duel:");
  361.    
  362.     char format[100];
  363.     Format(format, 100, "No Scope: %s\n\n", NoScope ? "On" : "Off");
  364.     AddMenuItem(menu, "noscope", format);
  365.    
  366.     Format(format, 100, "Armor: %s\n\n", Armor ? "On" : "Off");
  367.     AddMenuItem(menu, "armor", format);
  368.    
  369.     AddMenuItem(menu, "done", "Done!");
  370.    
  371.     DisplayMenu(menu, id, MENU_TIME_FOREVER);
  372. }
  373.  
  374. public SettingsHandler(Menu menu, MenuAction action, int id, int pos)
  375. {
  376.     if(action == MenuAction_Select)
  377.     {
  378.         char info[10];
  379.         GetMenuItem(menu, pos, info, 15);
  380.        
  381.         if (StrEqual(info, "noscope"))
  382.         {
  383.             NoScope = !NoScope;
  384.             ChooseSettings(id);
  385.         }
  386.        
  387.         else if(StrEqual(info, "armor"))
  388.         {
  389.             Armor = !Armor;
  390.             ChooseSettings(id);
  391.         }
  392.        
  393.         else if(StrEqual(info, "done"))
  394.         {
  395.             ChooseGuard(id);
  396.         }
  397.     }
  398.    
  399.     else if(action == MenuAction_End)
  400.         CloseHandle(menu);
  401. }
  402.  
  403. ChooseGuard(id)
  404. {
  405.     if(GetAliveCT() <= 0 || GetAliveTerror() != 1 || IsActive)
  406.     {
  407.         PrintToChat(id, "You can't use LR now!");
  408.         return;
  409.     }
  410.    
  411.     Handle menu = CreateMenu(CTMenuHandler);
  412.     SetMenuTitle(menu, "Choose a Guard:");
  413.    
  414.     char name[64];
  415.     char temp_id[5];
  416.    
  417.     for (int i = 1; i <= MaxClients; i++)
  418.     {
  419.         if(!IsValidClient(i, true) || !(GetClientTeam(i) == CS_TEAM_CT))
  420.             continue;
  421.            
  422.         Format(temp_id, 5, "%d", i);
  423.         GetClientName(i, name, 64);
  424.         AddMenuItem(menu, temp_id, name);
  425.     }
  426.    
  427.     DisplayMenu(menu, id, MENU_TIME_FOREVER);
  428.    
  429.     return;
  430. }
  431.  
  432. public CTMenuHandler(Menu menu, MenuAction action, int id, int pos)
  433. {
  434.     if(action == MenuAction_Select)
  435.     {
  436.         char temp_id[5];
  437.         GetMenuItem(menu, pos, temp_id, 5);
  438.         Prisoner = id;
  439.         Guard = StringToInt(temp_id);
  440.        
  441.         InitiateLR();
  442.     }
  443.    
  444.     else if(action == MenuAction_End)
  445.         CloseHandle(menu);
  446. }
  447.        
  448.  
  449. InitiateLR()
  450. {
  451.     if(GetAliveCT() <= 0 || GetAliveTerror() != 1 || IsActive)
  452.     {
  453.         PrintToChatAll("You can't use LR now!");
  454.         return;
  455.     }
  456.    
  457.     Client_RemoveAllWeapons(Prisoner);
  458.     Client_RemoveAllWeapons(Guard);
  459.    
  460.     switch(LRType)
  461.     {
  462.         case LR_DUEL:
  463.         {
  464.             Entity_SetHealth(Prisoner, Weapons[DuelWep][HP], true);
  465.             Entity_SetHealth(Guard, Weapons[DuelWep][HP], true);
  466.            
  467.             if(Armor)
  468.             {
  469.                 Client_SetArmor(Prisoner, 1000);
  470.                 Client_SetArmor(Guard, 1000);
  471.             }
  472.            
  473.             PWep = GivePlayerItem(Prisoner, Weapons[DuelWep][WeaponClassname]);
  474.             GWep = GivePlayerItem(Guard, Weapons[DuelWep][WeaponClassname]);
  475.         }
  476.        
  477.         case LR_S4S:
  478.         {
  479.             Entity_SetHealth(Prisoner, 100, true);
  480.             Entity_SetHealth(Guard, 100, true);
  481.             PWep = GivePlayerItem(Prisoner, SWeapons[DuelWep][WeaponClassname]);
  482.             GWep = GivePlayerItem(Guard, SWeapons[DuelWep][WeaponClassname]);
  483.            
  484.             Weapon_SetClips(PWep, 1, 1);
  485.             Weapon_SetClips(GWep, 0, 0);
  486.            
  487.             SetEntProp(PWep, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
  488.             SetEntProp(GWep, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
  489.         }
  490.        
  491.         case LR_GUNTOSS:
  492.         {
  493.             Entity_SetHealth(Prisoner, 100, true);
  494.             Entity_SetHealth(Guard, 100, true);
  495.             PWep = GivePlayerItem(Prisoner, "weapon_deagle");
  496.             GWep = GivePlayerItem(Guard, "weapon_deagle");
  497.            
  498.             //Weapon_SetClips(PWep, 0, 0);
  499.             //Weapon_SetClips(GWep, 0, 0);
  500.             //
  501.             //SetEntProp(PWep, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
  502.             //SetEntProp(GWep, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
  503.         }
  504.        
  505.         case LR_POWERDEAGLE:
  506.         {
  507.             Entity_SetHealth(Prisoner, 500, true);
  508.             Entity_SetHealth(Guard, 500, true);
  509.             PWep = GivePlayerItem(Prisoner, "weapon_deagle");
  510.             GWep = GivePlayerItem(Guard, "weapon_deagle");
  511.         }
  512.        
  513.         case LR_COMBO:
  514.         {
  515.             for (int i = 0; i < MOVES; i++)
  516.             {
  517.                 ComboMoves[i] = Math_GetRandomInt(0, (MAXBUTTONS - 1));
  518.             }
  519.            
  520.             PlayerPos[Prisoner] = 0;
  521.             PlayerPos[Guard] = 0;
  522.             PrintHintText(Prisoner, "<u>%s</u> \n--><b><font color='#FF6666'>%s</font></b> \n%s", (PlayerPos[Prisoner] == 0) ? "Begin:" : "Continue:", sButtons[ComboMoves[PlayerPos[Prisoner]]], (PlayerPos[Prisoner] == (MOVES - 1)) ? "Done!" : sButtons[ComboMoves[PlayerPos[Prisoner] + 1]]);
  523.             PrintHintText(Guard, "<u>%s</u> \n--><b><font color='#FF6666'>%s</font></b> \n%s", (PlayerPos[Guard] == 0) ? "Begin:" : "Continue:", sButtons[ComboMoves[PlayerPos[Guard]]], (PlayerPos[Guard] == (MOVES - 1)) ? "Done!" : sButtons[ComboMoves[PlayerPos[Guard] + 1]]);
  524.         }
  525.        
  526.         case LR_RAMBO:
  527.         {
  528.             Entity_SetHealth(Prisoner, 50 + 100 * GetAliveCT(), true);
  529.             PWep = GivePlayerItem(Prisoner, "weapon_negev");
  530.         }
  531.     }
  532.    
  533.     IsActive = true;
  534.     ShowInfo();
  535. }
  536.  
  537. ShowInfo()
  538. {
  539.     PrintToChatAll(" \x10Last Request \x01has been \x04Activated\x01!");
  540.    
  541.     switch(LRType)
  542.     {
  543.         case LR_DUEL:
  544.         {
  545.             PrintToChatAll(" \x07%N \x01has started a \x06Duel \x01against \x0C%N \x01with \x08%s\x01!", Prisoner, Guard, Weapons[DuelWep][WeaponName]);
  546.             PrintToChatAll(" \x06No Scope \x01is %s", NoScope ? "\x04On" : "\x02Off");
  547.             PrintToChatAll(" \x06Armor \x01is %s", Armor ? "\x04On" : "\x02Off");
  548.             PrintToChatAll(" Fight till the Death!");
  549.         }
  550.        
  551.         case LR_S4S:
  552.         {
  553.             PrintToChatAll(" \x07%N \x01has started a \x06Shot4Shot \x01against \x0C%N \x01with \x08%s\x01!", Prisoner, Guard, SWeapons[DuelWep][WeaponName]);
  554.             PrintToChatAll(" Each one takes a shot at his turn.");
  555.         }
  556.        
  557.         case LR_GUNTOSS:
  558.         {
  559.             PrintToChatAll(" \x07%N \x01has started a \x06Gun Toss \x01against \x0C%N\x01!", Prisoner, Guard);
  560.             PrintToChatAll(" Longest toss will win.");
  561.         }
  562.        
  563.         case LR_POWERDEAGLE:
  564.         {
  565.             PrintToChatAll(" \x07%N \x01has started a \x06Power Deagle \x01against \x0C%N\x01!", Prisoner, Guard);
  566.             PrintToChatAll(" Fight till the Death!");
  567.         }
  568.        
  569.         case LR_COMBO:
  570.         {
  571.             PrintToChatAll(" \x07%N \x01has started a \x06Combo Contest \x01against \x0C%N\x01!", Prisoner, Guard);
  572.             PrintToChatAll(" First one to Complete the Combination will win!");
  573.         }
  574.        
  575.         case LR_RAMBO:
  576.         {
  577.             PrintToChatAll(" \x07%N \x01went \x06Rambo!", Prisoner);
  578.             PrintToChatAll(" Kill them all!");
  579.         }
  580.     }
  581.    
  582.     PrintToChatAll(" Winner will be Awarded!");
  583. }
  584.  
  585. public Action PlayerHurt(Handle event, char[] name, bool dontBroadcast)
  586. {
  587.     if(IsActive)
  588.     {
  589.         switch(LRType)
  590.         {
  591.             case LR_POWERDEAGLE:
  592.             {
  593.                 int id = GetClientOfUserId(GetEventInt(event, "userid"));
  594.                 int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  595.                
  596.                 if(id != attacker && IsClientInGame(id) && IsClientInGame(attacker) && (Prisoner == attacker || Prisoner == id) && (Guard == attacker || Guard == id))
  597.                 {
  598.                     //char weapon[64];
  599.                     //GetEventString(event, "weapon", weapon, 64);
  600.                     //StrEqual(weapon, "deagle");
  601.                    
  602.                     float vec[3];
  603.                    
  604.                     vec[0] = Math_GetRandomFloat(1.0, 1000.0);
  605.                     vec[1] = Math_GetRandomFloat(1.0, 1000.0);
  606.                     vec[2] = Math_GetRandomFloat(1.0, 1000.0);
  607.                    
  608.                     TeleportEntity(id, NULL_VECTOR, NULL_VECTOR, vec);
  609.                 }
  610.             }
  611.         }
  612.     }
  613. }
  614.  
  615. public Action EventWeaponFire(Handle event, char[] name, bool dontBroadcast)
  616. {
  617.     if(IsActive)
  618.     {
  619.         int id = GetClientOfUserId(GetEventInt(event, "userid"));
  620.        
  621.         if(id == Prisoner || id == Guard)
  622.         {
  623.             switch(LRType)
  624.             {
  625.                 case LR_S4S:
  626.                 {
  627.                     if(id == Prisoner)
  628.                         Weapon_SetClips(GWep, 1, 1);
  629.                    
  630.                     else if(id == Guard) //TODO: Not sure we need if here
  631.                         Weapon_SetClips(PWep, 1, 1);
  632.                 }
  633.             }
  634.         }
  635.     }
  636. }
  637.  
  638. public Action EventPlayerDeath(Handle event, char[] name, bool dontBroadcast)
  639. {
  640.     if(GetAliveTerror() == 1 && GetAliveCT() > 0)
  641.     {
  642.         int terror = Client_GetNext(CLIENTFILTER_NOBOTS | CLIENTFILTER_ALIVE | CLIENTFILTER_TEAMONE);
  643.         LRMenu(terror, 0);
  644.     }
  645.    
  646.     if(IsActive && LRType != LR_RAMBO) // TODO: add here if not rebel
  647.     {
  648.         int victim = GetClientOfUserId(GetEventInt(event, "userid"));
  649.        
  650.         if(victim == Prisoner || victim == Guard)
  651.         {
  652.             IsActive = false;
  653.             NoScope = false;
  654.             Armor = false;
  655.            
  656.             if(GetAliveTerror() == 1 && GetAliveCT() > 0)
  657.             {
  658.                 int terror = Client_GetNext(CLIENTFILTER_NOBOTS | CLIENTFILTER_ALIVE | CLIENTFILTER_TEAMONE);
  659.                 LRMenu(terror, 0);
  660.             }
  661.         }
  662.     }
  663. }
  664.  
  665. public Action RoundEnd(Handle event, char[] name, bool dontBroadcast)
  666. {
  667.     IsActive = false;
  668.     NoScope = false;
  669.     Armor = false;
  670. }
  671.  
  672. public Action OnPlayerRunCmd(id, &buttons)
  673. {
  674.     if(IsActive)
  675.     {
  676.         if(id == Prisoner || id == Guard)
  677.         {
  678.             switch(LRType)
  679.             {
  680.                 case LR_DUEL:
  681.                 {
  682.                     if(NoScope)
  683.                     {
  684.                         if(buttons & IN_ATTACK2)
  685.                             buttons &= ~IN_ATTACK2;
  686.                     }
  687.                 }
  688.                
  689.                 case LR_COMBO:
  690.                 {
  691.                     if(!(g_LastButtons[id] & buttons) && IsPressing(buttons))
  692.                     {
  693.                         if((buttons & Buttons[ComboMoves[PlayerPos[id]]]))
  694.                         {
  695.                             PlayerPos[id]++;
  696.                         }
  697.                        
  698.                         else
  699.                         {
  700.                             PrintToChat(id, "Wrong Button!");
  701.                             PlayerPos[id] = 0;
  702.                         }
  703.                        
  704.                         if(PlayerPos[id] >= MOVES)
  705.                         {
  706.                             PrintHintText(id, "You Won!");
  707.                            
  708.                             if(id == Prisoner)
  709.                             {
  710.                                 PrintHintText(Guard, "You Lost!");
  711.                                 ForcePlayerSuicide(Guard);
  712.                             }
  713.                            
  714.                             else if(id == Guard)
  715.                             {
  716.                                 PrintHintText(Prisoner, "You Lost!");
  717.                                 ForcePlayerSuicide(Prisoner);
  718.                             }
  719.                            
  720.                             IsActive = false;
  721.                         }
  722.                        
  723.                         else
  724.                         {
  725.                             PrintHintText(id, "<u>%s</u> \n--><b><font color='#FF6666'>%s</font></b> \n%s", (PlayerPos[id] == 0) ? "Begin:" : "Continue:", sButtons[ComboMoves[PlayerPos[id]]], (PlayerPos[id] == (MOVES - 1)) ? "Done!" : sButtons[ComboMoves[PlayerPos[id] + 1]]);
  726.                         }
  727.                     }
  728.                    
  729.                     g_LastButtons[id] = buttons;
  730.                 }
  731.             }
  732.         }
  733.     }
  734. }
  735.  
  736. public bool IsPressing(buttons)
  737. {
  738.     for(int i = 0; i < MAX_BUTTONS; i++)
  739.     {
  740.         if(buttons & (1 << i))
  741.         {
  742.             return true;
  743.         }
  744.     }
  745.    
  746.     return false;
  747. }
  748.  
  749. public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
  750. {
  751.    CreateNative("IsLRActive", Native_IsLRActive);
  752.    return APLRes_Success;
  753. }
  754.  
  755. public int Native_IsLRActive(Handle plugin, int numParams)
  756. {
  757.     return IsActive;
  758. }
  759.  
  760. stock int GetAliveTerror()
  761. {
  762.     int count = 0;
  763.    
  764.     for (int i = 1; i <= MaxClients; i++)
  765.     {
  766.         if(!IsValidClient(i) || (GetClientTeam(i) != CS_TEAM_T) || !IsPlayerAlive(i))
  767.             continue;
  768.        
  769.         count++;
  770.     }
  771.    
  772.     return count;
  773. }
  774.  
  775. stock int GetAliveCT()
  776. {
  777.     int count = 0;
  778.    
  779.     for (int i = 1; i <= MaxClients; i++)
  780.     {
  781.         if(!IsValidClient(i) || (GetClientTeam(i) != CS_TEAM_CT) || !IsPlayerAlive(i))
  782.             continue;
  783.        
  784.         count++;
  785.     }
  786.    
  787.     return count;
  788. }
  789.  
  790. stock bool IsValidClient(int client, bool bAlive = false)
  791. {
  792.     return (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (!bAlive || IsPlayerAlive(client)));
  793. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement