Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sdktools>
- #include <sdkhooks>
- #include <cstrike>
- #pragma semicolon 1
- #pragma newdecls required
- public Plugin myinfo = {
- name = "Regen HP for VIP + player",
- author = "shanapu",
- description = "Regen HP for VIP + player",
- version = "1.0",
- url = "github.com/shanapu"
- };
- Handle g_hRegenTimer[MAXPLAYERS + 1];
- ConVar g_Interval;
- ConVar g_MaxHPCT;
- ConVar g_MaxHPT;
- ConVar g_MaxHPCTVIP;
- ConVar g_MaxHPTVIP;
- ConVar g_Inc;
- public void OnPluginStart()
- {
- AutoExecConfig(true, "regenHP", "sourcemod");
- g_Interval = CreateConVar("regen_interval", "1.0");
- g_MaxHPCTVIP = CreateConVar("regen_maxhp_ct_VIP", "1250");
- g_MaxHPTVIP = CreateConVar("regen_maxhp_t_VIP", "250");
- g_MaxHPCT = CreateConVar("regen_maxhp_ct", "999");
- g_MaxHPT = CreateConVar("regen_maxhp_t", "100");
- g_Inc = CreateConVar("regen_inc", "10");
- HookEvent("player_hurt", HookPlayerHurt);
- }
- public void HookPlayerHurt(Event event, const char[] name, bool dontBroadcast)
- {
- int userid = event.GetInt("userid");
- int client = GetClientOfUserId(userid);
- if(g_hRegenTimer[client] == INVALID_HANDLE)
- {
- g_hRegenTimer[client] = CreateTimer(g_Interval.FloatValue, Timer_Regenerate, userid, TIMER_REPEAT);
- }
- }
- public Action Timer_Regenerate(Handle timer, int userid)
- {
- int client = GetClientOfUserId(userid);
- if (!client)
- return Plugin_Stop;
- int ClientHealth = GetClientHealth(client);
- int TeamMax;
- if (GetClientTeam(client) == CS_TEAM_CT)
- {
- if (CheckCommandAccess(client, "sm_respawnvip", ADMFLAG_CUSTOM6))
- {
- TeamMax = g_MaxHPCTVIP.IntValue;
- }
- else TeamMax = g_MaxHPCT.IntValue;
- }
- else
- {
- if (CheckCommandAccess(client, "sm_respawnvip", ADMFLAG_CUSTOM6))
- {
- TeamMax = g_MaxHPTVIP.IntValue;
- }
- else TeamMax = g_MaxHPT.IntValue;
- }
- if(ClientHealth < TeamMax)
- {
- SetEntityHealth(client, ClientHealth + g_Inc.IntValue);
- }
- else
- {
- SetEntityHealth(client, TeamMax);
- g_hRegenTimer[client] = INVALID_HANDLE;
- KillTimer(timer);
- return Plugin_Stop;
- }
- return Plugin_Continue;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement