Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #include <sdktools>
  2. #include <sdkhooks>
  3. #include <cstrike>
  4.  
  5. #pragma semicolon 1
  6. #pragma newdecls required
  7.  
  8. public Plugin myinfo = {
  9. name = "Regen HP for VIP + player",
  10. author = "shanapu",
  11. description = "Regen HP for VIP + player",
  12. version = "1.0",
  13. url = "github.com/shanapu"
  14. };
  15.  
  16. Handle g_hRegenTimer[MAXPLAYERS + 1];
  17.  
  18. ConVar g_Interval;
  19. ConVar g_MaxHPCT;
  20. ConVar g_MaxHPT;
  21. ConVar g_MaxHPCTVIP;
  22. ConVar g_MaxHPTVIP;
  23. ConVar g_Inc;
  24.  
  25. public void OnPluginStart()
  26. {
  27. AutoExecConfig(true, "regenHP", "sourcemod");
  28.  
  29. g_Interval = CreateConVar("regen_interval", "1.0");
  30. g_MaxHPCTVIP = CreateConVar("regen_maxhp_ct_VIP", "1250");
  31. g_MaxHPTVIP = CreateConVar("regen_maxhp_t_VIP", "250");
  32. g_MaxHPCT = CreateConVar("regen_maxhp_ct", "999");
  33. g_MaxHPT = CreateConVar("regen_maxhp_t", "100");
  34. g_Inc = CreateConVar("regen_inc", "10");
  35.  
  36. HookEvent("player_hurt", HookPlayerHurt);
  37. }
  38.  
  39. public void HookPlayerHurt(Event event, const char[] name, bool dontBroadcast)
  40. {
  41. int userid = event.GetInt("userid");
  42. int client = GetClientOfUserId(userid);
  43.  
  44. if(g_hRegenTimer[client] == INVALID_HANDLE)
  45. {
  46. g_hRegenTimer[client] = CreateTimer(g_Interval.FloatValue, Timer_Regenerate, userid, TIMER_REPEAT);
  47. }
  48. }
  49.  
  50. public Action Timer_Regenerate(Handle timer, int userid)
  51. {
  52. int client = GetClientOfUserId(userid);
  53. if (!client)
  54. return Plugin_Stop;
  55.  
  56. int ClientHealth = GetClientHealth(client);
  57. int TeamMax;
  58.  
  59. if (GetClientTeam(client) == CS_TEAM_CT)
  60. {
  61. if (CheckCommandAccess(client, "sm_respawnvip", ADMFLAG_CUSTOM6))
  62. {
  63. TeamMax = g_MaxHPCTVIP.IntValue;
  64. }
  65. else TeamMax = g_MaxHPCT.IntValue;
  66. }
  67. else
  68. {
  69. if (CheckCommandAccess(client, "sm_respawnvip", ADMFLAG_CUSTOM6))
  70. {
  71. TeamMax = g_MaxHPTVIP.IntValue;
  72. }
  73. else TeamMax = g_MaxHPT.IntValue;
  74. }
  75.  
  76. if(ClientHealth < TeamMax)
  77. {
  78. SetEntityHealth(client, ClientHealth + g_Inc.IntValue);
  79. }
  80. else
  81. {
  82. SetEntityHealth(client, TeamMax);
  83. g_hRegenTimer[client] = INVALID_HANDLE;
  84. KillTimer(timer);
  85. return Plugin_Stop;
  86. }
  87.  
  88. return Plugin_Continue;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement