View Single Post
eyal282
Veteran Member
Join Date: Aug 2011
Old 10-16-2018 , 07:08   Re: [CSGO] Blocking Left knife
Reply With Quote #20

Quote:
Originally Posted by SM9 View Post
New version which should be less expensive (Tested and does not break tasers)

PHP Code:
#include <sdktools>
#include <sdkhooks>
#include <cstrike>

public Plugin myinfo 
{
    
name "Block Left Knife"
    
author "Bara, [Updated by The Killer [NL], SM9();]"
    
description "Block Left Knife"
    
version "2.5"
    
url "www.bara.in, www.upvotegaming.com"
}

ArrayList g_alActiveKnives null;

public 
void OnPluginStart()
{
    
g_alActiveKnives = new ArrayList();
    
    for (
int i 1<= MaxClientsi++) {
        if (!
IsClientInGame(i)) {
            continue;
        }
        
        
OnClientPutInServer(i);
        
FindAndAddKnifeInitial(i);
    }
    
    
TriggerTimer(CreateTimer(0.5Timer_UpdateKnives_TIMER_REPEAT));
}

public 
void OnClientPutInServer(int iClient) {
    
SDKHookEx(iClientSDKHook_WeaponEquipPostOnWeaponEquipPost);
}

public 
void OnWeaponEquipPost(int iClientint iWeapon)
{
    if (
iWeapon != GetPlayerWeaponSlot(iClientCS_SLOT_KNIFE)) {
        return;
    }
    
    if(
CS_ItemDefIndexToID(GetEntProp(iWeaponProp_Send"m_iItemDefinitionIndex")) == CSWeapon_TASER) {
        return;
    }
    
    
int iEntRef EntIndexToEntRef(iWeapon);
    
    if (
g_alActiveKnives.FindValue(iEntRef) != -1) {
        return;
    }
    
    
g_alActiveKnives.Push(iEntRef);
}

public 
Action Timer_UpdateKnives(Handle hTimer)
{
    
int iKnife = -1;
    
int iEntRef INVALID_ENT_REFERENCE;
    
    for (
int i 0g_alActiveKnives.Lengthi++) {
        
iEntRef g_alActiveKnives.Get(i);
        
        if(
iEntRef == INVALID_ENT_REFERENCE) {
            
g_alActiveKnives.Erase(i);
            continue;
        }
        
        
iKnife EntRefToEntIndex(iEntRef);
        
        if (
iKnife <= MaxClients || !IsValidEntity(iKnife)) {
            
g_alActiveKnives.Erase(i);
            continue;
        }
        
        
SetEntPropFloat(iKnifeProp_Send"m_flNextPrimaryAttack"GetGameTime() + 999.0);
    }
}

public 
void OnEntityDestroyed(int iEntity)
{
    
int iEntRef INVALID_ENT_REFERENCE;
    
    if(
iEntity 0) {
        
iEntRef iEntity;
    } else {
        
iEntRef EntIndexToEntRef(iEntity);
    }
    
    
int iKnifeIndex g_alActiveKnives.FindValue(iEntRef);
    
    if (
iKnifeIndex == -1) {
        return;
    }
    
    
g_alActiveKnives.Erase(iKnifeIndex);
}

void FindAndAddKnifeInitial(int iClient)
{
    
int iWeapon = -1;
    
int iEntRef INVALID_ENT_REFERENCE;
    
    for (
int i 0GetEntPropArraySize(iClientProp_Send"m_hMyWeapons"); i++) {
        
iWeapon GetEntPropEnt(iClientProp_Send"m_hMyWeapons"i);
        
        if (
iWeapon <= MaxClients || !IsValidEntity(iWeapon)) {
            continue;
        }
        
        if (
iWeapon != GetPlayerWeaponSlot(iClientCS_SLOT_KNIFE)) {
            continue;
        }
        
        if(
CS_ItemDefIndexToID(GetEntProp(iWeaponProp_Send"m_iItemDefinitionIndex")) == CSWeapon_TASER) {
            return;
        }
        
        
iEntRef EntIndexToEntRef(iWeapon);
        
        if (
g_alActiveKnives.FindValue(iEntRef) != -1) {
            continue;
        }
        
        
g_alActiveKnives.Push(iEntRef);
    }

Does it work changing the next prim attack to a value like 21747483647.0 on weapon equip, blocking the need for any timers or functions that fire more than 10 a second? Should a right click negate it you can try hooking right attack somehow.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline