FlacoBey

Untitled

May 4th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.12 KB | None | 0 0
  1. #pragma semicolon 1
  2. #include <sourcemod>
  3. #pragma newdecls required
  4.  
  5. bool g_stop_event, g_stop_event2;
  6. Handle g_iEnable = null, g_iInterval = null, g_qInterval = null, g_iInterval2 = null, g_qInterval2 = null, g_iEnable_MissionLost = null;
  7. Handle g_Timer = null, g_Timer2 = null;
  8.  
  9. public void OnPluginStart()
  10. {
  11.     g_iEnable = CreateConVar("sm_enable_unlocked_tank","1", "0:Выкл. 1:Вкл.", FCVAR_NOTIFY);
  12.     g_iEnable_MissionLost = CreateConVar("sm_enable_mission_lost","1", "Вызвать танка если команда проиграла? 0:Выкл. 1:Вкл.", FCVAR_NOTIFY);
  13.  
  14.     g_iInterval = CreateConVar("sm_interval_1","90.0", "Первое рандомное время.",  FCVAR_NOTIFY);
  15.     g_qInterval = CreateConVar("sm_interval_2","180.0", "Второе рандомное время.", FCVAR_NOTIFY);
  16.  
  17.     g_iInterval2 = CreateConVar("sm_interval2_1","120.0", "Первое рандомное время.",  FCVAR_NOTIFY);
  18.     g_qInterval2 = CreateConVar("sm_interval2_2","240.0", "Второе рандомное время.", FCVAR_NOTIFY);
  19.  
  20.     HookEvent("player_left_checkpoint", EventPlayerHook);
  21.  
  22.     HookEvent("round_start", ResetBool);
  23.     HookEvent("round_end", ResetBool);
  24. }
  25.  
  26. public void EventPlayerHook(Event event, const char[] name, bool dontBroadcast)
  27. {
  28.     if (!GetConVarInt(g_iEnable))
  29.     {
  30.         if (g_stop_event)
  31.         {
  32.             if (g_Timer != null)
  33.             {
  34.                 delete(g_Timer);
  35.                 g_Timer = null;
  36.             }
  37.             g_Timer = CreateTimer(GetRandomInt(0, 1) ? GetConVarFloat(g_iInterval) : GetConVarFloat(g_qInterval), SpawnTank, _, TIMER_FLAG_NO_MAPCHANGE);
  38.             g_stop_event = true;
  39.         }
  40.            
  41.         if (g_stop_event2)
  42.         {
  43.             if (g_Timer2 != null)
  44.             {
  45.                 delete(g_Timer2);
  46.                 g_Timer2 = null;
  47.             }
  48.             g_Timer2 = CreateTimer(GetRandomInt(0, 1) ? GetConVarFloat(g_iInterval2) : GetConVarFloat(g_qInterval2), SpawnWitch, _, TIMER_FLAG_NO_MAPCHANGE);
  49.             g_stop_event2 = true;
  50.         }
  51.     }
  52. }
  53.  
  54. public void OnMapStart()
  55. {
  56.     g_stop_event = true;
  57.     g_stop_event2 = true;
  58.     g_Timer = null;
  59.     g_Timer2 = null;
  60.  
  61.     if (!IsModelPrecached("models/infected/hulk_dlc3.mdl"))
  62.     {
  63.         PrecacheModel("models/infected/hulk_dlc3.mdl", true);
  64.     }
  65. }
  66.  
  67. public void OnMapEnd()
  68. {
  69.     g_Timer = null;
  70.     g_Timer2 = null;
  71. }
  72.  
  73. public void ResetBool(Event event, const char[] name, bool dontBroadcast)
  74. {
  75.     if (!GetConVarInt(g_iEnable_MissionLost)) return;
  76.     {
  77.         g_stop_event = false;
  78.         g_stop_event2 = false;
  79.     }
  80. }
  81.  
  82. public Action SpawnTank(Handle timer)
  83. {
  84.     for (int i = 1; i <= MaxClients; ++i) if(IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
  85.     {
  86.         HxFakeCHEAT(i, "z_spawn_old", "tank auto");
  87.         break;
  88.     }
  89.    
  90.     g_Timer = null;
  91.     return Plugin_Stop;
  92. }
  93.  
  94. public Action SpawnWitch(Handle timer)
  95. {
  96.     for (int i = 1; i <= MaxClients; ++i) if(IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
  97.     {
  98.         HxFakeCHEAT(i, "z_spawn_old", "witch auto");
  99.         break;
  100.     }
  101.    
  102.     g_Timer2 = null;
  103.     return Plugin_Stop;
  104. }
  105.  
  106. void HxFakeCHEAT(int &client, const char[] sCmd, const char[] sArg)
  107. {
  108.     int iFlags = GetCommandFlags(sCmd);
  109.     SetCommandFlags(sCmd, iFlags & ~FCVAR_CHEAT);
  110.     FakeClientCommand(client, "%s %s", sCmd, sArg);
  111.     SetCommandFlags(sCmd, iFlags);
  112. }
Advertisement
Add Comment
Please, Sign In to add comment