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

Checking for silencer


Post New Thread Reply   
 
Thread Tools Display Modes
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 07-10-2012 , 17:59   Re: Checking for silencer
Reply With Quote #11

Quote:
if (GetEntPropEnt(FindEntityByClassname(attacker , "weapon_usp"), Prop_Send, "m_bSilencerOn") == 1)
That's never gonna work without checking the owner of the weapon at least (and this way it's not really clean).

Quote:
Originally Posted by Annihilator View Post
[PHP]#pragma semicolon 1
Works when testing on a small server, but doesn't work on a populated server.
No error logs.
Any ideas? :/
When I hate something more than someone coding dirty, it is when someone ignores me, do what I mentioned before !
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 07-10-2012 at 18:00.
berni is offline
Annihilator
Senior Member
Join Date: Nov 2006
Location: Lithuania
Old 07-11-2012 , 06:12   Re: Checking for silencer
Reply With Quote #12

PHP Code:
(StrEqual(WeaponName"weapon_usp") && (GetEntPropEnt(GetEntPropEnt(attackerProp_Data"m_hActiveWeapon"), Prop_Send"m_bSilencerOn") == 1)) 
Or did I get it wrong again?
Annihilator is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 07-11-2012 , 15:41   Re: Checking for silencer
Reply With Quote #13

Add some proper validation checking, remove unnecessary code and do some code cleanup (readable code is very important) then you are fine:

PHP Code:
public Action:TakeDamageHook(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])
{
    
// We don't have to check if the victim is valid, because otherwise this hook wouldn't have been called.
    
if (attacker || attacker MaxClients || !IsClientInGame(attacker)) {
        return 
Plugin_Continue;
    }

    if (
GetClientTeam(victim) == CS_TEAM_T && GetClientTeam(attacker) == CS_TEAM_CT) {
        
decl String:weaponClass[32];
        
GetEntityClassname(weaponweaponClasssizeof(weaponClass));

        if (
StrEqual(weaponClass"weapon_usp")) {
            
// We use GetEntProp to get a cell and cast it to a boolean, because there is no boolean version
            
new bool:m_bSilencerOn bool:GetEntProp(weaponProp_Send"m_bSilencerOn");

            if (
m_bSilencerOn) {
                
damage 0.0;
                
PrintToChatAll("\x01Oh noes! \x03%N \x01shot \x04%N \x01!"attackervictim);

                return 
Plugin_Changed;
            }
        }
    }

    return 
Plugin_Continue;

__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 07-11-2012 at 15:43.
berni 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 11:37.


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