Advertisement
FlacoBey

Untitled

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