AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Instant change weapon model (https://forums.alliedmods.net/showthread.php?t=243370)

Mirk 07-03-2014 14:44

Instant change weapon model
 
I have a problem with instant change weapon model through Forward - FM_UpdateClientData and I don't know, where is the error, please?

Code:
PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < cstrike >

#define EXTRAOFFSET_WEAPON    4
#define m_pPlayer         41

new bool:g_bSkins33 ];

public 
plugin_init() 
{
    
register_plugin"Test""1.0""Author" );
    
    new 
szWeapon20 ];
    for(new 
CSW_P228<= CSW_P90i++ )
    {
        if( 
get_weaponnameiszWeaponcharsmaxszWeapon ) ) )
        {
            
RegisterHamHam_Item_DeployszWeapon"ham_Deploy_Post");
        }
    }
    
    
register_forwardFM_UpdateClientData"UpdateClientData_Post");

    
register_clcmd"say /test""Open_Setting" );
}

public 
client_putinserverid )
{
    
g_bSkinsid ] = true;
}

public 
ham_Deploy_PostiWeapon )
{
    new 
id get_pdata_cbaseiWeaponm_pPlayerEXTRAOFFSET_WEAPON );
    new 
iCswId cs_get_weapon_idiWeapon );
    
    if( 
g_bSkinsid ] )
    {
        if( 
iCswId == CSW_KNIFE )
        {
            
set_pevidpev_viewmodel2"models/v_newknife.mdl" );
            
set_pevidpev_weaponmodel2"models/p_newknife.mdl" );
        }
    }
    else
    {
        if( 
iCswId == CSW_KNIFE )
        {
            
set_pevidpev_viewmodel2"models/v_knife.mdl" );
            
set_pevidpev_weaponmodel2"models/p_knife.mdl" );
        }
    }
}

public 
UpdateClientData_Postidsendweaponscd_handle )
{
    if( !
is_user_aliveid ) )
        return 
FMRES_IGNORED;
            
    if( 
g_bSkinsid ] )
    {
        
get_cdcd_handleCD_ViewModelg_bSkinsid ] );
    }
    else
    {
        
set_cdcd_handleCD_ViewModel );
    }
    
    return 
FMRES_HANDLED;
}

public 
Open_Settingid )
{
    new 
hSet menu_create"\ySetting:""Handler_Setting" );
    
    
menu_additemhSet, ( g_bSkinsid ] ) ? "\wSkins \y[ON]" "\wSkins \r[OFF]""1"0);
    
    
menu_displayidhSet);
}

public 
Handler_SettingidhMenuiItem )
{
    if( 
iItem == MENU_EXIT )
    {
        return;
    }
    
    new 
szData], iAccess2hCallback;
    
menu_item_getinfohMenuiItemiAccess2szData5__hCallback );
    new 
iKey str_to_numszData );
   
    switch( 
iKey )
    {
        case 
1:
        {
            
g_bSkinsid ] = ( g_bSkinsid ] ) ? false true;
        }
    }
    
    
menu_destroyhMenu );
    return;



GuskiS 07-03-2014 17:29

Re: Instant change weapon model
 
Can you explain what are you trying to do?

Mirk 07-03-2014 17:40

Re: Instant change weapon model
 
Immediately change the knife model.

Flick3rR 07-03-2014 17:49

Re: Instant change weapon model
 
Ham_ItemDeploy is enough. No need for such forwards. Just register it with weapon_knife and set the models.

Mirk 07-03-2014 19:00

Re: Instant change weapon model
 
This is only part of the code, I want to more models later...

Eagle07 07-03-2014 19:31

Re: Instant change weapon model
 
add this
PHP Code:

public plugin_precache()
{
     
precache_model("models/v_newknife.mdl")
     
precache_model("models/p_newknife.mdl")



GuskiS 07-03-2014 19:38

Re: Instant change weapon model
 
Quote:

Originally Posted by Mirk (Post 2161561)
This is only part of the code, I want to more models later...

Then you register for Ham_ItemDeploy for each weapon for which you want to change model.
No need for UpdatePlayerInfo.

hornet 07-03-2014 20:11

Re: Instant change weapon model
 
Depends how many weapons will have different models. If you have lots, ResetMaxSpeed() would be acceptable.
Can also be done with just a couple lines in Orpheu. :)

Mirk 07-04-2014 01:40

Re: Instant change weapon model
 
Quote:

Originally Posted by GuskiS (Post 2161580)
Then you register for Ham_ItemDeploy for each weapon for which you want to change model.
No need for UpdatePlayerInfo.

But then immediately change model, when I give OFF or ON model.

Quote:

Originally Posted by hornet (Post 2161597)
Depends how many weapons will have different models. If you have lots, ResetMaxSpeed() would be acceptable.
Can also be done with just a couple lines in Orpheu. :)

Could you give an example, please? - ResetMaxSpeed()

GuskiS 07-04-2014 06:22

Re: Instant change weapon model
 
To change immediately:
ExecuteHamB(Ham_Item_Deploy, find_ent_by_owner(-1, "weapon_knife", id));


All times are GMT -4. The time now is 21:05.

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