Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.49 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. #pragma semicolon   1
  5. #pragma newdecls required
  6.  
  7. public Plugin myinfo = {
  8.     name = "Hard Spawns Survival",
  9.     author = "Gravity",
  10.     description = "no",
  11.     version = "1.0",
  12.     url = ""
  13. };
  14.  
  15. public void OnPluginStart()
  16. {
  17.     HookEvent("survival_round_start", Event_SurvStart, EventHookMode_Pre);
  18.     HookEvent("round_start", Event_OnRoundInit, EventHookMode_Pre);
  19.    
  20.     SetConvars();
  21.     AddCommandListener(Listener_Idle, "go_away_from_keyboard");
  22. }
  23.  
  24. public void OnPluginEnd()
  25. {
  26.     ResetConvars();
  27. }
  28.  
  29. public void OnMapStart()
  30. {
  31.     SetConvars();
  32. }
  33.  
  34. public void OnClientPutInServer(int client)
  35. {
  36.     if (IsFakeClient(client))
  37.     {
  38.         return;
  39.     }
  40.     if(client && IsClientInGame(client))
  41.     {
  42.         CreateTimer(5.0, Timer_PrintHelpMessage, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
  43.     }
  44. }
  45.  
  46. public Action Timer_PrintHelpMessage(Handle timer, any data)
  47. {
  48.     int client = GetClientOfUserId(data);
  49.     if(client && IsClientInGame(client))
  50.     {
  51.         PrintHelpMesssage(client);
  52.         PrintToChat(client, "\x03Hard Spawns survival\x01 loaded.");
  53.     }
  54. }
  55.  
  56. void PrintHelpMesssage(int client)
  57. {
  58.     PrintToConsole(client, "");
  59.     PrintToConsole(client, "|--------------------------------------------------------------------|");
  60.     PrintToConsole(client, "|                       Hard Spawns survival                         |");
  61.     PrintToConsole(client, "|--------------------------------------------------------------------|");
  62.     PrintToConsole(client, "| Changes:                                                           |");
  63.     PrintToConsole(client, "| - Spawns wont shut down.                                           |");
  64.     PrintToConsole(client, "| - SI wont get stuck.                                               |");
  65.     PrintToConsole(client, "| - SI spawning intervals slightly decreased.                        |");
  66.     PrintToConsole(client, "| - Spawning rules changed, infected can spawn nearly everywhere.    |");
  67.     PrintToConsole(client, "|--------------------------------------------------------------------|");
  68. }
  69.  
  70. public Action Listener_Idle(int client, const char[] command, int argc)
  71. {
  72.     PrintToChat(client, "Idle not allowed.");
  73.     return Plugin_Handled;
  74. }
  75.  
  76. public void Event_OnRoundInit(Event event, const char[] name, bool dontBroadcast)
  77. {
  78.     // Prevent some of spawn shutdowns caused by team switching or disconnects
  79.     SetConVarInt(FindConVar("z_spawn_range"), 10);
  80. }
  81.  
  82. public void Event_SurvStart(Event event, const char[] name, bool dontBroadcast)
  83. {
  84.     // Spawn range has to be reset
  85.     ResetConVar(FindConVar("z_spawn_range"));
  86.    
  87.     CreateNavPointerEntity();
  88. }
  89.  
  90. /*
  91.  *  Creates a point_nav_attribute_region entity which affects the whole map and enables a lot of additional spawns.
  92.  *  Sets two flags aka navmesh attributes:
  93.  *  Battlefield - General tag
  94.  *  Not clearable - The area is not clearable.
  95. */
  96. void CreateNavPointerEntity()
  97. {
  98.     float fMins[3], fMaxs[3];
  99.     char sMins[64], sMaxs[64];
  100.     GetEntPropVector(0, Prop_Data, "m_WorldMaxs", fMaxs);
  101.     GetEntPropVector(0, Prop_Data, "m_WorldMins", fMins);
  102.    
  103.     Format(sMins, sizeof(sMins), "%f %f %f", fMins[0], fMins[1], fMins[2]);
  104.     Format(sMaxs, sizeof(sMaxs), "%f %f %f", fMaxs[0], fMaxs[1], fMaxs[2]);
  105.    
  106.     int iEntity = CreateEntityByName("point_nav_attribute_region");
  107.     if(IsValidEdict(iEntity))
  108.     {
  109.         DispatchKeyValue(iEntity, "spawnflags", "1280");
  110.         DispatchKeyValue(iEntity, "maxs", sMaxs);
  111.         DispatchKeyValue(iEntity, "mins", sMins);
  112.         DispatchSpawn(iEntity);
  113.     }
  114. }
  115.  
  116. void ResetConvars()
  117. {
  118.     SetConVarBool(FindConVar("z_dont_clear"), false);
  119.     ResetConVar(FindConVar("z_discard_range"));
  120.     ResetConVar(FindConVar("z_spawn_range"));
  121.     ResetConVar(FindConVar("survival_special_spawn_interval"));
  122.     ResetConVar(FindConVar("survival_special_stage_interval"));
  123.     ResetConVar(FindConVar("director_special_respawn_interval"));
  124.     ResetConVar(FindConVar("survival_max_specials"));
  125.     ResetConVar(FindConVar("director_afk_timeout"));
  126. }
  127.  
  128. // Some of these SI limits are probably overriden by director vscripts etc.
  129. void SetConvars()
  130. {
  131.     SetConVarBool(FindConVar("z_dont_clear"), true);                    // Dont allow spawn clearing
  132.     SetConVarInt(FindConVar("z_discard_range"), 999999);                // dont slay distant SI
  133.     SetConVarInt(FindConVar("survival_special_spawn_interval"), 3);
  134.     SetConVarInt(FindConVar("survival_special_stage_interval"), 10);
  135.     SetConVarInt(FindConVar("director_special_respawn_interval"), 3);
  136.     SetConVarInt(FindConVar("survival_max_specials"),   20);            // Max SI alive at a time
  137.    
  138.     // AFK timeout
  139.     SetConVarInt(FindConVar("director_afk_timeout"), 9999);
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement