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

How to make props dont move when granade explodes ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
martoxs
Junior Member
Join Date: Dec 2012
Old 01-07-2013 , 08:49   How to make props dont move when granade explodes ?
Reply With Quote #1

Granate destroy baricades and push props very much. How to make props dont move when granade explodes ?
martoxs is offline
Jargon
SourceMod Donor
Join Date: Jun 2012
Location: Sydney, Australia
Old 01-07-2013 , 14:51   Re: How to make props dont move when granade explodes ?
Reply With Quote #2

As far as I know, they are either movable or they aren't, there's no selectivity with what weapon/grenade can/can't move them.
Jargon is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 01-07-2013 , 15:20  
Reply With Quote #3

you could try setting near props of a grenade to not movable 0.1 second before its explosion and, then, setting it to movable 0.1 second after its explosion.

@edit
actually, you could even try setting the props to not movable when the entity env_explosion is created.
__________________
sie sind das essen und wir sind die jäger!

Last edited by Bimbo1; 01-07-2013 at 15:30.
Bimbo1 is offline
martoxs
Junior Member
Join Date: Dec 2012
Old 01-11-2013 , 02:34   Re: How to make props dont move when granade explodes ?
Reply With Quote #4

I don't understand, does anyone know how ?
martoxs is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 01-12-2013 , 14:45   Re: How to make props dont move when granade explodes ?
Reply With Quote #5

here you go, i did it for you:
you may want to change the number at the line 31. it's the squared range of the explosion. i set the range as 250000, which is 500 squared. it worked fine for me, but if you want to change its radius, do it.
Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>

public OnEntityCreated(entity, const String:classname[]){
    
    if(StrEqual(classname, "hegrenade_projectile", false)){
        
        CreateTimer(1.5, OnGrenadeExplosion, entity);
        
    }
    
}

public Action:OnGrenadeExplosion(Handle:timer, any:entity){
    
    decl Float:pos[3];
    decl Float:pos2[3];
    decl String:classname[32];
    new Handle:pack = CreateDataPack();
    GetEntPropVector(entity, Prop_Data, "m_vecOrigin", pos);
    for(new i = MaxClients+1; i < 2048; i++){
        
        if(IsValidEntity(i)){
            
            GetEntPropString(i, Prop_Data, "m_iClassname", classname, 32);
            if(StrContains(classname, "prop_physics", false) != -1){
                
                GetEntPropVector(i, Prop_Data, "m_vecOrigin", pos2);
                if(GetVectorDistance(pos, pos2, true) <= 250000.0){
                    
                    AcceptEntityInput(i, "DisableMotion");
                    WritePackCell(pack, i);
                    
                }
                
            }
            
        }
        
    }
    WritePackCell(pack, -1);
    CreateTimer(0.1, AfterGrenadeExplosion, pack);
    return Plugin_Continue;
    
}

public Action:AfterGrenadeExplosion(Handle:timer, Handle:pack){
    
    ResetPack(pack);
    new entity = ReadPackCell(pack);
    decl String:classname[32];
    while(entity != -1){
        
        if(IsValidEntity(entity)){
            
            GetEntPropString(entity, Prop_Data, "m_iClassname", classname, 32);
            if(StrContains(classname, "prop_physics", false) != -1){
                
                AcceptEntityInput(entity, "EnableMotion");
                
            }
            
        }
        entity = ReadPackCell(pack);
        
    }
    
}
code in pastie: http://pastie.org/private/dynw0dfiukcimnjglsvvjq
Bimbo1 is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 01-12-2013 , 15:29   Re: How to make props dont move when granade explodes ?
Reply With Quote #6

oh, and please change the line:
for(new i = MaxClients+1; i < 2048; i++){
to this
for(new i = MAXPLAYERS+1; i < 2048; i++){
Bimbo1 is offline
eziukasish
BANNED
Join Date: Jan 2013
Old 01-14-2013 , 10:27   Re: How to make props dont move when granade explodes ?
Reply With Quote #7

Man, u are the beast!!!!!! Thank you!!!!!!!!!!!
eziukasish is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 01-19-2013 , 22:06   Re: How to make props dont move when granade explodes ?
Reply With Quote #8

Quote:
Originally Posted by eziukasish View Post
Man, u are the beast!!!!!! Thank you!!!!!!!!!!!
lol, i don't think being a beast is a good thing, but whatever. anyway, the method i used before is just dumb, so i thought a little more about it and did something much simplier and smarter which should work flawlessly:
Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>

new bool:grenadeIndex[2048] = {false, false, ...};

public OnEntityCreated(entity, const String:classname[]){
    
    if(StrEqual(classname, "hegrenade_projectile", false)){
        
        grenadeIndex[entity] = true;
        
    }else if(StrContains(classname, "prop_physics", false) != -1){
        
        SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
        
    }
    
}

public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype){
    
    if(!grenadeIndex[inflictor]){
        
        return Plugin_Continue;
        
    }
    return Plugin_Handled;
    
}

Last edited by Bimbo1; 01-19-2013 at 22:10. Reason: grammar
Bimbo1 is offline
rhelgeby
Veteran Member
Join Date: Oct 2008
Location: 0x4E6F72776179
Old 01-20-2013 , 02:26   Re: How to make props dont move when granade explodes ?
Reply With Quote #9

The basic logic would work, but you don't have a line that's resetting an entry in grenadeIndex to false again. Over time every entry will eventually be true. Not all entity indexes are unique, like the grenade projectiles.

Perhaps it works by using OnEntityDestroyed to reset entries in grenadeIndex to false, if the entity exist in that list.

You also might want to add additional damage hooks for prop_physics_multiplier and prop_physics_override, since those are also common in maps.
__________________
Richard Helgeby

Zombie:Reloaded | PawnUnit | Object Library
(Please don't send private messages for support, they will be ignored. Use the forum.)
rhelgeby is offline
Send a message via MSN to rhelgeby
ocwoody
AlliedModders Donor
Join Date: Nov 2010
Location: huh
Old 01-20-2013 , 14:56   Re: How to make props dont move when granade explodes ?
Reply With Quote #10

Quote:
Originally Posted by rhelgeby View Post
The basic logic would work, but you don't have a line that's resetting an entry in grenadeIndex to false again. Over time every entry will eventually be true. Not all entity indexes are unique, like the grenade projectiles.

Perhaps it works by using OnEntityDestroyed to reset entries in grenadeIndex to false, if the entity exist in that list.

You also might want to add additional damage hooks for prop_physics_multiplier and prop_physics_override, since those are also common in maps.
Would love to see these changes made, so I can use it on my server!

Last edited by ocwoody; 01-20-2013 at 15:44.
ocwoody 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 23:08.


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