[AMX] Tổng hợp Code, Plug do Mem chế hoặc giới thiệu

  • Thread starter Thread starter Orpheus
  • Ngày gửi Ngày gửi
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 :D
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.

hl_2011-07-21_14-09-00-60.png


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:

PHP:
 #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()
}
Sao code từng khẩu 1 thế, thử rút ngắn lại xem nào .
P/s: Đang ngoài hàng, k biết đến bao h mới có mạng mà dùng :((
 
plugin của TSA đc chỉnh sửa 1 chút và dùng cho CW2 đó ;))
@All : AI có plugin cấm chuyển sag dao ko
 
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 :D
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.

hl_2011-07-21_14-09-00-60.png


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:

PHP:
 #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()
}
Tớ cũng đang xài cái plugin tương tự như vậy, nhưng lúc chơi hay bị văng ra menu lắm, các pro có biết tại sao ko? console báo lỗi not client gì gì đó ko hiểu...
 
plugin của TSA đc chỉnh sửa 1 chút và dùng cho CW2 đó ;))
@All : AI có plugin cấm chuyển sag dao ko
Hèn gì bên VNZ nghe loáng thoáng "quay clip plugin của VN-Zombie" gì đó :))
Mà thôi, giờ em đã chuyển Advanced Assault qua Source Engine 2009 ( muốn biết Advanced Assault là cái gì cứ click vào chữ kí :)) ), trong team của em đã có lập trình viên C++ và modeller chuyên nghiệp, bản thân em cũng đang học lập trình C++ và HL2 modding nên plugin này không còn cần thiết nữa. Ai thích modify hay re-distribute thì cứ tự nhiên :D
 
Plugin portal mod nay của game portal chơi khá hay , bạn chỉ cần ném 1 lỗ xanh lên tường trong map và 1 lỗ đỏ đi vô tường là nhảy sang bên kia
Game Portal
[YOUTUBE]TluRVBhmf8w[/YOUTUBE]

map
http://www.sendspace.com/file/pvd2xw
[YOUTUBE]jpNDK2fQCHA[/YOUTUBE]

mod + Plugin
[YOUTUBE]W0wdNa-Sqm0[/YOUTUBE]

http://depositfiles.com/files/mdjirx6v3

http://amxx.pl/topic/51842-portal-gun
Hai cái pic cho mọi người
1315278741_64266348.jpg

47447_108071559254191_100001540434718_68723_3136519_n.jpg


Warning ko được chơi theo kiểu này
[YOUTUBE]3L-rrkyvApU[/YOUTUBE]
:)):)):)):))
GOOD LUCK , NOW YOU WILL THINKING WITH PORTAL

---------- Post added at 12:29 ---------- Previous post was at 12:27 ----------

trời ạ trên đây post video với sửa bài sao thế
 
@TSA : source engine hình như có gmod rồi, iron sight xog run đủ hết =))
 
@TSA : source engine hình như có gmod rồi, iron sight xog run đủ hết =))
Kệ Gmod :))
Em sẽ mod với Source Engine 2009, chính xác là mod CS:Source, có iron sight, sprint đủ cả, với cảm giác bắn của CSS, và quan trọng nhất là sẽ chia class ra chứ không phải chọn class nào cũng được :D
 
Kệ Gmod :))
Em sẽ mod với Source Engine 2009, chính xác là mod CS:Source, có iron sight, sprint đủ cả, với cảm giác bắn của CSS, và quan trọng nhất là sẽ chia class ra chứ không phải chọn class nào cũng được :D
thấy dc 41% rồi:-?
mong đợi bản này quá :x
p/s:
(I JUST WANT TO DEVOTE SOMETHING FOR THE CS COMMUNITY, NOT EARNING MONEY, AND I DON'T HAVE MONEY TO PAY FOR YOUR HELP. SORRY TO SAY THAT)
LIKE!!!!!!!!!!!
 
Chỉnh sửa cuối:
Kệ Gmod :))
Em sẽ mod với Source Engine 2009, chính xác là mod CS:Source, có iron sight, sprint đủ cả, với cảm giác bắn của CSS, và quan trọng nhất là sẽ chia class ra chứ không phải chọn class nào cũng được :D
Striker_All phải ko? Mong cậu sẽ sớm hoàn thành xong bản mod đó! Nhưng tớ thấy Gmod cũng nhiều plugin hay lắm đó, còn bản của cậu khác như thế nào?
 
Hèn gì bên VNZ nghe loáng thoáng "quay clip plugin của VN-Zombie" gì đó :))
Mà thôi, giờ em đã chuyển Advanced Assault qua Source Engine 2009 ( muốn biết Advanced Assault là cái gì cứ click vào chữ kí :)) ), trong team của em đã có lập trình viên C++ và modeller chuyên nghiệp, bản thân em cũng đang học lập trình C++ và HL2 modding nên plugin này không còn cần thiết nữa. Ai thích modify hay re-distribute thì cứ tự nhiên :D
Mod kiểu này mới thích
waiting ... :x
 
nhiều súng ống đạn dược nữa thì quá tuyệt,100% y như mình hằng mong đợi
ý tưởng giống mình vãi =))
 
Kệ Gmod :))
Em sẽ mod với Source Engine 2009, chính xác là mod CS:Source, có iron sight, sprint đủ cả, với cảm giác bắn của CSS, và quan trọng nhất là sẽ chia class ra chứ không phải chọn class nào cũng được :D
Chắc ko đó, trên thế giới nhiều người giỏi lập trình nhưng chưa chắc đã mod đc css đâu, huống chi cậu mới chỉ là beginer
 
Chắc ko đó, trên thế giới nhiều người giỏi lập trình nhưng chưa chắc đã mod đc css đâu, huống chi cậu mới chỉ là beginer
nhóc đấy bên dân modeller mà =)) coder chính là người khác
 
nhóc đấy bên dân modeller mà =)) coder chính là người khác
Thế còn spr vs UI =))
NẾu nói về mod chỉ riêng skin cho CSS thì cũng hơi bị nhọc đó, khai thác đủ thứ, chứ chưa nói đến mod gameplay and mode <= Cái này chắc chả có hy vọng gì 8->
P/s: Ước gì có ai đó đứng dậy mod game css nhỉ, đem zombie3 từ CSONST về CSS nhỉ. Ai mod đc cho cái thẻ đt 20k \m/
 
Thế còn spr vs UI =))
NẾu nói về mod chỉ riêng skin cho CSS thì cũng hơi bị nhọc đó, khai thác đủ thứ, chứ chưa nói đến mod gameplay and mode <= Cái này chắc chả có hy vọng gì 8->
P/s: Ước gì có ai đó đứng dậy mod game css nhỉ, đem zombie3 từ CSONST về CSS nhỉ. Ai mod đc cho cái thẻ đt 20k \m/
spr và ui đơn giản :-j chỉ là file vtf thôi, chủ yếu vẫn là coder
 
Valve public source CS:S à=))nếu thế thì convert qua HLSDK --> làm lại CS thôi=))
 
MƠ hả 8->, nó bỏ mấy năm trời dev để rồi pu líck hả ;))
 
LOL.... Lại có người muốn modify CSS như kiểu hay làm với CS1.6 á =))... Đến bây giờ cái nguồn Source Engine còn khó khai thác, plugin của nó cũng ít. Nếu mà tính như thế thì học luôn SDK Source rồi make 1 mod mới luôn cho còn gì nữa...
 
LOL.... Lại có người muốn modify CSS như kiểu hay làm với CS1.6 á =))... Đến bây giờ cái nguồn Source Engine còn khó khai thác, plugin của nó cũng ít. Nếu mà tính như thế thì học luôn SDK Source rồi make 1 mod mới luôn cho còn gì nữa...
Đúng vậy, cho nên em mới chuyển mod qua làm bằng Source SDK.
Mọi người đừng có lo về khoảng coding, sẽ không chỉ có một người code đâu. Còn thêm vài người nữa. Ai muốn giúp cứ giúp, mọi người đều được "welcome".
Em bảo tên coder dùng mã nguồn HL2 đi, Valve làm gì có public mã nguồn CS:S, thế mà nó cứ khăng khăng là có mã nguồn CS:S, vì anh họ của nó làm ở Valve :-o
Còn model thì... để mai tính. Tất nhiên chỉ một mình em thì đừng có hòng làm hết model :))
Mà thôi, bàn chuyện ấy ở topic này coi bộ lạc đề rồi. Để sau này mod đã nên hình nên dáng rồi em sẽ lập topic kêu gọi giúp đỡ. =))
 
Back
Top