Raised This Month: $ Target: $400
 0% 

[REQ] Command Change Model.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-25-2011 , 06:34   Re: [REQ] Command Change Model.
Reply With Quote #1

It is possible with only 1 model either.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-25-2011 , 08:53   Re: [REQ] Command Change Model.
Reply With Quote #2

Don't need to write anything, just try to drop your knife with default drop key.

The only thing you have to edit in code is models :
PHP Code:
    new szModels[][] = 
    {
        
"custom_weapons/v_knife1.mdl"// don't put cstrike/models/ in path
        
"custom_weapons/v_knife2.mdl",
        
"custom_weapons/v_knife3.mdl"
    

PHP Code:
/*    Formatright © 2011, ConnorMcLeod

    knives models is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with cs1.5 knife; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

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

#define VERSION "0.2.0"

const MAX_PLAYERS 32

const KNIFE_DRAW 3

const FIRST_PERSON_VIEW    4

const XO_WEAPON 4
const m_pPlayer 41
const m_iId 43
const m_flDeployedTime 76 // m_flDecreaseShotsFired ? w/e nvm works

const XO_PLAYER 5
const m_pActiveItem 373

const DEFAULT_MODEL = -1

new g_iPlayerModel[MAX_PLAYERS+1]
new Array:
g_aKnivesModelsAllocated
new g_iKnivesNum

public plugin_precache()
{
    new 
szModels[][] = 
    {
        
"custom_weapons/v_knife1.mdl"// don't put cstrike/models/ in path
        
"custom_weapons/v_knife2.mdl",
        
"custom_weapons/v_knife3.mdl"
    
}

    
g_aKnivesModelsAllocated ArrayCreate(1,1)
    new 
szFullModel[64]

    for(new 
ii<sizeof(szModels); i++)
    {
        
formatex(szFullModelcharsmax(szFullModel), "models/%s"szModels[i])
        
precache_model(szFullModel)
        
ArrayPushCell(g_aKnivesModelsAllocatedengfunc(EngFunc_AllocStringszFullModel))
    }
    
g_iKnivesNum ArraySize(g_aKnivesModelsAllocated)
}

public 
plugin_init()
{
    
register_plugin("knives models"VERSION"ConnorMcLeod")

    
RegisterHam(Ham_Item_Deploy"weapon_knife""Knife_Deploy"1)

    
register_clcmd("drop""ClientCommand_Drop")
}

public 
client_putinserver(id)
{
    
g_iPlayerModel[id] = DEFAULT_MODEL
}

public 
Knife_DeployiKnife )
{
    new 
id get_pdata_cbase(iKnifem_pPlayerXO_WEAPON)
    new 
iModel g_iPlayerModel[id]
    if( 
iModel != DEFAULT_MODEL )
    {
        
set_pev(idpev_viewmodelArrayGetCell(g_aKnivesModelsAllocatediModel))
    }
}

public 
ClientCommand_Dropid )
{
    if( 
is_user_alive(id) )
    {
        new 
iWeapon get_pdata_cbase(idm_pActiveItemXO_PLAYER)
        if( 
get_pdata_int(iWeaponm_iIdXO_WEAPON) == CSW_KNIFE )
        {
            new 
iModel g_iPlayerModel[id]
            if( ++
iModel >= g_iKnivesNum )
            {
                
iModel DEFAULT_MODEL
            
}
            
g_iPlayerModel[id] = iModel

            
if( get_gametime() - get_pdata_float(iWeaponm_flDeployedTimeXO_WEAPON) <= 1.5 )
            {
                new 
iPlayers[MAX_PLAYERS], iNumiPlayeriBody pev(id,pev_body)

                
get_players(iPlayersiNum"bh")
                for(--
iNumiNum>=0iNum--)
                {
                    
iPlayer iPlayers[iNum]
                    if( 
pev(iPlayerpev_iuser2) == id && pev(iPlayerpev_iuser1) == FIRST_PERSON_VIEW )
                    {
                        
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player=iPlayer)
                        {
                            
write_byte(KNIFE_DRAW)
                            
write_byte(iBody)
                        }
                        
message_end()
                    }
                }
                
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player=id)
                {
                    
write_byte(KNIFE_DRAW)
                    
write_byte(iBody)
                }
                
message_end()
            }

            
ExecuteHamB(Ham_Item_DeployiWeapon)

            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 20:59.


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