Raised This Month: $ Target: $400
 0% 

Instant change weapon model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mirk
Senior Member
Join Date: Nov 2012
Old 07-03-2014 , 14:44   Instant change weapon model
Reply With Quote #1

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;


Last edited by Mirk; 07-03-2014 at 14:44.
Mirk is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-03-2014 , 17:29   Re: Instant change weapon model
Reply With Quote #2

Can you explain what are you trying to do?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Mirk
Senior Member
Join Date: Nov 2012
Old 07-03-2014 , 17:40   Re: Instant change weapon model
Reply With Quote #3

Immediately change the knife model.
Mirk is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-03-2014 , 17:49   Re: Instant change weapon model
Reply With Quote #4

Ham_ItemDeploy is enough. No need for such forwards. Just register it with weapon_knife and set the models.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Mirk
Senior Member
Join Date: Nov 2012
Old 07-03-2014 , 19:00   Re: Instant change weapon model
Reply With Quote #5

This is only part of the code, I want to more models later...
Mirk is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-03-2014 , 19:38   Re: Instant change weapon model
Reply With Quote #6

Quote:
Originally Posted by Mirk View Post
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.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Mirk
Senior Member
Join Date: Nov 2012
Old 07-04-2014 , 01:40   Re: Instant change weapon model
Reply With Quote #7

Quote:
Originally Posted by GuskiS View Post
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 View Post
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()
Mirk is offline
Eagle07
Veteran Member
Join Date: May 2014
Location: Morocco :D
Old 07-03-2014 , 19:31   Re: Instant change weapon model
Reply With Quote #8

add this
PHP Code:
public plugin_precache()
{
     
precache_model("models/v_newknife.mdl")
     
precache_model("models/p_newknife.mdl")

__________________
Eagle07 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 07-03-2014 , 20:11   Re: Instant change weapon model
Reply With Quote #9

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.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-04-2014 , 06:22   Re: Instant change weapon model
Reply With Quote #10

To change immediately:
ExecuteHamB(Ham_Item_Deploy, find_ent_by_owner(-1, "weapon_knife", id));
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS 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 21:05.


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