LittleKu 发表于 2011-3-7 23:55:53

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

new const g_szVmodels[ CsTeams ][] = {
        "",
        "models/v_hgun.mdl",
        "models/v_crowbar.mdl",
        ""
};

new const g_szPmodels[ CsTeams ][] = {
        "",
        "models/p_hgun.mdl",
        "models/p_crowbar.mdl",
        ""
};

new const g_szWmodels[ CsTeams ][] = {
        "",
        "models/w_hgun.mdl",
        "models/w_crowbar.mdl",
        ""
};

new const g_szOldSound[][] = {
        "sound/weapons/knife_deploy1.wav",
        "sound/weapons/knife_slash1.wav" ,
        "sound/weapons/knife_slash2.wav",
        "sound/weapons/knife_hit1.wav" ,
        "sound/weapons/knife_hit2.wav",
        "sound/weapons/knife_hit3.wav",
        "sound/weapons/knife_hit4.wav",
        "sound/weapons/knife_stab.wav",
        "sound/weapons/knife_hitwall1.wav"
};

new const g_szNewSound[][] = {
        "sound/weapons/fiveseven_clipin.wav",
        "sound/FeNgGe/FeNgGe_7.wav",
        "sound/FeNgGe/FeNgGe_7.wav",
        "sound/FeNgGe/FeNgGe_8.wav",
        "sound/FeNgGe/FeNgGe_8.wav",
        "sound/FeNgGe/FeNgGe_8.wav",
        "sound/FeNgGe/FeNgGe_9.wav",
        "sound/debris/concrete3.wav",
        "这里再加一个音效"
};

new const g_szOldWmodel[] = "models/w_knife.mdl";

new const PLUGIN_NAME[]                = "";
new const PLUGIN_AUTHOR[]      = "";
new const PLUGIN_VERSION[]      = "";

#define IsPlayer(%1) (1<=%1<=g_iMaxPlayers)

new g_iMaxPlayers;

public plugin_init()
{
        register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
        register_event( "CurWeapon", "Event_CurWeapon", "be","1=1" );
        register_forward( FM_SetModel, "fw_SetModel" );
       
        g_iMaxPlayers = get_maxplayers();
       
        //Hook Sound
        register_forward( FM_EmitSound, "fw_EmitSound" );
}

public plugin_precache()
{
        for ( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
        {
                engfunc( EngFunc_PrecacheModel, g_szVmodels[ i ] );
                engfunc( EngFunc_PrecacheModel, g_szWmodels[ i ] );
                engfunc( EngFunc_PrecacheModel, g_szPmodels[ i ] );
        }
       
        for ( new i = 0; i < sizeof g_szNewSound; i++ )
                engfunc( EngFunc_PrecacheSound, g_szNewSound[ i ] );
}

public Event_CurWeapon( id )
{   
        new iWeapon = read_data( 2 );
        new CsTeams:iUserTeam = cs_get_user_team( id );
       
        if( iWeapon != CSW_KNIFE )
                return PLUGIN_CONTINUE;
       
        set_pev( id, pev_viewmodel2, g_szVmodels[ iUserTeam ] );
        set_pev( id, pev_weaponmodel2, g_szWmodels[ iUserTeam ] );
       
        return PLUGIN_CONTINUE;
}

public fw_SetModel( iEnt, const szModel[ ] )
{
        if( !pev_valid( iEnt ) )
                return FMRES_IGNORED;
       
        if( !equali(szModel, g_szOldWmodel ) )
                return FMRES_IGNORED;
       
        new szClassName[ 33 ];
        pev( iEnt, pev_classname, szClassName, charsmax( szClassName ) );
       
        new id = pev( iEnt, pev_owner );
        new CsTeams:iUserTeam = cs_get_user_team( id );
       
        if( equal( szClassName, "weaponbox" ) || equal( szClassName, "armoury_entity" ) || equal( szClassName, "grenade" ) )
        {
                engfunc( EngFunc_SetModel, iEnt, g_szWmodels[ iUserTeam ] );
                return FMRES_SUPERCEDE;
        }
        return FMRES_IGNORED;
}

public fw_EmitSound( id, iChannel, const szSample[], Float:fVolume, Float:fAttenuation, iFlags, iPitch )
{
        if ( !IsPlayer( id ) || !is_user_alive(id) || !is_user_connected( id ) )
                return FMRES_IGNORED;
       
        if ( iChannel != CHAN_WEAPON && iChannel != CHAN_ITEM )
                return FMRES_IGNORED;
       
        if ( cs_get_user_team( id ) != CS_TEAM_T )
                return FMRES_IGNORED;
       
        for ( new i = 0; i < sizeof g_szOldSound; i++ )
        {
                if ( equali( szSample, g_szOldSound[ i ] ) )
                {
                        engfunc( EngFunc_EmitSound, id, CHAN_WEAPON, g_szNewSound[ i ], VOL_NORM, ATTN_NORM, CHAN_AUTO, PITCH_NORM );
                        return FMRES_SUPERCEDE;
                }
        }
        return FMRES_IGNORED;
}小疏忽哈,已经修正错误和警告

点通粉丝 发表于 2011-3-8 02:26:31

11# kk阿朗

可以编绎了..但是开图不足两分钟死机..提示是

470191594 发表于 2011-3-8 10:33:14

缺少模型arcticT.mdl

LittleKu 发表于 2011-3-8 11:33:00

这个是你模型的问题,与代码无关!请确认所需模型全部具有!
页: 1 [2]
查看完整版本: 己解决主题-在此感谢kk阿郎的帮忙