己解决主题-在此感谢kk阿郎的帮忙
本帖最后由 点通粉丝 于 2011-3-9 07:50 编辑#include <amxmodx>
#include <engine>
public plugin_init() {
// Plugin information
register_plugin("TeamKnives","1.0","Ywa-NL")
register_event("CurWeapon", "weaponChange", "be", "1=1")
register_cvar("amx_teamknives", "1")
return PLUGIN_CONTINUE
}
public plugin_precache() {
precache_model("models/v_crowbar.mdl")
precache_model("models/v_hgun.mdl")
return PLUGIN_CONTINUE
}
public weaponChange(id) {
if ( !get_cvar_num("amx_teamknives") )
return PLUGIN_CONTINUE
// Get needed information
//
// Weapon ID, Ammo, Clip
new clip, ammo, wpnid = get_user_weapon(id,clip,ammo)
// Team
new team = get_user_team(id);
switch( team ) {
case 1: {
if (wpnid == CSW_KNIFE)
{
entity_set_string(id, EV_SZ_viewmodel, "models/v_crowbar.mdl")
}
}
case 2: {
if (wpnid == CSW_KNIFE)
{
entity_set_string(id, EV_SZ_viewmodel, "models/v_hgun.mdl")
}
}
}
return PLUGIN_CONTINUE
}这个是改变,警察和韭徙小刀模型代码来的
这两个小刀分别是cs1.5自带小刀模型来.不用下截的
第一个是 铁 J
v_crowbar.mdl
第二个是 怪物手
v_hgun.mdl
这两个都有W和P模型的..........
========================
我就想你改一下代码..不单只是V模型..连W和P模型也帮我加一下上去可以吗
v_crowbar.mdl
w_crowbar.mdl
p_crowbar.mdl
v_hgun.mdl
w_hgun.mdl
p_hgun.mdl
帮我改一下啦..谢谢
武器模型分三类:(*为武器名称)
v_*.mdl 手部武器模型 - 为自己看见的手部模型
w_*.mdl 地上武器模型 - 别人也看得见模型
p_*.mdl 人物身上武器模型 - 别人也看得见模型
上面两张图片分别是
v_crowbar.mdl
v_hgun.mdl
麻烦帮一下帮把W和P模型也加上代码去...谢了 哈哈 僵尸服的插件,喜欢啊,呵呵 感谢楼主 #include <amxmodx>
#include <engine>
#include <fakemeta>
new VIEW_MODEL[] = "models/v_<model name>.mdl"
new PLAYER_MODEL[] = "models/p_<model name>.mdl"
new WORLD_MODEL[] = "models/w_<model name>.mdl"
new OLDWORLD_MODEL[] = "models/w_<model name>.mdl" // the world model you want replaced
new PLUGIN_NAME[] = "Custom Weapon Model"
new PLUGIN_AUTHOR[] = "Cheap_Suit"
new PLUGIN_VERSION[] = "1.0"
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")
}
public plugin_precache()
{
precache_model(VIEW_MODEL)
precache_model(PLAYER_MODEL)
precache_model(WORLD_MODEL)
}
public Event_CurWeapon(id)
{
// might not work for other mods
new weaponID = read_data(2)
// eg, if weapon is not ak then continue
if(weaponID != CSW_AK47)
return PLUGIN_CONTINUE
// this set's the view model (what you see when holding the gun)
entity_set_string(id, EV_SZ_viewmodel, VIEW_MODEL)
// this set's the player model (what you see when people holding the gun)
entity_set_string(id, EV_SZ_weaponmodel, PLAYER_MODEL)
return PLUGIN_CONTINUE
}
public fw_SetModel(entity, model[])
{
// check if its a valid entity or else we'll get errors
if(!is_valid_ent(entity))
return FMRES_IGNORED
// checks if it's the model we want to change
if(!equali(model, OLDWORLD_MODEL))
return FMRES_IGNORED
new className
entity_get_string(entity, EV_SZ_classname, className, 32)
// dropped weapons map weapons c4 + grenades
if(equal(className, "weaponbox") || equal(className, "armoury_entity") || equal(className, "grenade"))
{
// set's the world model (what you see on the ground)
entity_set_model(entity, WORLD_MODEL)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}http://forums.alliedmods.net/showthread.php?t=40822
自己动动手弄弄哈,没工具! 大哥我不是要所有人都一样的手部模型啊
我要两边不一样的啊...........
你这代码我看不明白啦..
我的意思可能你不明白吧..我再说清楚一点
这是警的手部模形
v_crowbar.mdl
这是韭的手部模形
v_hgun.mdl
我的代码不是注明了么
我就是想把两边的
w和p也分别加上代码去呀
正确的意思我想这样
这是警的
v_crowbar.mdl
w_crowbar.mdl
p_crowbar.mdl
这是韭徙的
v_hgun.mdl
w_hgun.mdl
p_hgun.mdl #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_szOldWmodel[] = "models/w_knife.mdl";
new const PLUGIN_NAME[] = "";
new const PLUGIN_AUTHOR[] = "";
new const PLUGIN_VERSION[] = "";
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" );
}
public plugin_precache()
{
new i;
for ( 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 ] );
}
}
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;
}自己测试一下! 本帖最后由 点通粉丝 于 2011-3-7 21:06 编辑
阿郎哥'上面的代码编绎时出现以下错误,,首先在些感谢你的代码先'测试失败.看图
为了使插件更具有娱乐性
可不可以再加一些音效上去
用铁J打人为正常小刀音效
v_crowbar.mdl
用v_hgun.mdl打人为
僵尸音效呢
\\\\\\\\\\\\\\\\\\\\\\\\\\
下面为小刀音效
//小刀武器音效
"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" 然后用v_hgun.mdl打人为
这些音效呢
"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" 你要替换的音效少了一个,我在代码里面已经做了注明,自己加上去!#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()
{
new i;
for ( 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 ( 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;
}
自己测试 9# kk阿朗
编绎出现以下错误..........看图
页:
[1]
2