Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define Damage 1.6
- public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
- {
- EngineVersion test = GetEngineVersion();
- if (test != Engine_Left4Dead && test != Engine_Left4Dead2) {
- strcopy(error, err_max, "Plugin only supports Left 4 Dead 1 & 2.");
- return APLRes_SilentFailure;
- }
- return APLRes_Success;
- }
- public OnPluginStart(){
- HookEvent("player_hurt", PlayerHurt);
- HookEvent("infected_hurt", InfectedHurt);
- }
- public Action PlayerHurt(Event event, const char[] name, bool dontBroadcast)
- {
- int attackerId = event.GetInt("attacker");
- int attacker = GetClientOfUserId(attackerId);
- //char name[64];
- //GetClientName(attacker, name, sizeof(name));
- if(attacker > 0 && attacker <= MaxClients && IsClientConnected(attacker) && IsClientInGame(attacker) && GetClientTeam(attacker) == 2 && IsFakeClient(attacker))
- {
- int amount = event.GetInt("dmg_health");
- int UserId = event.GetInt("userid");
- int client = GetClientOfUserId(UserId);
- int cur_health = event.GetInt("health");
- int dmg_health = RoundToNearest(cur_health - amount*Damage);
- if(GetClientTeam(client) == 3)
- {
- SetEntProp(client, Prop_Data, "m_iHealth", dmg_health + amount);
- return Plugin_Handled;
- }
- }
- return Plugin_Continue;
- }
- public Action InfectedHurt(Event event, const char[] name, bool dontBroadcast)
- {
- int attackerId = event.GetInt("attacker");
- int attacker = GetClientOfUserId(attackerId);
- //char name[64];
- //GetClientName(attacker, name, sizeof(name));
- if(attacker > 0 && attacker <= MaxClients && IsClientConnected(attacker) && IsClientInGame(attacker) && GetClientTeam(attacker) == 2 && IsFakeClient(attacker))
- {
- int amount = event.GetInt("amount");
- int client = event.GetInt("entityid");
- int cur_health = GetEntProp(client, Prop_Data, "m_iHealth");
- int dmg_health = RoundToNearest(cur_health - amount*Damage);
- if(cur_health > 0)
- {
- SetEntProp(client, Prop_Data, "m_iHealth", dmg_health);
- return Plugin_Handled;
- }
- }
- return Plugin_Continue;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement