View Single Post
The Killer NL
AlliedModders Donor
Join Date: Aug 2018
Location: The Netherlands
Old 10-16-2018 , 04:21   Re: [CSGO] Blocking Left knife
Reply With Quote #17

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 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);
}

public 
void OnWeaponEquipPost(int iClientint iWeapon)
{
    if (
iWeapon != GetPlayerWeaponSlot(iClientCS_SLOT_KNIFE)) {
        return;
    }
    
    
char szClassName[48]; 
    
    if(!
GetEntityClassname(iWeaponszClassNamesizeof(szClassName))) {
        return;
    }
    
    if(
StrContains(szClassName"taser"false) != -1) {
        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);
    }
}

void FindAndAddKnifeInitial(int iClient)
{
    
int iWeapon = -1;
    
int iEntRef INVALID_ENT_REFERENCE;
    
    
char szClassName[48]; 
    
    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(!
GetEntityClassname(iWeaponszClassNamesizeof(szClassName))) {
            continue;
        }
        
        if(
StrContains(szClassName"taser"false) != -1) {
            continue;
        }
        
        
iEntRef EntIndexToEntRef(iWeapon);
        
        if (
g_alActiveKnives.FindValue(iEntRef) != -1) {
            continue;
        }
        
        
g_alActiveKnives.Push(iEntRef);
    }

Do you mind me changing the main one to this and add u into the credits list? since it works good.
__________________

The Killer NL is offline