Advertisement
FlacoBey

Untitled

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