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

Correct Silencers


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Gameplay       
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 11-16-2013 , 05:40   Correct Silencers
Reply With Quote #1

Correct Silencers

Description
:
This plugin add M4A1 and USP models (p_, w_) without silencer, and display it (ofcourse, when weapon without silencer). Like in Counter-Strike: Source.

Warning:
This plugin does not support Tactical Shield (B88). Use only if Tactical Shield disabled on your server.

Needed Include:
Counter-Strike pvPrivateData offsets (direct download link here).

Screenshots:


Thanks to:
KORD_12.7

Changelog:
Attached Files
File Type: sma Get Plugin or Get Source (cors.sma - 986 views - 4.8 KB)
File Type: zip models.zip (50.5 KB, 301 views)

Last edited by Phant; 11-18-2013 at 04:04.
Phant is offline
Send a message via ICQ to Phant
bibu
Veteran Member
Join Date: Sep 2010
Old 11-16-2013 , 05:54   Re: Correct Silencers
Reply With Quote #2

Just you should know, this exists already, but your method is more reliable IMO.

http://forums.alliedmods.net/showthread.php?p=183118
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 11-16-2013 , 06:58   Re: Correct Silencers
Reply With Quote #3

Quote:
Originally Posted by bibu View Post
Just you should know, this exists already, but your method is more reliable IMO.

http://forums.alliedmods.net/showthread.php?p=183118
Oh my god . I got carried away with this plugin, forgetting about search .

Thanks for link. I will study existing codes and try make my version better...
Phant is offline
Send a message via ICQ to Phant
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 11-16-2013 , 13:20   Re: Correct Silencers
Reply With Quote #4

Nice plugin anyway.
__________________
Kia is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-16-2013 , 15:08   Re: Correct Silencers
Reply With Quote #5

Better to check model string in SetModel forward, so it won't override model plugins.
You should allocate model strings at plugin initialisation and use set_pev_string instead of set_pev for pev_weaponmodel2
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 11-17-2013 , 00:36   Re: Correct Silencers
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
Better to check model string in SetModel forward, so it won't override model plugins.
Just like in your code?:
PHP Code:
public SetModel_Pre(entmodel[])
{
    if( 
pev_valident ) )
    {
        if( 
equal(model"models/w_usp.mdl") )
        {
            new 
usp get_pdata_cbase(entm_rgpPlayerItems_wpnbx_slot2XO_WEAPONBOX);
            if( 
usp && ~get_weapon_stateusp ) & WEAPONSTATE_USP_SILENCED )
            {
                
SET_MODEL(entW_USP_NOSIL);
                return 
FMRES_SUPERCEDE;
            }
        }
        else if( 
equal(modelW_M4A1_SIL) )
        {
            new 
m4a1get_pdata_cbase(entm_rgpPlayerItems_wpnbx_slot1XO_WEAPONBOX);
            if( 
m4a1 && ~get_weapon_statem4a1 ) & WEAPONSTATE_M4A1_SILENCED )
            {
                
SET_MODEL(entW_M4A1_NOSIL);
                return 
FMRES_SUPERCEDE;
            }
        }
    }
    return 
FMRES_IGNORED;

Quote:
Originally Posted by ConnorMcLeod View Post
You should allocate model strings at plugin initialisation and use set_pev_string instead of set_pev for pev_weaponmodel2
Can you please say how I can set model via set_pev_string exactly?
I try:
PHP Code:
//set_pev(pPlayer, pev_weaponmodel2, P_USP)
set_pev_string(iWeaponpev_modelmUSP
mUSP is global variable of precached model:
PHP Code:
new mUSP

public plugin_precache()
{
    
mUSP precache_model(P_USP
But it's not work.
Phant is offline
Send a message via ICQ to Phant
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-17-2013 , 02:26   Re: Correct Silencers
Reply With Quote #7

For this plugin, i would compare passed model with pev_model, if doesn't match it means it has been changed by a model plugin at PRE hook, but sometimes trying to make plugins compatible is hard or stupid, dunno.


PHP Code:
public plugin_precache()
{
    
precache_model(P_USP)
    
mUSP engfunc(EngFunc_AllocStringP_USP)
}

{
    
//set_pev(pPlayer, pev_weaponmodel2, P_USP)
    
set_pev_string(iWeaponpev_weaponmodel2mUSP)
    
// or set_pev(iWeapon, pev_weaponmodel, mUSP)
    // which is basically the same,but not all pev_*** strings have this equivalent

When you use set_pev and pev_weaponmodel2, it allocate the string each time at a new place in game dll memory, and this memory is never reset, even after map change, so allocate it 1 time in precache is far better
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-17-2013 at 02:30.
ConnorMcLeod is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 11-18-2013 , 04:08   Re: Correct Silencers
Reply With Quote #8

Updated (1.1). Hope, all are okay.
Phant is offline
Send a message via ICQ to Phant
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-03-2015 , 14:05   Re: Correct Silencers
Reply With Quote #9

Some fast thoughts:
1.Do not hardcode string-array size, use charsmax() to retrieve it.
2.Use real offset names, for readability. Instead of 35 and 36, use m_rgpPlayerItems_CWeaponBox[6] = { 34 , 35 , ... } and index by the weapon slot(1 for primary weapons and 2 for secondary), for 41 m_pPlayer etc.
3.You have a macro for m_fWeaponState, use it.
4.Please also fix the armoury_entities, get the armoury index with m_iItem or cs_get_armoury_index(with is the same thing) and check if it contains a M4A1(the index is 6).
5.Add support for shield.
__________________
HamletEagle is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-23-2015 , 12:33   Re: Correct Silencers
Reply With Quote #10

More than 15 days have passed and I don't see any changes from the author. Since section needs to be cleaned I'll unapprove this for now, but don't worry, your plugin can be reviewed at any time. PM a plugin approver after you made the changes.
__________________

Last edited by HamletEagle; 10-23-2015 at 12:33.
HamletEagle 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 06:27.


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