|
楼主 |
发表于 2010-2-28 20:46:21
|
显示全部楼层
来自 中国–广东–广州
再发个列子代码.让大家帮忙看一下
这是B13手枪杀敌效果.他里面就有一段这样的代码
deagle_explode(vec1[3])
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(12);
write_coord(vec1[0]);
write_coord(vec1[1]);
write_coord(vec1[2]);
write_byte(200);
write_byte(10);
message_end();
}
但问是下面的代码里.他杀人后也会有这像烟花的爆炸效果
但他不会有爆炸声呀.............
我就想问一下他是怎做到的.情形就是这样了- MODULES required: Fakemeta
- */
- #include <amxmodx>
- #include <fakemeta>
- #define V_MODEL "models/v_deagle.mdl"
- #define W_MODEL "models/w_357.mdl"
- #define P_MODEL "models/p_357.mdl"
- #define DEAGLE_W_MODEL "models/w_357.mdl"
- new
- toggle,toggle_icon,toggle_shake,
- toggle_fade,toggle_explode, toggle_mdl,
- toggle_light,toggle_dur,p_dur,toggle_hs,p_hs;
- new
- shake,atack,
- iconstatus,screenfade;
- new bool:g_Icon[33];
- new white,lightning,g_sModelIndexSmoke;
- new g_Hs[33];
- public plugin_init()
- {
- register_plugin("Deagle Power","2.1.1","anakin_cstrike");
- register_forward(FM_SetModel,"fw_setmodel"/*,1*/);
- register_event("CurWeapon", "event_curw", "be","1=1");
- register_event("DeathMsg","hook_death","a");
-
- toggle = register_cvar("deagle_power","1");
- toggle_shake = register_cvar("deagle_power_shake","0");
- toggle_icon = register_cvar("deagle_power_icon","1");
- toggle_fade = register_cvar("deagle_power_screenflash","0");
- toggle_explode = register_cvar("deagle_power_explode","1");
- toggle_light = register_cvar("deagle_power_light","1");
- toggle_dur = register_cvar("deagle_power_lightduration","6");
- toggle_hs = register_cvar("deagle_power_hs","6");
- toggle_mdl = register_cvar("deagle_power_model","1");
-
- p_dur = get_pcvar_num(toggle_dur);
- p_hs = get_pcvar_num(toggle_hs);
-
- shake = get_user_msgid("ScreenShake");
- iconstatus = get_user_msgid("StatusIcon");
- screenfade = get_user_msgid("ScreenFade");
- }
- public client_connect(id) {g_Hs[id] = 0;g_Icon[id] = false;}
- public client_disconnect(id) {g_Hs[id] = 0;g_Icon[id] = false;}
- public plugin_precache()
- {
- engfunc(EngFunc_PrecacheModel,V_MODEL);
- engfunc(EngFunc_PrecacheModel,P_MODEL);
- engfunc(EngFunc_PrecacheModel,W_MODEL);
- precache_sound( "ambience/mgun_burst4.wav");
- precache_sound( "weapons/headshot2.wav");
- precache_sound( "weapons/flashbang-2.wav");
-
- g_sModelIndexSmoke = precache_model("sprites/steam1.spr");
- lightning = precache_model("sprites/xenobeam.spr");
- white = precache_model("sprites/white.spr");
- return PLUGIN_CONTINUE
- }
- public fw_setmodel(ent,const model[])
- {
- if(get_pcvar_num(toggle) != 1)
- return FMRES_IGNORED;
- if(get_pcvar_num(toggle_mdl) != 1)
- return FMRES_IGNORED;
-
- if(strcmp(DEAGLE_W_MODEL,model))
- return FMRES_IGNORED;
-
- static classname[32]
- pev(ent,pev_classname,classname,31);
-
- if(!strcmp(classname, "weaponbox") || !strcmp(classname, "armoury_entity") || !strcmp(classname, "grenade"))
- {
- engfunc(EngFunc_SetModel,ent,W_MODEL);
- return FMRES_SUPERCEDE;
- }
- return FMRES_IGNORED;
- }
- public event_curw(id)
- {
- if(get_pcvar_num(toggle) != 1)
- return PLUGIN_CONTINUE;
- if(!is_user_alive(id))
- return PLUGIN_CONTINUE;
- new wID = read_data(2);
- if(wID != CSW_DEAGLE)
- return PLUGIN_CONTINUE;
-
- set_pev(id,pev_viewmodel2,V_MODEL);
- set_pev(id,pev_weaponmodel2,P_MODEL);
-
- atack = pev(id,pev_button)
- if(wID == CSW_DEAGLE && get_pcvar_num(toggle_shake) == 1 && atack & IN_ATTACK)
- {
- message_begin(MSG_ONE,shake,{0,0,0},id);
- write_short(1<<13);
- write_short(1<<13);
- write_short(1<<13);
- message_end();
- }
- return PLUGIN_CONTINUE;
- }
- public hook_death()
- {
- if(get_pcvar_num(toggle) != 1)
- return PLUGIN_CONTINUE;
- static weapon[2];
- read_data(4,weapon,1);
- if(weapon[0] != 'd')
- return PLUGIN_CONTINUE;
-
- static killer,victim,kname[32];
- killer = read_data(1);
- victim = read_data(2);
- get_user_name(killer,kname,31);
- g_Hs[victim] = 0;
- if(read_data(3))
- {
- g_Hs[killer]++;
- if(get_pcvar_num(toggle_icon) == 1)
- {
- g_Icon[killer] = true;
- message_begin(MSG_ONE,iconstatus,{0,0,0},killer);
- write_byte(2);
- write_string("dmg_shock");
- write_byte(255);
- write_byte(0);
- write_byte(0);
- message_end();
- set_task(3.0,"reset_icon",killer);
- }
- if(get_pcvar_num(toggle_explode) == 1)
- {
- new vorigin[3],srco[3];
- get_user_origin(victim,vorigin);
- vorigin[2] -= 26
- srco[0] = vorigin[0] + 30
- srco[1] = vorigin[1] + 40
- srco[2] = vorigin[2] + 120
-
- switch(random_num(1,3))
- {
- case 1:
- {
- emit_sound(0,CHAN_ITEM, "ambience/mgun_burst4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
- deagle_thunder(srco,vorigin);
- }
- case 2:
- {
- emit_sound(0,CHAN_ITEM, "weapons/headshot2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
- deagle_blood(vorigin);
- }
- case 3:
- {
- emit_sound(0,CHAN_ITEM, "weapons/flashbang-2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
- deagle_explode(vorigin);
- }
- }
- }
- if(!is_user_alive(victim) && !is_user_bot(victim) && get_pcvar_num(toggle_fade) == 1)
- {
- message_begin(MSG_ONE_UNRELIABLE,screenfade,{0,0,0},victim);
- write_short(6<<10);
- write_short(5<<10);
- write_short(1<<12);
- write_byte(255);
- write_byte(0);
- write_byte(0);
- write_byte(170);
- message_end();
- }
- if(g_Hs[killer] == p_hs)
- {
- set_hudmessage(85, 215, 255, 0.1, 0.20, 0, 6.0, 5.0);
- show_hudmessage(0, "%s: Deagle Warrior !",kname);
- if(get_pcvar_num(toggle_light) == 1)
- {
- lights("d");
- set_task(float(p_dur),"relights");
- }
- g_Hs[killer] = 0;
- }
- }
- if(g_Icon[victim])
- {
- g_Icon[victim] = false;
- message_begin(MSG_ONE,iconstatus,{0,0,0},victim);
- write_byte(0);
- write_string("dmg_shock");
- message_end();
- }
- return PLUGIN_CONTINUE;
- }
- deagle_explode(vec1[3])
- {
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY,vec1);
- write_byte(21);
- write_coord(vec1[0]);
- write_coord(vec1[1]);
- write_coord(vec1[2] + 16);
- write_coord(vec1[0]);
- write_coord(vec1[1]);
- write_coord(vec1[2] + 1936);
- write_short(white);
- write_byte(0);
- write_byte(0);
- write_byte(2);
- write_byte(80);
- write_byte(0);
- write_byte(188);
- write_byte(220);
- write_byte(205);
- write_byte(60);
- write_byte(0);
- message_end();
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
- write_byte(12);
- write_coord(vec1[0]);
- write_coord(vec1[1]);
- write_coord(vec1[2]);
- write_byte(120);
- write_byte(10);
- message_end();
-
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY,vec1);
- write_byte(5);
- write_coord(vec1[0]);
- write_coord(vec1[1]);
- write_coord(vec1[2]);
- write_short(g_sModelIndexSmoke);
- write_byte(2);
- write_byte(10);
- message_end();
- }
- deagle_thunder(vec1[3],vec2[3])
- {
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
- write_byte(0);
- write_coord(vec1[0]);
- write_coord(vec1[1]);
- write_coord(vec1[2]);
- write_coord(vec2[0]);
- write_coord(vec2[1]);
- write_coord(vec2[2]);
- write_short(lightning);
- write_byte(1);
- write_byte(5);
- write_byte(2);
- write_byte(30);
- write_byte(250);
- write_byte(200);
- write_byte(200);
- write_byte(200);
- write_byte(200);
- write_byte(250);
- message_end();
- message_begin( MSG_PVS, SVC_TEMPENTITY,vec2);
- write_byte(9);
- write_coord(vec2[0]);
- write_coord(vec2[1]);
- write_coord(vec2[2]);
- message_end();
-
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY,vec2);
- write_byte(5);
- write_coord(vec2[0]);
- write_coord(vec2[1]);
- write_coord(vec2[2]);
- write_short(g_sModelIndexSmoke);
- write_byte(10);
- write_byte(10)
- message_end();
- }
- deagle_blood(vec1[3])
- {
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
- write_byte(10);
- write_coord(vec1[0]);
- write_coord(vec1[1]);
- write_coord(vec1[2]);
- message_end();
- }
- public reset_icon(id)
- {
- message_begin(MSG_ONE,iconstatus,{0,0,0},id);
- write_byte(0);
- write_string("dmg_shock");
- message_end();
- }
- public relights() lights("n");
- stock lights(const light[]) return engfunc(EngFunc_LightStyle,0,light);
复制代码 7# 点通粉丝 |
|