Advertisement
nomy

Untitled

Oct 11th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.23 KB | None | 0 0
  1. #pragma semicolon 1
  2. #include <sourcemod>
  3. #include <sdkhooks>
  4. #include <sdktools>
  5. #include <cstrike>
  6. #include <basecomm>
  7. #include <hosties>
  8.  
  9. new Handle:timer = INVALID_HANDLE;
  10. new Handle:gH_Menu = INVALID_HANDLE;
  11. new bool:enabled;
  12. new bool:weaponlock = false;
  13. new iTimer;
  14. new iEnt;
  15. new String:EntityList[][] = {"func_door", "func_movelinear", "func_door_rotating"};
  16.  
  17. public OnPluginStart()
  18. {
  19.     RegAdminCmd("sm_ffd", FfdCommand, ADMFLAG_GENERIC, "JailBreak FriendlyFire Day Menu");
  20.     HookEvent("round_end", OnRoundEnd);
  21.     timer = CreateConVar("sm_jbffd_time", "40", "Seconds for teaming up and to get in position");
  22.    
  23.     gH_Menu = CreateMenu(MenuHandler);
  24.     SetMenuTitle(gH_Menu, "Weapon Selection Menu");
  25.     AddMenuItem(gH_Menu, "m4a1", "M4A1");
  26.     AddMenuItem(gH_Menu, "ak47", "AK47");
  27.     AddMenuItem(gH_Menu, "awp", "AWP");
  28.     AddMenuItem(gH_Menu, "p90", "P90");
  29.     AddMenuItem(gH_Menu, "m249", "M249");
  30.     AddMenuItem(gH_Menu, "mac10", "Mac10");
  31.     AddMenuItem(gH_Menu, "m3", "M3");
  32.     AddMenuItem(gH_Menu, "xm1014", "XM1014");
  33.     AddMenuItem(gH_Menu, "scout", "Scout");
  34.    
  35. }
  36.  
  37. public OnMapStart()
  38. {
  39.     if(enabled)
  40.     {
  41.         enabled = false;
  42.         weaponlock = false;
  43.         SetConVarInt(FindConVar("mp_friendlyfire"), 0);
  44.         //SetConVarInt(FindConVar("sm_hosties_lr"), 1);
  45.     }
  46. }
  47.  
  48. public Action:OnRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
  49. {
  50.     if(enabled)
  51.     {
  52.         enabled = false;
  53.         weaponlock = false;
  54.         SetConVarInt(FindConVar("mp_friendlyfire"), 0);
  55.         //SetConVarInt(FindConVar("sm_hosties_lr"), 1);
  56.         PrintToChatAll("\x04JailBreak FriendlyFire Day has ended.");
  57.     }
  58. }
  59.  
  60. public Action:Timer_Delay(Handle:hTimer, any:data)
  61. {
  62.     if(timer)
  63.     {
  64.         if(iTimer == 0)
  65.         {
  66.             if(!enabled)
  67.             {
  68.                 return Plugin_Stop;
  69.             }
  70.             else
  71.             {
  72.                 weaponlock = false;
  73.                 PrintToChatAll("\x04Weapons are now UNLOCKED!");
  74.                 PrintCenterTextAll("Weapons are now UNLOCKED!");
  75.                 SetConVarInt(FindConVar("mp_friendlyfire"), 1);
  76.                 return Plugin_Stop;
  77.             }
  78.         }
  79.         else
  80.         {
  81.             if(!enabled)
  82.             {
  83.                 return Plugin_Stop;
  84.             }
  85.             else
  86.             {
  87.                 iTimer--;
  88.                 PrintCenterTextAll("You have %02i seconds to team up and get in position.", iTimer % 60);
  89.                 return Plugin_Continue;
  90.             }
  91.         }
  92.     }
  93.     return Plugin_Stop;
  94. }
  95.  
  96.  
  97. public Action:FfdCommand(client, args)
  98. {
  99.     if(GetClientTeam(client) == CS_TEAM_CT)
  100.     {
  101.         new Handle:FFD = CreateMenu(MenuHandler_FFD);
  102.         SetMenuTitle(FFD, "FriendlyFire Day:");
  103.         AddMenuItem(FFD, "on", "Enable");
  104.         AddMenuItem(FFD, "off", "Disable");
  105.         DisplayMenu(FFD, client, MENU_TIME_FOREVER);
  106.     }
  107.     else
  108.     {
  109.         PrintToChat(client, "\x04This command is reserved for CT Admins.");
  110.     }
  111.     return Plugin_Handled;
  112. }
  113.  
  114. public MenuHandler_FFD(Handle:FFD, MenuAction:action, iClient, iMenuItem)
  115. {
  116.     if(action == MenuAction_Select)
  117.     {
  118.         switch (iMenuItem)
  119.         {
  120.             case 0:
  121.             {
  122.                 if(enabled)
  123.                 {
  124.                     PrintToChat(iClient, "\x04JailBreak FriendlyFire Day is already enabled.");
  125.                 }
  126.                 else
  127.                 {
  128.                     iTimer = GetConVarInt(FindConVar("sm_jbffd_time"));
  129.                     enabled = true;
  130.                     weaponlock = true;
  131.                     OpenCells();
  132.                     UnmuteAlive();
  133.                     //SetConVarInt(FindConVar("sm_hosties_lr"), 0);
  134.                     PrintToChatAll("\x04%N has started JailBreak FriendlyFire Day.", iClient);
  135.                     CreateTimer(1.0, Timer_Delay, _, TIMER_REPEAT);
  136.                     ServerCommand("sm_hp @ct 250");
  137.                     for(new i = 1; i < MaxClients; i++)
  138.                     {
  139.                         CreateTimer(2.0, GiveWeapons, i, TIMER_FLAG_NO_MAPCHANGE);
  140.                     }
  141.                 }
  142.             }
  143.             case 1:
  144.             {
  145.                 if(enabled)
  146.                 {
  147.                     enabled = false;
  148.                     weaponlock = false;
  149.                     //SetConVarInt(FindConVar("sm_hosties_lr"), 1);
  150.                     SetConVarInt(FindConVar("mp_friendlyfire"), 0);
  151.                     PrintToChatAll("\x04%N has stopped JailBreak FriendlyFire Day.", iClient);
  152.                 }
  153.                 else
  154.                 {
  155.                     PrintToChat(iClient, "\x04JailBreak FriendlyFire Day is already disabled.");
  156.                 }
  157.             }
  158.         }
  159.     }
  160.     else if(action == MenuAction_End)
  161.     {
  162.         CloseHandle(FFD);
  163.     }
  164. }
  165.  
  166. public Action:OpenCells()
  167. {
  168.     for(new i = 0; i < sizeof(EntityList); i++)
  169.     while((iEnt = FindEntityByClassname(iEnt, EntityList[i])) != -1)
  170.     AcceptEntityInput(iEnt, "Open");
  171. }
  172.  
  173. public MenuHandler(Handle:menu, MenuAction:action, client, param2)
  174. {
  175.     if(action == MenuAction_Select)
  176.     {
  177.         if(IsPlayerAlive(client))
  178.         {
  179.             decl String:selection[64];
  180.             decl String:selectiondisp[64];
  181.             GetMenuItem(menu, param2, selection, sizeof(selection), _, selectiondisp, sizeof(selectiondisp));
  182.            
  183.             decl String:buffer[64];
  184.             Format(buffer, sizeof(buffer), "weapon_%s", selection);
  185.             GivePlayerItem(client, buffer);
  186.             PrintToChat(client, "You were given %s, team up and get in position!", selectiondisp);
  187.         }
  188.     }
  189. }
  190.  
  191. stock UnmuteAlive()
  192. {
  193.     for(new i = 1; i <= MaxClients; i++)
  194.     {
  195.         if (IsClientInGame(i) && IsPlayerAlive(i)) // if player is in game and alive
  196.         {
  197.             if (!BaseComm_IsClientMuted(i))
  198.             {
  199.                 UnmutePlayer(i);
  200.             }
  201.         }
  202.     }
  203. }
  204.  
  205. public Action:GiveWeapons(Handle:htimer, any:client)
  206. {
  207.     if(enabled && IsClientInGame(client) && IsPlayerAlive(client))
  208.     {
  209.         GivePlayerItem(client, "weapon_deagle");
  210.         DisplayMenu(gH_Menu, client, 0);
  211.     }
  212.     return Plugin_Handled;
  213. }
  214.  
  215. public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
  216. {
  217.     if(buttons & IN_ATTACK && enabled && weaponlock)
  218.     {
  219.         buttons &= ~IN_ATTACK;
  220.     }
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement