Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdkhooks>
- #pragma newdecls required
- ConVar g_NextHitTime;
- bool block[MAXPLAYERS + 1];
- public Plugin myinfo =
- {
- name = "HNS - After Knife Block",
- author = "SUPER TIMOR",
- description = "Makes TT immune to get hurt after knife hit",
- version = "1.0",
- url = "http://cs-placzabaw.pl"
- };
- public void OnPluginStart()
- {
- HookEvent("player_spawn", PlayerSpawn);
- g_NextHitTime = CreateConVar("next_hit_time", "3.0", "Float value, that describes time needed to make CT able to hit TT again");
- AutoExecConfig(true, "hns-akb", "sourcemod");
- }
- public void OnClientPutInServer(int client)
- {
- SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- block[client] = false;
- }
- public void OnClientDisconnect(int client)
- {
- SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- block[client] = false;
- }
- public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
- {
- if(!IsValidClient(victim) || !IsValidClient(attacker))
- return Plugin_Continue;
- if(GetClientTeam(victim) == 3)
- return Plugin_Continue;
- if(block[victim])
- return Plugin_Handled;
- else
- {
- char weapon[32];
- GetClientWeapon(attacker, weapon, sizeof(weapon));
- if((StrContains(weapon, "knife") >= 0 || StrContains(weapon, "bayonet") >= 0) && !block[victim] && IsPlayerAlive(victim))
- {
- if(damage > 55.0)
- {
- damage = 55.0;
- return Plugin_Changed;
- }
- KnifeBlock(victim);
- }
- }
- return Plugin_Continue;
- }
- public void KnifeBlock(int client)
- {
- CreateTimer(g_NextHitTime.FloatValue, NoKnifeBlock, GetClientUserId(client))
- block[client] = true;
- SetEntityRenderMode(client, RENDER_TRANSCOLOR);
- SetEntityRenderColor(client, 255, 0, 0, 160);
- }
- public Action NoKnifeBlock(Handle timer, any userid)
- {
- int client = GetClientOfUserId(userid);
- if (!client)
- return Plugin_Stop;
- block[client] = false;
- SetEntityRenderMode(client, RENDER_TRANSCOLOR);
- SetEntityRenderColor(client, 255, 255, 255, 255);
- return Plugin_Continue;
- }
- public Action PlayerSpawn(Handle event, char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- block[client] = false;
- }
- public bool IsValidClient(int client)
- {
- if (client <= 0 || client > MaxClients)
- return false;
- if (!IsClientInGame(client))
- return false;
- if (!IsPlayerAlive(client))
- return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement