You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

75 lines
2.0 KiB

/* Plugin Template generated by Pawn Studio */
#include <sourcemod>
new Handle:h_enabled;
new bool:enabled, health[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "Health 4 Ever (GOD MODE)",
author = "Chefe",
description = "Give Health (GODMODE)",
version = "1.3",
url = "www.sourcemod.net"
}
public OnPluginStart()
{
HookEvent("player_hurt", Event_PlayerHurt);
HookEvent("player_spawn", Event_PlayerSpawn);
h_enabled = CreateConVar("sm_god_enabled", "1", "Enable or Disable Health for Admins.");
AutoExecConfig(true);
CreateTimer(1.0, Timer_RefillClip, _, TIMER_REPEAT);
enabled = GetConVarBool(h_enabled);
HookConVarChange(h_enabled, OnEnabledChange);
}
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new userid = GetEventInt(event, "userid");
new client = GetClientOfUserId(userid);
health[client] = GetClientHealth(client);
}
public OnEnabledChange(Handle:cvar, const String:oldVal[], const String:newVal[])
{
enabled = !!StringToInt(String:newVal);
}
public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new client_userid = GetEventInt(event, "userid");
new client = GetClientOfUserId(client_userid);
new AdminId:client_admin = GetUserAdmin(client);
new damage = GetEventInt(event, "health");
if (IsClientInGame(client) && enabled && IsPlayerAlive(client) && !IsFakeClient(client))
{
SetEntData(client, FindDataMapOffs(client, "m_iMaxHealth"), health[client], 4, true);
SetEntData(client, FindDataMapOffs(client, "m_iHealth"), health[client], 4, true);
PrintToChat(client, "\x01[\x04HR\x01] Blocked \x04%i\x01 damage!", (health[client]-damage));
}
}
public Action:Timer_RefillClip(Handle:timer)
{
for (new i = 1; i != GetMaxClients(); i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i))
{
RefillClip(i)
}
}
}
stock RefillClip(i)
{
new iWeapon = GetEntDataEnt2(i, FindSendPropInfo("CTFPlayer", "m_hActiveWeapon"));
SetEntData(iWeapon, FindSendPropInfo("CBaseCombatWeapon", "m_iClip1"), 500);
}