Raised This Month: $32 Target: $400
 8% 

Blocking Smoke Detonate CS:GO


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 04-22-2016 , 18:03   Blocking Smoke Detonate CS:GO
Reply With Quote #1

Hey guys,

Im trying to block the explosion of smokegrenades. At the moment, I hook the spawn of the entity and remove it if the velocity is zero. The problems are that (1) this only blocks the first smokegrenade and (2) after the block I cant give another smoke with GivePlayerItem.

Am I doing something wrong? Is there a bether way to achieve this? In cs1.6 you could just set the next think of the nade to 9999, would this be a possability in cs:go too?

PHP Code:
public OnEntityCreated(entity, const String:classname[]) 

    if(
StrEqual(classname"smokegrenade_projectile")) 
    { 
        
SDKHook(entitySDKHook_SpawnOnEntitySpawned)
    } 


public 
OnEntitySpawned(entity

    
CreateTimer(0.01TimerExecentityTIMER_REPEAT)
}

public 
Action TimerExec(Handle tint entity

    new 
Float:fVelocity[3]; 
    
GetEntPropVector(entityProp_Send"m_vecVelocity"fVelocity); 
    if(
fVelocity[0] == 0.0 && fVelocity[1] == 0.0 && fVelocity[2] == 0.0
    { 
        
AcceptEntityInput(entity"Kill");
        
        return 
Plugin_Stop
    
}

    return 
Plugin_Continue

__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 04-22-2016 , 19:13   Re: Blocking Smoke Detonate CS:GO
Reply With Quote #2

Do you mean something like this?

PHP Code:
#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
    
HookEvent("smokegrenade_detonate"OnSmokeDetonate);
}

public 
void OnSmokeDetonate(Event event, const char[] namebool dontBroadcast)
{
    
float origin[3];
    
origin[0] = GetEventFloat(event"x");
    
origin[1] = GetEventFloat(event"y");
    
origin[2] = GetEventFloat(event"z");
    
    
int index MaxClients+1;
    
float xyz[3];
    while ((
index FindEntityByClassname(index"smokegrenade_projectile")) != -1)
    {
        
GetEntPropVector(indexProp_Send"m_vecOrigin"xyz);
        if (
xyz[0] == origin[0] && xyz[1] == origin[1] && xyz[2] == origin[2])
        {
            
AcceptEntityInput(index"kill");
        }
    }
    
    while((
index FindEntityByClassname(index"env_particlesmokegrenade")) != -1)
    {
        
GetEntPropVector(indexProp_Send"m_vecOrigin"xyz);
        if (
xyz[0] == origin[0] && xyz[1] == origin[1] && xyz[2] == origin[2])
        {
            
AcceptEntityInput(index"kill");
        }
    }

__________________
xines is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 04-22-2016 , 19:14   Re: Blocking Smoke Detonate CS:GO
Reply With Quote #3

Code:
public OnEntityCreated(entity, const String:classname[])
{
	if(!strcmp(classname, "env_particlesmokegrenade"))
		AcceptEntityInput(entity, "Kill");
}
try this
__________________
Notable Projects:
Event Item Spawner | Scissors, Rock, Paper for ZephStore
tVip | Smart Link Remover
PLG & GGC - CS:GO Roleplay

and countless more...

I can make a helicopter shoot missles if you want me to...

Last edited by Totenfluch; 04-22-2016 at 19:15. Reason: EDIT: too late
Totenfluch is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-22-2016 , 19:22   Re: Blocking Smoke Detonate CS:GO
Reply With Quote #4

Quote:
Originally Posted by Totenfluch View Post
Code:
public OnEntityCreated(entity, const String:classname[])
{
	if(!strcmp(classname, "env_particlesmokegrenade"))
		AcceptEntityInput(entity, "Kill");
}
try this
Be carefull killing entities on this callback.

You should hook spawn and kill it there.
__________________
Neuro Toxin is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 04-22-2016 , 19:26   Re: Blocking Smoke Detonate CS:GO
Reply With Quote #5

Quote:
Originally Posted by Neuro Toxin View Post
Be carefull killing entities on this callback.

You should hook spawn and kill it there.
This Question may sound stupid but.. why?
__________________
Notable Projects:
Event Item Spawner | Scissors, Rock, Paper for ZephStore
tVip | Smart Link Remover
PLG & GGC - CS:GO Roleplay

and countless more...

I can make a helicopter shoot missles if you want me to...
Totenfluch is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-22-2016 , 20:05   Re: Blocking Smoke Detonate CS:GO
Reply With Quote #6

When create entity is called an entity index is returned.

If you kill the entity. Whatever created it might not check if the entity created is valid and attempt to call spawn entity.

This causes errors and in some cases server crashes.

Hooking spawn on the entity created callback and killing on spawn avoids this.
__________________
Neuro Toxin is offline
milutinke
AlliedModders Donor
Join Date: Jun 2012
Location: Serbia
Old 04-23-2016 , 04:36   Re: Blocking Smoke Detonate CS:GO
Reply With Quote #7

Code:
 SetEntProp( iEntity, Prop_Data, "m_nNextThinkTick", -1 );
I am using this and it works like charm
milutinke is offline
Send a message via Skype™ to milutinke
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 04-23-2016 , 05:30   Re: Blocking Smoke Detonate CS:GO
Reply With Quote #8

Quote:
Originally Posted by Neuro Toxin View Post
When create entity is called an entity index is returned.

If you kill the entity. Whatever created it might not check if the entity created is valid and attempt to call spawn entity.

This causes errors and in some cases server crashes.

Hooking spawn on the entity created callback and killing on spawn avoids this.
Thanks!
__________________
Notable Projects:
Event Item Spawner | Scissors, Rock, Paper for ZephStore
tVip | Smart Link Remover
PLG & GGC - CS:GO Roleplay

and countless more...

I can make a helicopter shoot missles if you want me to...
Totenfluch is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 04-23-2016 , 12:06   Re: Blocking Smoke Detonate CS:GO
Reply With Quote #9

Thanks guys, got it working with your help.
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
B_R
Member
Join Date: May 2017
Old 03-05-2018 , 22:58   Re: Blocking Smoke Detonate CS:GO
Reply With Quote #10

Quote:
Originally Posted by xines View Post
Do you mean something like this?

PHP Code:
#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
    
HookEvent("smokegrenade_detonate"OnSmokeDetonate);
}

public 
void OnSmokeDetonate(Event event, const char[] namebool dontBroadcast)
{
    
float origin[3];
    
origin[0] = GetEventFloat(event"x");
    
origin[1] = GetEventFloat(event"y");
    
origin[2] = GetEventFloat(event"z");
    
    
int index MaxClients+1;
    
float xyz[3];
    while ((
index FindEntityByClassname(index"smokegrenade_projectile")) != -1)
    {
        
GetEntPropVector(indexProp_Send"m_vecOrigin"xyz);
        if (
xyz[0] == origin[0] && xyz[1] == origin[1] && xyz[2] == origin[2])
        {
            
AcceptEntityInput(index"kill");
        }
    }
    
    while((
index FindEntityByClassname(index"env_particlesmokegrenade")) != -1)
    {
        
GetEntPropVector(indexProp_Send"m_vecOrigin"xyz);
        if (
xyz[0] == origin[0] && xyz[1] == origin[1] && xyz[2] == origin[2])
        {
            
AcceptEntityInput(index"kill");
        }
    }

Works bro you saved ma life, i can have smoke effect now wich doesn't make the detonate bug with molotov on ze ^^
B_R is offline
Reply


Thread Tools
Display Modes

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 05:15.


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