View Single Post
Danielej1
Senior Member
Join Date: Jul 2022
Location: Poland
Old 11-12-2022 , 10:46   Re: [CSGO] How to disable pick up Nades
Reply With Quote #5

Quote:
Originally Posted by Bacardi View Post
You have not tell us, do players still need collect grenades when round start ?


This example follow weapon drop by player,
when weapon is grenade, it store that entity in array and will block pickup.
On round start plugin clear array of stored entities.

PHP Code:


#include <sdkhooks>
#include <cstrike>

ArrayList blockpick;

public 
void OnPluginStart()
{
    
blockpick = new ArrayList();

    
HookEvent("round_start"round_start);

    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i)) OnClientPutInServer(i);
    }
}

public 
void round_start(Event event, const char[] namebool dontBroadcast)
{
    
blockpick.Clear();
}

public 
void OnClientPutInServer(int client)
{
    
//SDKHook(client, SDKHook_OnTakeDamage, ontakedamage);
    //SDKHook(client, SDKHook_WeaponCanSwitchTo, weapon_cb1);
    
SDKHook(clientSDKHook_WeaponCanUseweapon_cb2);
    
SDKHook(clientSDKHook_WeaponDropweapon_cb3);
}

public 
Action ontakedamage(int victimintattackerintinflictorfloatdamageintdamagetype)
{
    
PrintToServer("%i %f %i",
                            
inflictor,
                            
damage,
                            
damagetype);
    return 
Plugin_Continue;
}


public 
Action weapon_cb1(int clientint weapon)
{
    
PrintToServer("weapon_cb1 %i %i",
                            
client,
                            
weapon);
    return 
Plugin_Continue;
}

public 
Action weapon_cb2(int clientint weapon)
{
    if(
weapon == -1)
        return 
Plugin_Continue;

    
int entref EntIndexToEntRef(weapon);

    if(
entref != -&& blockpick.FindValue(entref) != -1)
    {
        return 
Plugin_Handled;
    }

    return 
Plugin_Continue;
}

public 
Action weapon_cb3(int clientint weapon)
{
    if(
weapon == -|| !HasEntProp(weaponProp_Send"m_iItemDefinitionIndex"))
        return 
Plugin_Continue;

    
int entref EntIndexToEntRef(weapon);

    if(
entref != -&& blockpick.FindValue(entref) == -1)
    {
        
int m_iItemDefinitionIndex GetEntProp(weaponProp_Send"m_iItemDefinitionIndex");
        
CSWeaponID weaponid CS_ItemDefIndexToID(m_iItemDefinitionIndex);

        switch(
weaponid)
        {
            case 
CSWeapon_HEGRENADECSWeapon_SMOKEGRENADECSWeapon_FLASHBANG,\
                
CSWeapon_MOLOTOVCSWeapon_DECOYCSWeapon_INCGRENADECSWeapon_TAGGRENADECSWeapon_FRAGGRENADE:
            {
                
blockpick.Push(entref);
            }
        }
    }

    return 
Plugin_Continue;



Code:
C:\Users\ja\Desktop\blocknade.sp(74) : error 017: undefined symbol "CS_ItemDefIndexToID"
C:\Users\ja\Desktop\blocknade.sp(74) : warning 213: tag mismatch
C:\Users\ja\Desktop\blocknade.sp(79) : error 017: undefined symbol "CSWeapon_TAGGRENADE"
Danielej1 is offline