Guest User

Untitled

a guest
Jan 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.81 KB | None | 0 0
  1. public Action:timerMainTimer(Handle:timer)
  2. {
  3.     if(g_bEscapeStarted)
  4.     {
  5.         decl String:map[256];
  6.         GetCurrentMap(map, sizeof(map));
  7.         if(StrEqual(map, "c5m5_bridge"))
  8.         {
  9.             if(!g_bCreateChopperWaitTime)
  10.             {
  11.                 g_bCreateChopperWaitTime = true;
  12.                 g_iTimeLeft = 120;
  13.             }
  14.         }
  15.         else
  16.         {
  17.             DebugToClient("\x04[DEBUG] \x01Timer is not necessary anymore, killing");
  18.             g_iTimeLeft = GetMapTime();
  19.             return Plugin_Stop;
  20.         }
  21.     }
  22.     if(!g_bShouldAddTimer || !g_bShowTimer)
  23.     {
  24.         DebugToClient("\x04[DEBUG] \x01Timer is not necessary anymore, killing");
  25.         g_iTimeLeft = GetMapTime();
  26.         return Plugin_Stop;
  27.     }
  28.     if(g_iTimeLeft <= 0)
  29.     {
  30.         DebugToClient("\x04[DEBUG] \x01The finale timed out, triggering escape");
  31.         g_iTimeLeft = GetMapTime();
  32.         ForceEscapeStart();
  33.         return Plugin_Stop;
  34.     }
  35.     if(GetSurvivorsCount() <= 0)
  36.     {
  37.         DebugToClient("\x04[DEBUG] \x01No survivors alive, canceling timer");
  38.         return Plugin_Stop;
  39.     }
  40.     if(g_iGameVer == 2)
  41.     {
  42.         decl String:map[256];
  43.         GetCurrentMap(map, sizeof(map));
  44.         if(StrEqual(map, "c7m3_port"))
  45.         {
  46.             if(g_iGeneratorCount < 3)
  47.             {
  48.                 DebugToClient("\x04[DEBUG] \x01Cannot continue finale, generators needed");
  49.                 PrintHintTextToAll("ALL GENERATORS MUST BE ACTIVATED TO CONTINUE THE FINALE!");
  50.                 return Plugin_Continue;
  51.             }
  52.         }
  53.         if(StrEqual(map, "c2m5_concert"))
  54.         {
  55.             if(g_iTimeLeft == 240)
  56.             {
  57.                 CheatCommand(_, "ent_fire", "tank1_music playsound");
  58.                 CheatCommand(_, "ent_fire", "arch_beams_relay Trigger");
  59.                 CheatCommand(_, "ent_fire", "side_beams_relay Trigger");
  60.                 CheatCommand(_, "ent_fire", "arch_side_beams_start_counter Kill");
  61.                 CheatCommand(_, "ent_fire", "stage_lights_dim_relay Trigger");
  62.             }
  63.             if(g_iTimeLeft == 237)
  64.             {
  65.                 CheatCommand(_, "ent_fire", "arch_beams_stop_relay Trigger");
  66.                 CheatCommand(_, "ent_fire", "side_beams_off_relay Trigger");
  67.                 CheatCommand(_, "ent_fire", "arch_side_beams_stop_counter Kill");
  68.             }
  69.             if(g_iTimeLeft == 234)
  70.             {
  71.                 CheatCommand(_, "ent_fire", "stage_lastsong_relay Trigger");
  72.             }
  73.             if(g_iTimeLeft == 140)
  74.             {
  75.                 CheatCommand(_, "ent_fire", "mic_spotlights_relay Trigger");
  76.                 CheatCommand(_, "ent_fire", "arch_side_miclights_start_counter Kill");
  77.                 CheatCommand(_, "ent_fire", "stage_lights_dim_relay Trigger");
  78.             }
  79.             if(g_iTimeLeft == 120)
  80.             {
  81.                 CheatCommand(_, "ent_fire", "arch_side_fireworks_start_counter Kill");
  82.                 CheatCommand(_, "ent_fire", "fireworks_relay Trigger");
  83.                 CheatCommand(_, "ent_fire", "tank2_music PlaySound");
  84.             }
  85.         }
  86.         if(RequireTanks() && GetTankCount() > 0 && IsCooperativeGameMode())
  87.         {
  88.             PrintHintTextToAll("THE RESCUE VEHICLE CANNOT ARRIVE WITH TANKS AROUND!");
  89.             return Plugin_Continue;
  90.         }
  91.     }
  92.    
  93.     if(!g_bDestroy)
  94.     {
  95.         DebugToClient("Detected HoldOut Finale");
  96.         new iTimePassed = GetMapTime() - g_iTimeLeft;
  97.         DebugToClient("Time Left: %i, Time Passed: %i", g_iTimeLeft, iTimePassed);
  98.         if(iTimePassed > GetMapTime()/4)
  99.         {
  100.             DebugToClient("25% of the time reached, scores will be modified now");
  101.             new Percent = RoundFloat(((iTimePassed*1.0)/GetMapTime())*100);
  102.             DebugToClient("The percent of the finale done is: %i%%", Percent);
  103.             if(g_iGameVer == 2)
  104.             {
  105.                 DebugToClient("Detected Left 4 Dead 2");
  106.                 new NeededTotalScore = RoundFloat(((1.0*GetMaxScore())*Percent)/100);
  107.                 DebugToClient("NeededTotalScore: %i | CS(1): %i | CS(2): %i | CS(3): %i", NeededTotalScore, SDKCall(sdkGetTeamScore, 1, 0), SDKCall(sdkGetTeamScore, 2, 0), SDKCall(sdkGetTeamScore, 3, 0));
  108.                 new ScorePerChar = RoundFloat(NeededTotalScore/(4*1.0));
  109.                 if(g_iTimeLeft == GetMapTime()/2 || g_iTimeLeft == GetMapTime()/4)
  110.                 {
  111.                     if(RequireTanks())
  112.                     {
  113.                         ForceTankSpawn();
  114.                     }
  115.                 }
  116.                 if(SDKCall(sdkGetTeamScore, 1, 0) <= 0)
  117.                 {
  118.                     if(SDKCall(sdkGetTeamScore, 2, 0) <= NeededTotalScore)
  119.                     {
  120.                         for(new i = 0; i <= 3; i++)
  121.                         {
  122.                             DebugToClient("\x04[DEBUG] \x01 IsMainDeath(%i, 2) -> %b", i, IsMainDeath(i, 2));
  123.                             if(!IsMainDeath(i, 2))
  124.                             {
  125.                                 SDKCall(sdkSetCharScore, i, 2, ScorePerChar);
  126.                             }
  127.                         }
  128.                     }
  129.                 }
  130.                 else if(SDKCall(sdkGetTeamScore, 2, 0) <= 0)
  131.                 {
  132.                     if(SDKCall(sdkGetTeamScore, 1, 0) <= NeededTotalScore)
  133.                     {
  134.                         for(new i = 0; i <= 3; i++)
  135.                         {
  136.                             DebugToClient("\x04[DEBUG] \x01 IsMainDeath(%i, 2) -> %b", i, IsMainDeath(i, 2));
  137.                             if(!IsMainDeath(i, 2))
  138.                             {
  139.                                 SDKCall(sdkSetCharScore, i, 2, ScorePerChar);
  140.                             }
  141.                         }
  142.                     }
  143.                 }
  144.             }
  145.         }
  146.         if(g_iTimeLeft == 60)
  147.         {
  148.             ClientCommandAll("music_dynamic_play Event.ApproachingScavengeRoundWin");
  149.             ClientCommandAll("play music/scavenge/gascanofvictory");
  150.             PrintToChatAll("\x0460 seconds left!");
  151.         }
  152.     }
  153.     else
  154.     {
  155.         if(g_iTimeLeft == 25)
  156.         {
  157.             ClientCommandAll("play music/terror/clingingtohell4.wav");
  158.         }
  159.         if(g_iTimeLeft == 15)
  160.         {
  161.             ClientCommandAll("play music/terror/iamsocold.wav");
  162.         }
  163.     }
  164.     new iMinutes = g_iTimeLeft/60;
  165.     new iSeconds = g_iTimeLeft%60;
  166.     decl String:SurvMessage[256], String:InfMessage[256], String:sMinutes[5], String:sSeconds[5];
  167.     GetSurvivorMsg(SurvMessage, sizeof(SurvMessage));
  168.     GetInfectedMsg(InfMessage, sizeof(InfMessage));
  169.     if(iMinutes < 10 && iMinutes >= 0)
  170.     {
  171.         Format(sMinutes, sizeof(sMinutes), "0%d", iMinutes);
  172.     }
  173.     else
  174.     {
  175.         Format(sMinutes, sizeof(sMinutes), "%d", iMinutes);
  176.     }
  177.    
  178.     if(iSeconds < 10 && iSeconds >= 0)
  179.     {
  180.         Format(sSeconds, sizeof(sSeconds), "0%d", iSeconds);
  181.     }
  182.     else
  183.     {
  184.         Format(sSeconds, sizeof(sSeconds), "%d", iSeconds);
  185.     }
  186.     for(new i = 1; i <= MaxClients; i++)
  187.     {
  188.         if(IsValidEntity(i) && IsClientInGame(i) && !IsFakeClient(i))
  189.         {
  190.             if(GetClientTeam(i) == 3)
  191.             {
  192.                 PrintHintText(i, "%s %s:%s", InfMessage, sMinutes, sSeconds);
  193.             }
  194.             else
  195.             {
  196.                 PrintHintText(i, "%s %s:%s", SurvMessage, sMinutes, sSeconds);
  197.             }
  198.         }
  199.     }
  200.     g_iTimeLeft--;
  201.     return Plugin_Continue;
  202. }
Add Comment
Please, Sign In to add comment