teobrvt1995
T.E.T.Я.I.S
- 19/9/10
- 691
- 2
ai help tớ cái nào :(
pro đâu hết rùi...
pro đâu hết rùi...
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Cám ơn mình đã sửa được trong file .sma cái MONEY_START giờ không còn bị set tiền cố định ở đầu trận nữa rồicái này trong sma của ZB3 ở cái event new round có 1 cái set money đó, del cái đó đi
Im3 vãiCám ơn mình đã sửa được trong file .sma cái MONEY_START giờ không còn bị set tiền cố định ở đầu trận nữa rồi
Thế còn cái mua súng được nhiều lần trong 1 ván đấu Zombie-Mod 3 bạn biết sửa ở đâu không?


rùi restart
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
new g_cvarEnabled;
new g_msgCrosshair;
new g_insight;
new g_HideWeapon;
new crosshair[33];
public plugin_init()
{
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_mp5navy", "iron_sight_mp5", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_ak47", "iron_sight_ak47", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_deagle", "iron_sight_deagle", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_galil", "iron_sight_deagle", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_m249", "iron_sight_m249", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_p90", "iron_sight_m249", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_mac10", "iron_sight_mac10", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_p228", "iron_sight_p228", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_fiveseven", "iron_sight_fiveseven", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_m3", "iron_sight_m3", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_xm1014", "iron_sight_m4", 1 )
RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_tmp", "iron_sight_tmp", 1 )
register_plugin("EIS","1.3","TSA");
g_HideWeapon = get_user_msgid("HideWeapon")
register_event("ResetHUD","event_resethud","b");
register_event("CurWeapon","event_curweapon","b","1=1");
register_event("DeathMsg","event_deathmsg","a");
g_cvarEnabled = register_cvar("sc_enabled","1",FCVAR_SERVER);
}
//precache the models
public plugin_precache()
{
precache_model("models/v_mp5_sight.mdl")
precache_model("models/v_ak47_sight.mdl")
precache_model("models/v_deagle_sight.mdl")
precache_model("models/v_galil_sight.mdl")
precache_model("models/v_m249_sight.mdl")
precache_model("models/v_p90_sight.mdl")
precache_model("models/v_p228_sight.mdl")
precache_model("models/v_mac10_sight.mdl")
precache_model("models/v_fiveseven_sight.mdl")
precache_model("models/v_m3_sight.mdl")
precache_model("models/v_xm1014_sight.mdl")
precache_model("models/v_tmp_sight.mdl")
}
//events
public event_resethud(id)
{
// spawn with crosshair
if(is_user_alive(id))
draw_crosshair(id);
}
// the best part of the code
public client_PreThink(id)
{
//using a mp5
new clip, ammo, weapon = get_user_weapon(id, clip, ammo);
new button = entity_get_int(id,EV_INT_button);
if(weapon == CSW_MP5NAVY)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_mp5(id,0);
}
else
{
unsight_mp5(id,1);
}
}
// disable regular zoom
entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2);
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_mp5(id, 1)
}
}
//using an ak47
if(weapon == CSW_AK47)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_ak47(id,0);
}
else
{
unsight_ak47(id,1);
}
}
// disable regular zoom
entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2);
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_ak47(id, 1)
}
}
//using a deagle
if(weapon == CSW_DEAGLE)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_deagle(id,0);
}
else
{
unsight_deagle(id,1);
}
}
// disable regular zoom
entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2);
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_deagle(id, 1)
}
}
//using a galil
if(weapon == CSW_GALIL)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_galil(id,0);
}
else
{
unsight_galil(id,1);
}
}
// disable regular zoom
entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2);
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_galil(id, 1)
}
}
//using a m249
if(weapon == CSW_M249)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_m249(id,0);
}
else
{
unsight_m249(id,1);
}
}
// disable regular zoom
entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2);
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_m249(id, 1)
}
}
//using a p90
if(weapon == CSW_P90)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_p90(id,0);
}
else
{
unsight_p90(id,1);
}
}
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_p90(id, 1)
}
}
//using a mac10
if(weapon == CSW_MAC10)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_mac10(id,0);
}
else
{
unsight_mac10(id,1);
}
}
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_mac10(id, 1)
}
}
//using a p228
if(weapon == CSW_P228)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_p228(id,0);
}
else
{
unsight_p228(id,1);
}
}
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_p228(id, 1)
}
}
//using a fiveseven
if(weapon == CSW_FIVESEVEN)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_fiveseven(id,0);
}
else
{
unsight_fiveseven(id,1);
}
}
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_fiveseven(id, 1)
}
}
//using a m3
if(weapon == CSW_M3)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_m3(id,0);
}
else
{
unsight_m3(id,1);
}
}
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_m3(id, 1)
}
}
//using a m4
if(weapon == CSW_XM1014)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_m4(id,0);
}
else
{
unsight_m4(id,1);
}
}
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_m4(id, 1)
}
}
//using a tmp
if(weapon == CSW_TMP)
{
// is user pressing right click?
if(button & IN_ATTACK2)
{
// did he just press it?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))
{
if(g_insight == false)
{
iron_sight_tmp(id,0);
}
else
{
unsight_tmp(id,1);
}
}
}
if(button & IN_RELOAD)
{
// did he just press reload?
if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD))
unsight_tmp(id, 1)
}
}
}
// ironsight and crosshair related
public iron_sight_mp5(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_mp5_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_mp5navy 0.5")
}
public unsight_mp5(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_mp5.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_mp5navy 0.8")
}
public iron_sight_ak47(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_ak47_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_ak47 0.4")
}
public unsight_ak47(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_ak47.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_ak47 1.0")
}
public iron_sight_deagle(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_deagle_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_deagle 0.72")
}
public unsight_deagle(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_deagle.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_deagle 0.96")
}
public iron_sight_galil(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_galil_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_galil 0.5")
}
public unsight_galil(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_galil.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_galil 0.96")
}
public iron_sight_m249(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_m249_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_m249 0.4")
}
public unsight_m249(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_m249.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_m249 0.96")
}
public iron_sight_p90(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_p90_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_p90 0.4")
}
public unsight_p90(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_p90.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_p90 0.96")
}
public iron_sight_mac10(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_mac10_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_mac10 0.4")
}
public unsight_mac10(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_mac10.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_mac10 0.96")
}
public iron_sight_p228(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_p228_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_p228 0.4")
}
public unsight_p228(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_p228.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_p228 0.96")
}
public iron_sight_fiveseven(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_fiveseven_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_fiveseven 0.4")
}
public unsight_fiveseven(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_fiveseven.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_fiveseven 0.96")
}
public iron_sight_m3(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_m3_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_m3 0.8")
}
public unsight_m3(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_m3.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_m3 0.96")
}
public iron_sight_m4(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_xm1014_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_xm1014 0.7")
}
public unsight_m4(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_xm1014.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_xm1014 0.96")
}
public iron_sight_tmp(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_tmp_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_tmp 0.7")
}
public unsight_tmp(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_tmp.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_tmp 0.96")
}
public iron_sight_m4a1(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_m4a1_sight.mdl");
g_insight = true
hide_crosshair(id)
client_cmd(id,"amx_recoil_tmp 0.7")
}
public unsight_m4a1(id,enabled)
{
entity_set_string(id,EV_SZ_viewmodel, "models/v_m4a1.mdl");
g_insight = false
draw_crosshair(id)
client_cmd(id,"amx_recoil_tmp 0.96")
}
public draw_crosshair(id)
{
message_begin(MSG_ONE_UNRELIABLE, g_HideWeapon, _,id)
write_byte(0)
message_end()
}
public hide_crosshair(id)
{
message_begin(MSG_ONE_UNRELIABLE, g_HideWeapon, _,id)
write_byte(1<<6)
message_end()
}
Code của bợn dài quáEm viết plugin này để dùng cho mod của em. Té ra cũng hoạt động khá tốt. Em chỉ upload plugin thôi. Còn model mọi người phải tự lo
Nguyên lý hoạt động là thế này: chuyển qua lại giữa model thường và model sight. Nghe khá đơn giản. Và vì mọi người đều biết ỉon sight là cái gì nên chỉ post 1 hình gọi là demo.
![]()
Tiện đây cũng hỏi luôn mọi người, nhất là ai rành AMX coding về một số giới hạn em gặp phải khi viết plugin này.
Thứ nhất, có cách nào để xác định khi player đổi weapon không, để em toggle cái crosshair cho đúng?
Thứ hai, em chưa biết làm sao để làm iron sight cho các weapon có attack2 mặc định, và chuyển attack2 mặc định sang một key khác, chẳng hạn M4A1, right click là iron sight, T là silencer. Ai có cao kiến gì xin chỉ giáo.
Trừ hai giới hạn trên ra, những thứ còn lại đã tạm ổn.
Cảm ơn mọi người nhiều.
Đây là toàn bộ code cho ai muốn giúp thì tham khảo:
Mã:#include <amxmodx> #include <fakemeta> #include <hamsandwich> #include <engine> new g_cvarEnabled; new g_msgCrosshair; new g_insight; new g_HideWeapon; new crosshair[33]; public plugin_init() { RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_mp5navy", "iron_sight_mp5", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_ak47", "iron_sight_ak47", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_deagle", "iron_sight_deagle", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_galil", "iron_sight_deagle", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_m249", "iron_sight_m249", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_p90", "iron_sight_m249", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_mac10", "iron_sight_mac10", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_p228", "iron_sight_p228", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_fiveseven", "iron_sight_fiveseven", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_m3", "iron_sight_m3", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_xm1014", "iron_sight_m4", 1 ) RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_tmp", "iron_sight_tmp", 1 ) register_plugin("EIS","1.3","TSA"); g_HideWeapon = get_user_msgid("HideWeapon") register_event("ResetHUD","event_resethud","b"); register_event("CurWeapon","event_curweapon","b","1=1"); register_event("DeathMsg","event_deathmsg","a"); g_cvarEnabled = register_cvar("sc_enabled","1",FCVAR_SERVER); } //precache the models public plugin_precache() { precache_model("models/v_mp5_sight.mdl") precache_model("models/v_ak47_sight.mdl") precache_model("models/v_deagle_sight.mdl") precache_model("models/v_galil_sight.mdl") precache_model("models/v_m249_sight.mdl") precache_model("models/v_p90_sight.mdl") precache_model("models/v_p228_sight.mdl") precache_model("models/v_mac10_sight.mdl") precache_model("models/v_fiveseven_sight.mdl") precache_model("models/v_m3_sight.mdl") precache_model("models/v_xm1014_sight.mdl") precache_model("models/v_tmp_sight.mdl") } //events public event_resethud(id) { // spawn with crosshair if(is_user_alive(id)) draw_crosshair(id); } // the best part of the code public client_PreThink(id) { //using a mp5 new clip, ammo, weapon = get_user_weapon(id, clip, ammo); new button = entity_get_int(id,EV_INT_button); if(weapon == CSW_MP5NAVY) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_mp5(id,0); } else { unsight_mp5(id,1); } } // disable regular zoom entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2); } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_mp5(id, 1) } } //using an ak47 if(weapon == CSW_AK47) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_ak47(id,0); } else { unsight_ak47(id,1); } } // disable regular zoom entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2); } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_ak47(id, 1) } } //using a deagle if(weapon == CSW_DEAGLE) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_deagle(id,0); } else { unsight_deagle(id,1); } } // disable regular zoom entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2); } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_deagle(id, 1) } } //using a galil if(weapon == CSW_GALIL) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_galil(id,0); } else { unsight_galil(id,1); } } // disable regular zoom entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2); } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_galil(id, 1) } } //using a m249 if(weapon == CSW_M249) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_m249(id,0); } else { unsight_m249(id,1); } } // disable regular zoom entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2); } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_m249(id, 1) } } //using a p90 if(weapon == CSW_P90) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_p90(id,0); } else { unsight_p90(id,1); } } } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_p90(id, 1) } } //using a mac10 if(weapon == CSW_MAC10) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_mac10(id,0); } else { unsight_mac10(id,1); } } } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_mac10(id, 1) } } //using a p228 if(weapon == CSW_P228) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_p228(id,0); } else { unsight_p228(id,1); } } } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_p228(id, 1) } } //using a fiveseven if(weapon == CSW_FIVESEVEN) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_fiveseven(id,0); } else { unsight_fiveseven(id,1); } } } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_fiveseven(id, 1) } } //using a m3 if(weapon == CSW_M3) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_m3(id,0); } else { unsight_m3(id,1); } } } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_m3(id, 1) } } //using a m4 if(weapon == CSW_XM1014) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_m4(id,0); } else { unsight_m4(id,1); } } } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_m4(id, 1) } } //using a tmp if(weapon == CSW_TMP) { // is user pressing right click? if(button & IN_ATTACK2) { // did he just press it? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2)) { if(g_insight == false) { iron_sight_tmp(id,0); } else { unsight_tmp(id,1); } } } if(button & IN_RELOAD) { // did he just press reload? if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_RELOAD)) unsight_tmp(id, 1) } } } // ironsight and crosshair related public iron_sight_mp5(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_mp5_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_mp5navy 0.5") } public unsight_mp5(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_mp5.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_mp5navy 0.8") } public iron_sight_ak47(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_ak47_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_ak47 0.4") } public unsight_ak47(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_ak47.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_ak47 1.0") } public iron_sight_deagle(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_deagle_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_deagle 0.72") } public unsight_deagle(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_deagle.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_deagle 0.96") } public iron_sight_galil(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_galil_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_galil 0.5") } public unsight_galil(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_galil.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_galil 0.96") } public iron_sight_m249(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_m249_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_m249 0.4") } public unsight_m249(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_m249.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_m249 0.96") } public iron_sight_p90(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_p90_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_p90 0.4") } public unsight_p90(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_p90.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_p90 0.96") } public iron_sight_mac10(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_mac10_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_mac10 0.4") } public unsight_mac10(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_mac10.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_mac10 0.96") } public iron_sight_p228(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_p228_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_p228 0.4") } public unsight_p228(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_p228.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_p228 0.96") } public iron_sight_fiveseven(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_fiveseven_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_fiveseven 0.4") } public unsight_fiveseven(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_fiveseven.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_fiveseven 0.96") } public iron_sight_m3(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_m3_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_m3 0.8") } public unsight_m3(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_m3.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_m3 0.96") } public iron_sight_m4(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_xm1014_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_xm1014 0.7") } public unsight_m4(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_xm1014.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_xm1014 0.96") } public iron_sight_tmp(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_tmp_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_tmp 0.7") } public unsight_tmp(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_tmp.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_tmp 0.96") } public iron_sight_m4a1(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_m4a1_sight.mdl"); g_insight = true hide_crosshair(id) client_cmd(id,"amx_recoil_tmp 0.7") } public unsight_m4a1(id,enabled) { entity_set_string(id,EV_SZ_viewmodel, "models/v_m4a1.mdl"); g_insight = false draw_crosshair(id) client_cmd(id,"amx_recoil_tmp 0.96") } public draw_crosshair(id) { message_begin(MSG_ONE_UNRELIABLE, g_HideWeapon, _,id) write_byte(0) message_end() } public hide_crosshair(id) { message_begin(MSG_ONE_UNRELIABLE, g_HideWeapon, _,id) write_byte(1<<6) message_end() }
dùng array + format string có phải nhanh hơn ko
Đã xong.Cho cái đoạn code vào trong thẻ php....
Cái vấn đề thứ 2 thì tham khảo ở trong sma NST WPN Rifle

public plugin_init()
{
RegisterHam(Ham_Weapon_deploy,"weapon_m4a1","fw_blocksilent")
RegisterHam(Ham_Weapon_SecondaryAttack,"weapon_m4a1","fw_blocksilent")
}
public fw_blocksilent(ent)
{
set_pdata_float(ent, 47, 9999.0,4)
}
Chỉ có Ham_Item_Deploy thôiBị lỗi thế này: "Undefined symbol: Ham_Weapon_Deploy'"
Plugin này em viết khi chưa biết xài array, nên mới lung tung thế.

- new g_weapon[][] = {
"weapon_ak47",
"weapon_m4a1",
"weapon_aug"
}
for(new i = 0; i < sizeof(g_weapon); i++)
{
RegisterHam(Ham_Weapon_PrimaryAttack, g_weapon[i], "fw_weapon_primaryattack")
}
public fw_weapon_primaryattack(ent)
{
new id = pev(ent, pev_owner)
client_print(id, print_center, "[BECAREFUL. I AM FIRING]")
}
. mới post dc 13 bài nên ko cho edit bài viết/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
// Danh sach vu khi duoc tao = array
new g_weapon[][] = {
"weapon_ak47",
"weapon_m4a1",
"weapon_aug"
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
// Neu Console bao' la entity out of.... thi sua sizeof thanh charsmax
for(new i = 0; i < sizeof(g_weapon); i++)
{
RegisterHam(Ham_Weapon_PrimaryAttack, g_weapon[i], "fw_weapon_primaryattack")
}
}
public fw_weapon_primaryattack(ent)
{
new id = pev(ent, pev_owner)
client_print(id, print_center, "[BECAREFUL. I AM FIRING]")
}
