Raised This Month: $51 Target: $400
 12% 

How to deny molotov from being activated[csgo]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 01-28-2019 , 11:49   How to deny molotov from being activated[csgo]
Reply With Quote #1

Thanks in advance.

PHP Code:
public void OnEntityCreated(int iEnt, const char[] classname)
{
    if (
StrEqual(classname"molotov_projectile"))
    {
        
SDKHook(iEntSDKHook_SpawnPostSDK_OnSpawnPost);
    }
}

public 
void SDK_OnSpawnPost(int iEntityIndex)
{
    
CreateTimer(0.0Timer_OnGrenadeSpawniEntityIndex);
}

public 
Action Timer_OnGrenadeSpawn(Handle hTimerint iGrenadeEntity)
{
    if (
iGrenadeEntity != -&& IsValidEdict(iGrenadeEntity))
    {
        
int iClientIndex GetEntPropEnt(iGrenadeEntityProp_Data"m_hThrower");

        if(
iClientIndex != -1)
        {
            if(
IsPlayerExist(iClientIndexfalse))
            {
                if(
/**/)
                {
                    
char sClassName[32];
                    
GetEntityClassname(iGrenadeEntitysClassNamesizeof(sClassName));
                    if(
StrEqual(sClassName"molotov_projectile"))
                    {
                        
/*Here I need to block real molotov action*/
                        
CreateTimer(delayTimer_ExplodeAsSomethingiGrenadeEntity);
                    }
                }
            }
        }
    }

    return 
Plugin_Stop;

impossible_cc is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 01-28-2019 , 11:57   Re: How to deny molotov from being activated[csgo]
Reply With Quote #2

PHP Code:
SetEntProp(entityProp_Data"m_nNextThinkTick", -1); 
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 01-28-2019 at 11:58.
Franc1sco is offline
Send a message via MSN to Franc1sco
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 01-28-2019 , 13:57   Re: How to deny molotov from being activated[csgo]
Reply With Quote #3

It helps with all grenades, but molotov
impossible_cc is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 01-28-2019 , 14:26   Re: How to deny molotov from being activated[csgo]
Reply With Quote #4

About molotov action I mean to prevent it exploding when it touchs ground
impossible_cc is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 01-28-2019 , 15:55   Re: How to deny molotov from being activated[csgo]
Reply With Quote #5

Have you tried printing all entity classnames to console from you OnEntityCreated function?

Maybe another entity is created when it explodes that you could block.
__________________

Last edited by Neuro Toxin; 01-28-2019 at 15:55.
Neuro Toxin is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 01-29-2019 , 11:07   Re: How to deny molotov from being activated[csgo]
Reply With Quote #6

That works, but it looks a bit weird.
PHP Code:
public Action RecreateMolotov(Handle timerint oldgrenade)
{
    if(!
IsValidEntity(oldgrenade) || !HasEntProp(oldgrenadeProp_Send"m_vecOrigin") || oldgrenade <= 0)
    {
        return 
Plugin_Stop;
    }
    
float oldabs[3];
    
float oldvel[3];
    
//float oldang[3];
    
    
int iOwnerIndex GetEntPropEnt(oldgrenadeProp_Data"m_hThrower");
    
GetEntPropVector(oldgrenadeProp_Send"m_vecOrigin"oldabs);
    
GetEntPropVector(oldgrenadeProp_Data"m_vecVelocity"oldvel);
    
//GetEntPropVector(oldgrenade, Prop_Send, "m_vecAngles", oldang);
    
AcceptEntityInput(oldgrenade"kill");
    
int iGrenadeIndex CreateEntityByName("molotov_projectile");
    
DispatchSpawn(iGrenadeIndex);

    if(
IsValidEdict(iGrenadeIndex))
    {
        
DispatchKeyValue(iGrenadeIndex"globalname""customgrenade");
        
        
SetEntPropEnt(iGrenadeIndexProp_Data"m_hThrower"iOwnerIndex);
        
SetEntProp(iGrenadeIndexProp_Send"m_usSolidFlags",  152);
        
SetEntProp(iGrenadeIndexProp_Send"m_CollisionGroup"11);
        
SetEntityGravity(iGrenadeIndex1.0);
        
        
TeleportEntity(iGrenadeIndexoldabsNULL_VECTORoldvel);
    }
    return 
Plugin_Continue;

impossible_cc is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 01-30-2019 , 12:25   Re: How to deny molotov from being activated[csgo]
Reply With Quote #7

Quote:
Originally Posted by Neuro Toxin View Post
Have you tried printing all entity classnames to console from you OnEntityCreated function?

Maybe another entity is created when it explodes that you could block.


Yes. When you throw a grenade, molotov_projectile is created, but when it touchs something, inferno is created.
Can you advise me how to block that action?
impossible_cc is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-30-2019 , 12:57   Re: How to deny molotov from being activated[csgo]
Reply With Quote #8

Quote:
Originally Posted by impossible_cc View Post


Yes. When you throw a grenade, molotov_projectile is created, but when it touchs something, inferno is created.
Can you advise me how to block that action?
Several different methods, this might work:
Code:
public void OnEntityCreated(int entity, const char[] classname) {
    if(StrEqual(classname, "inferno")) {
        SDKHook(entity, SDKHook_Spawn, Hook_BlockSpawn);
    }
}

public Action Hook_BlockSpawn(int entity) {
    return Plugin_Handled;
}
or this:
Code:
public void OnEntityCreated(int entity, const char[] classname) {
    if(StrEqual(classname, "inferno")) {
        SDKHook(entity, SDKHook_SpawnPost, Hook_SpawnCP);
    }
}

public void Hook_SpawnCP(int entity) {
    AcceptEntityInput(entity, "Kill");
}
Mitchell is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 01-30-2019 , 14:35   Re: How to deny molotov from being activated[csgo]
Reply With Quote #9

Okay, that prevents creating fireplace. But is it possible to keep the projectile 'alive'?
Basically, I want to make molotov_projectile rebound from the floor, instead of destroying it and create "inferno".
For that purpose I tried to 'recreate' molotov_projectile by myself in the function above, the result was 'Okay' but it looks very weird because velocity is transferred not 100% correctly.
Sorry for being a bit obscure.
impossible_cc is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 01-30-2019 , 18:50   Re: How to deny molotov from being activated[csgo]
Reply With Quote #10

Maybe there is a way to hook Kill on the projectile and block it.
__________________
Neuro Toxin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:13.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode