Advertisement
FlacoBey

Untitled

Feb 15th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.99 KB | None | 0 0
  1. #pragma semicolon 1
  2. #include <sourcemod>
  3. #include <sdktools_sound>
  4. #define PLUGIN_VERSION "1.0"
  5.  
  6.  
  7. public Plugin:myinfo =
  8. {
  9.     name = "Saferoom Naps: Spawn Next Map With 50 HP",
  10.     author = "ConnerRia",
  11.     description = "Prevent metagaming in harder gamemodes. If you have less than 50hp, spawn in saferooms with 50hp. ",
  12.     version = PLUGIN_VERSION,
  13.     url = "N/A"
  14. }
  15.  
  16. int iSurvivorRespawnHealth, iCustomSaferoomHealth, iUseCustomValue, iRemoveBlackAndWhite, iHealthToSet;
  17. ConVar hUseCustomValue, hCustomSaferoomHealth, hRemoveBlackAndWhite, hTempHealthMultiplier, hVeryHealthyTempHealthMultiplier;
  18. float fTempHealthMultiplier, fCurrentBufferHealth, fVeryHealthyTempHealthMultiplier;
  19.  
  20. public void OnPluginStart()
  21. {
  22.     decl String:game_name[64];
  23.     GetGameFolderName(game_name, sizeof(game_name));
  24.     if (!StrEqual(game_name, "left4dead2", false) && !StrEqual(game_name, "left4dead", false))
  25.     {      
  26.         SetFailState("Plugin supports Left 4 Dead series only.");
  27.     }
  28.    
  29.     CreateConVar("SafeRoomNaps_Version", PLUGIN_VERSION, "SafeRoomNaps Version", FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_DONTRECORD);
  30.    
  31.     hUseCustomValue = CreateConVar("SafeRoomNaps_CanWeUseCustomValue", "0", "Set to 1 if you want to input your own saferoom hp value. Uses the z_survivor_respawn_health value otherwise. Disabled by default.", FCVAR_NOTIFY|FCVAR_REPLICATED);
  32.     hCustomSaferoomHealth = CreateConVar("SafeRoomNaps_CustomSaferoomHealth", "50", "Not used unless hUseCustomValue is enabled. If your health is lower than the set value, it will be modified to that value when the next map loads. ", FCVAR_NOTIFY|FCVAR_REPLICATED);
  33.     hRemoveBlackAndWhite = CreateConVar("SafeRoomNaps_RemoveBlackAndWhite", "1.0", "Whether to remove black-and-white from players. Set to 0 to disable this feature. ", FCVAR_NOTIFY|FCVAR_REPLICATED);
  34.     hTempHealthMultiplier = CreateConVar("SafeRoomNaps_TempHealthMultiplier", "0.0", "Multiplier of buffer health (from incap revive, pain pills, adrenaline) to keep for low health players. Default is 0.0, which means temp health is not kept at all. A value of 1 means all buffer health is kept. ", FCVAR_NOTIFY|FCVAR_REPLICATED); 
  35.     hVeryHealthyTempHealthMultiplier = CreateConVar("SafeRoomNaps_VeryHealthyTempHealthMultiplier", "1.0", "Multiplier of buffer health to keep for high health players who have not been incapped.(those above 50 real hp or the set saferoom health value). Default is 1.0, which means all their temp health is kept.", FCVAR_NOTIFY|FCVAR_REPLICATED);
  36.    
  37.     AutoExecConfig(true, "SaferoomNaps");
  38.    
  39.     HookEvent("map_transition", Event_MapTransition, EventHookMode_Pre);
  40.    
  41. }
  42.  
  43. public Action: Event_MapTransition(Handle:event, const String:name[], bool:dontBroadcast)
  44. {  
  45.  
  46.     iCustomSaferoomHealth = hCustomSaferoomHealth.IntValue;
  47.     iUseCustomValue = hUseCustomValue.IntValue;
  48.     iSurvivorRespawnHealth = FindConVar("z_survivor_respawn_health").IntValue;
  49.     iRemoveBlackAndWhite = hRemoveBlackAndWhite.IntValue;
  50.     fTempHealthMultiplier = hTempHealthMultiplier.FloatValue;
  51.     fVeryHealthyTempHealthMultiplier = hVeryHealthyTempHealthMultiplier.FloatValue;
  52.    
  53.     if (iUseCustomValue == 1)
  54.     {
  55.         iHealthToSet = iCustomSaferoomHealth;
  56.     }
  57.     else
  58.     {
  59.         iHealthToSet = iSurvivorRespawnHealth;
  60.     }
  61.     for (new i = 1; i <= MaxClients; i++)
  62.     {
  63.         if (IsClientConnected(i) && GetClientTeam(i) == 2)
  64.         {
  65.             SetEntProp(i, Prop_Send, "m_iHideHUD", 64);
  66.             if (iRemoveBlackAndWhite == 1)
  67.             {
  68.             SetEntProp(i, Prop_Send, "m_currentReviveCount", 0);
  69.             SetEntProp(i, Prop_Send, "m_bIsOnThirdStrike", 0);
  70.             StopSound(i, SNDCHAN_AUTO, "player/heartbeatloop.wav");
  71.             }
  72.             if (GetClientHealth(i) < iHealthToSet)
  73.             {
  74.                 fCurrentBufferHealth = GetEntPropFloat(i, Prop_Send, "m_healthBuffer");
  75.                 SetEntPropFloat(i, Prop_Send, "m_healthBuffer", fCurrentBufferHealth * fTempHealthMultiplier);
  76.                 SetEntityHealth(i, iHealthToSet);
  77.             }
  78.             else
  79.             {
  80.                 fCurrentBufferHealth = GetEntPropFloat(i, Prop_Send, "m_healthBuffer");
  81.                 SetEntPropFloat(i, Prop_Send, "m_healthBuffer", fCurrentBufferHealth * fVeryHealthyTempHealthMultiplier);
  82.             }  
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement