Advertisement
FlacoBey

Untitled

Feb 3rd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.60 KB | None | 0 0
  1. #pragma semicolon 1
  2. #include <sourcemod>
  3. #include <sdktools>
  4.  
  5. char sMap[64];
  6. Handle Timers = null;
  7. ConVar hCount, hMin, hMax;
  8. int ghCount = 0;
  9.  
  10. new bool:isFinale = false;
  11. new bool:RestMap = false;
  12. new bool:isRoundStart = false;
  13.  
  14. public Plugin myinfo =
  15. {
  16.     name = "[L4D2] Spawn Tank",
  17.     author = "dr_lex & BHaType",
  18.     description = "Spawn Tank",
  19.     version = "0.1",
  20.     url = ""
  21. }
  22.  
  23. public void OnPluginStart()
  24. {
  25.     hCount = CreateConVar("sm_tank_count", "2", "Кол-во танков", FCVAR_NONE);
  26.     hMin = CreateConVar("sm_tank_min", "60.0", "Минимальное время спавна", FCVAR_NONE);
  27.     hMax = CreateConVar("sm_tank_max", "180.0", "Максимальное время спавна", FCVAR_NONE);
  28.     HookEvent("round_start", Event_RoundStart);
  29.     HookEvent("tank_spawn", skuka);
  30. }
  31.  
  32. public Action skuka(Event event, const char[] name, bool dontBroadcast)
  33. {
  34.     ghCount++;
  35. }
  36.  
  37. public OnMapStart()
  38. {
  39.     if (Timers != null)
  40.     {
  41.         CloseHandle(Timers);
  42.         Timers = null;
  43.     }
  44.    
  45.     isRoundStart = false;
  46.    
  47.     new FinaleEntity;
  48.     while ((FinaleEntity = FindEntityByClassname(FinaleEntity, "trigger_finale")) != -1)
  49.     {
  50.         isFinale = true;
  51.     }
  52.    
  53.     GetCurrentMap(sMap, sizeof(sMap));
  54.     if (StrContains(sMap, "c1m1_hotel", true) > 1)
  55.     {
  56.         RestMap = true;
  57.     }
  58.     else if(StrContains(sMap, "c2m1_highway", true) > 1)
  59.     {
  60.         RestMap = true;
  61.     }
  62.     else if(StrContains(sMap, "c3m1_plankcountry", true) > 1)
  63.     {
  64.         RestMap = true;
  65.     }
  66.     else if(StrContains(sMap, "c4m1_milltown_a", true) > 1)
  67.     {
  68.         RestMap = true;
  69.     }
  70.     else if(StrContains(sMap, "c5m1_waterfront", true) > 1)
  71.     {
  72.         RestMap = true;
  73.     }
  74.     else if(StrContains(sMap, "c6m1_riverbank", true) > 1)
  75.     {
  76.         RestMap = true;
  77.     }
  78.     else if(StrContains(sMap, "c7m1_docks", true) > 1)
  79.     {
  80.         RestMap = true;
  81.     }
  82.     else if(StrContains(sMap, "c8m1_apartment", true) > 1)
  83.     {
  84.         RestMap = true;
  85.     }
  86.     else if(StrContains(sMap, "c10m1_caves", true) > 1)
  87.     {
  88.         RestMap = true;
  89.     }
  90.     else if(StrContains(sMap, "c11m1_greenhouse", true) > 1)
  91.     {
  92.         RestMap = true;
  93.     }
  94.     else if(StrContains(sMap, "c13m1_alpinecreek", true) > 1)
  95.     {
  96.         RestMap = true;
  97.     }
  98.     else if(StrContains(sMap, "c6m2_bedlam", true) > 1)
  99.     {
  100.         RestMap = true;
  101.     }
  102.    
  103.     if(RestMap == false)
  104.     {
  105.         if(isFinale == false)
  106.         {
  107.             if(isRoundStart == true)
  108.             {
  109.                 if(ghCount <= GetConVarInt(hCount))
  110.                 {
  111.                     float TimerTank = GetRandomFloat(GetConVarFloat(hMin), GetConVarFloat(hMax));
  112.                     Timers = CreateTimer(TimerTank, SpawnTank, TIMER_REPEAT);
  113.                 }
  114.             }
  115.         }
  116.     }
  117. }
  118.  
  119. public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
  120. {
  121.     if (Timers != null)
  122.     {
  123.         CloseHandle(Timers);
  124.         Timers = null;
  125.     }
  126.     isRoundStart = true;
  127.     ghCount = 0;
  128. }
  129.  
  130. public Action SpawnTank(Handle timer)
  131. {
  132.     for (int i = 1; i <= MaxClients; ++i) if(IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
  133.     {
  134.         HxFakeCHEAT(i, "z_spawn_old", "tank auto");
  135.     }
  136.    
  137.     Timers = null;
  138.    
  139.     return Plugin_Stop;
  140. }
  141.  
  142. void HxFakeCHEAT(int &client, const char[] sCmd, const char[] sArg)
  143. {
  144.     int iFlags = GetCommandFlags(sCmd);
  145.     SetCommandFlags(sCmd, iFlags & ~FCVAR_CHEAT);
  146.     FakeClientCommand(client, "%s %s", sCmd, sArg);
  147.     SetCommandFlags(sCmd, iFlags);
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement