AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [REQ] Command Change Model. (https://forums.alliedmods.net/showthread.php?t=174759)

ShLuMieL 12-24-2011 21:00

[REQ] Command Change Model.
 
Hey for all.

i need someone make me please plugin that's if i write /change
it's will change model on knife and i i write again its will return to first model
Thank's.

Heartbeat 12-25-2011 04:24

Re: [REQ] Command Change Model.
 
You can set it to choose a random model, otherwise i dont think its possible.

drekes 12-25-2011 06:34

Re: [REQ] Command Change Model.
 
It is possible with only 1 model either.

ShLuMieL 12-25-2011 08:32

Re: [REQ] Command Change Model.
 
i i want just 1 model either like if i write /change its set me
knife_212.mdl and if i write again it return the knife to defult knife.

ConnorMcLeod 12-25-2011 08:53

Re: [REQ] Command Change Model.
 
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



ShLuMieL 12-25-2011 12:47

Re: [REQ] Command Change Model.
 
Thank's to you


All times are GMT -4. The time now is 20:59.

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