[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
He he, đẹp trai + ga lăng + nhiều xiền = các em không nguyện chết vì chú thì anh đâm dao tự tử luôn :))
Mà chú học chuyên anh rồi thì cần gì tán em nào nữa, cứ thế mà đọc .inc, đọc nó xong thấy làm plugin dễ hơn hẳn

Dias tích cực dạy học trò ghê, có lẽ ông nên làm 1 topic riêng, chỉ post các bài giảng cho các recuit, :). Post từ bài cơ bản đến nâng cao (tôi cũng thích làm lắm, nhưng mỗi tội lười + kiến thức sư phạm để dạy người khác = 0 )
Tương lai các bản MOD không thiếu lực lượng coder rồi
Ông có biết cách nào để get client cvar kiểu như cl_forwardspeed ko?
_______________________________________________________________________________________________________
GVN S.V.E.N Member - kungfulon
 
Ai có plugins nst_combo_zombie không,cho mình xin với Nhưng mà cái plugins này nó không trùng với Nst_Effect_kill vì thấy mọi người bảo nó không dùng đc 2 cái :(
P/S:Mấy hôm nữa rảnh chắc là phải học amx thui,vì cứ lên mạng hỏi như ntn thì mấy anh lại phải khổ công làm ;;)
 
Ai có plugins nst_combo_zombie không,cho mình xin với Nhưng mà cái plugins này nó không trùng với Nst_Effect_kill vì thấy mọi người bảo nó không dùng đc 2 cái :(
P/S:Mấy hôm nữa rảnh chắc là phải học amx thui,vì cứ lên mạng hỏi như ntn thì mấy anh lại phải khổ công làm ;;)
Côm bô cho ZP á?
 
Thử get bằng get_cvar_num("cl_forward_speed")
 
Cộng cho bác dias 1 rep ^^
Bác Dias viết thêm tut đi...

__________________________Edit by buiducduy_111
 
ồ, thế thì xài module cvar ultility đi, nhiều cái hay lắm, hook được cả bọn client cvar nữa đó
 
He he, đẹp trai + ga lăng + nhiều xiền = các em không nguyện chết vì chú thì anh đâm dao tự tử luôn :))
Mà chú học chuyên anh rồi thì cần gì tán em nào nữa, cứ thế mà đọc .inc, đọc nó xong thấy làm plugin dễ hơn hẳn

Dias tích cực dạy học trò ghê, có lẽ ông nên làm 1 topic riêng, chỉ post các bài giảng cho các recuit, :). Post từ bài cơ bản đến nâng cao (tôi cũng thích làm lắm, nhưng mỗi tội lười + kiến thức sư phạm để dạy người khác = 0 )
Tương lai các bản MOD không thiếu lực lượng coder rồi
Okie, đồng ý luôn, bác Dias làm luôn cái topic như thế đi. Ngày xưa sếp oko dạy convert skin xong là hàng loạt Brồ ra đời đấy thôi =))
 
@5c0r:
Cái này hook phải ko nhỉ :-??

@legiondark + madboy95:
- tôi có cả site tut mà giờ die roài. Lười leech từ site đó qua đây lắm :(.
- Restore lại site cho mấy bác này, tôi ko viết tut ở đó nữa để cho các bác tham quan thôi =)). http://modvn.com/old_blog/

@redplane:
- Bác có sài emessenger, live, gmail gì ko. Liên lạc hỏi cho dễ :))

@kungfulon:
- Tôi sẽ leech 1 số tut mới qua đây, ông chịu khó chia Post đầu ra làm 2 phần: Tutorial và Plugin nhá =)) để lộn khó tìm
============================================================================================================

[Tutorial] Patch Non-Steam & P47 + P48

Như các bạn đã thấy, Steam đã update Game CS ngày càng lên mới hơn.
Và đã xuất hiện 2 Protocol 47 và 48. và Steam. Rất khó sử, khi Server P48 mà Client P47, hoặc non-steam hay steam. Phải phù hợp mới chơi được. Vì thế mình xin hướng dẫn các bạn cách Patch Non-Steam và P47 + P48. Làm cho 1 server có thể chơi cả Steam và Non-Steam, P47 và P48 luôn.
========================================
1. Download: http://www.mediafire.com/?0mhbqlfe0efxs3m
=> Tải “dproto.zip” về, rồi giải nén vào thư mục cstrike
2. Vào “addons/metamod”, mở file plugins.ini lên.
=> Thêm vào cuối cùng là:
* Có 2 loại:
A. Nếu bạn là Server Win thì add vào cuối cùng là:

Mã:
win32 addons/dproto/dproto.dll

B. Nếu bạn là Server Linux thì add vào cuối cùng là:

Mã:
linux addons/dproto/dproto_i386.so

3. Save lại
4. Quay lại thư mục cstrike, nơi mình đã giải nén file “dproto.zip”
=> Mở file “server.cfg” lên, rồi thêm vào cuối cùng là:

Mã:
exec dproto.cfg

5. Save lại
6. Giờ bật server lên thử xem. Bây giờ bất cứ steam hay non-steam hay p47, p48 đều chơi được server của bạn hết.

============================================================================================================

[Tutorial] Đặt riêng ID cho từng task (Tránh lộn task này sang task kia)

- Trong AMX chắc ai cũng biết set_task và remove_task. Nhưng khi mình phải set nhiều task hay remove nhiều task. thì có thể nhầm lộn. task này remove task nọ. task nọ remove task kia. Nên hôm nay mình xin hướng dẫn cho các bạn đặt riêng từng task, không bị lộn nữa.

PHP:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>

#define PLUGIN “Task ID”
#define VERSION “1.0″
#define AUTHOR “Dias”

#define TASK_ID1 = 1000
#define TASK_ID2 = 2000
// Đặt một số bất kì.

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd(“set_task”, “set_task1″)
}

public set_task1(id)
{
set_task(5.0, “task1″, id+TASK_ID1) // + Thêm TASK_ID1 để phân đây là của TASK_ID1
set_task(10.0, “task2″, id+TASK_ID2) // + Thêm TASK_ID2 để phân đây là của TASK_ID2
}

public task1(taskid)
{
new id = taskid – TASK_ID1 // Có mượn thì phải có trả, nếu trên kia cộng thì dưới đây trừ.
remove_task(id) // Remove TASK_ID1
}

// Nếu không bạn có thể làm như sau:
public task1(id)
{
remove_task(id-TASK_ID1) // Cách này có thể gọn hơn. Remove TASK_ID1
}

public task2(id)
{
remove_task(id-TASK_ID2) // Remove TASK_ID2
}

============================================================================================================

[Tutorial] Viết tiếng việt có dấu trong server.

123.png

- Cách làm thì cũng rất đơn giản. Các bạn đều biết, lang trong CS luôn luôn ở dạng ANSI. và khi viết tiếng việt có dấu thì, bị lỗi ngay. Lỗi thành mấy cái dấu “???”

- Tiếng việt của ta thì ở dạng UTF-8, vậy sao không chuyển dạng ANSI thành UTF-8.

ở đây mình dùng Notepad++, và sài lang “UTF-8 Without BOM”, còn “UTF-8″ thì chưa test…

Như vầy nè:
123.png


Kết Quả:
123.png


:-?? :-?? :-??
 
Chỉnh sửa cuối:
+REP +REP, tuyệt quá ...:-*

À, anh xem dùm em cái em edit kill_efect.sma của nst sao ko complie được anh?

PHP:
diub#include <amxmodx>
#include <fakemeta>

#include <nst_player>
#include <nst_zombie>
#include <nst_wpn>


#define PLUGIN "Effects Killer"
#define VERSION "3.0"
#define AUTHOR "NST"

#define LEVELS 8
new kills[33], Float:timekill[33], revenge[33], oneshot[33]
new iconstatus, g_firstkill, g_lastkill
new g_FM_Running
new cvar_time_kill, cvar_type, cvar_time_show

new const sound_combo[][] =
{
	"vox/kill/%s/kill_1_%s.wav", 
	"vox/kill/%s/kill_2_%s.wav", 
	"vox/kill/%s/kill_3_%s.wav", 
	"vox/kill/%s/kill_4_%s.wav", 
	"vox/kill/%s/kill_5_%s.wav", 
	"vox/kill/%s/kill_6_%s.wav", 
	"vox/kill/%s/kill_7_%s.wav", 
	"vox/kill/%s/kill_8_%s.wav", 
	"vox/kill/%s/revenge_%s.wav", 
	"vox/kill/%s/headshot_%s.wav", 
	"vox/kill/%s/knife_%s.wav", 
	"vox/kill/%s/grenade_%s.wav"
}
enum(+= 100)
{
	TASK_HIDESPR = 2000
}
#define ID_HIDESPR (taskid - TASK_HIDESPR)
enum
{
	HUD_SOUND = 1,
	HUD_MSGTEXT,
	HUD_SPRNAME
}
enum
{
	KILL_1 = 1,
	KILL_2,
	KILL_3,
	KILL_4,
	KILL_5,
	KILL_6,
	KILL_7,
	KILL_8,
	KILL_FIRST,
	C4_DEFUSE,
	C4_SET
}
enum
{
	KILL_NONE = 51,
	KILL_HEGRENADE,
	KILL_HEADSHOT,
	KILL_KNIFE,
	KILL_LAST,
	KILL_REVENGE,
	WALLSHOT,
	WALLSHOT_HEADSHOT,
	ONESHOT_2KILL,
	ONESHOT_3KILL
}


public plugin_precache()
{
	for (new i = 1; i <= 2; i++)
	{
		new sex[32]
		if (i == 1) sex = "woman"
		else sex = "man"
		
		for (new e = 0; e <= 11; e++)
		{
			new sound_ct[100], sound_t[100], team_ct[32] = "ct", team_t[32] = "t"
			format(sound_ct, 99, sound_combo[e], sex, team_ct)
			format(sound_t, 99, sound_combo[e], sex, team_t)
			//precache_sound(sound_ct)
			//precache_sound(sound_t)
		}
		
	}
	//precache_sound("misc/MultiKill/C4_Defuse.wav")
	//precache_sound("misc/MultiKill/C4_Set.wav")
	
}
public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
	register_event("DeathMsg", "event_DeathMsg", "a")
	
	cvar_time_kill = register_cvar("nst_ek_time_kill","3")
	cvar_type = register_cvar("nst_ek_type","1")
	cvar_time_show = register_cvar("nst_ek_time_show","2.0")
	
	iconstatus = get_user_msgid("StatusIcon")
	g_FM_Running = is_module_loaded("FakeMeta")
}
public event_round_start()
{
	new reset_value[33]

	g_firstkill = 1
	kills = reset_value
	revenge = reset_value
	oneshot = reset_value
}
public event_DeathMsg()
{
	// get value data
	static killer, headshot, weapon[32], wpnindex, victim
	killer = read_data(1)
	victim = read_data(2)
	headshot = read_data(3)
	read_data(4, weapon, charsmax(weapon))
	if (equali(weapon, "grenade")) format(weapon, charsmax(weapon), "hegrenade")
	format(weapon, charsmax(weapon), "weapon_%s", weapon)
	wpnindex = get_weaponid(weapon)
	
	// none killer = victim
	if (!is_user_connected(killer) || !is_user_connected(victim) || killer==victim) return;
	if (get_user_team(killer)==get_user_team(victim) && !get_cvar_num("mp_friendlyfire")) return;
	
	// reset kills of victim
	kills[victim] = 0

	// set revenge of victim
	revenge[victim] = killer

	// get num kill & one shoot multikill
	new Float:timeleft = get_gametime()-timekill[killer]
	if (timeleft <= get_pcvar_float(cvar_time_kill)) kills[killer] += 1
	else kills[killer] = 1
	if (kills[killer]>LEVELS) kills[killer] = 1
	timekill[killer] = get_gametime()

	if (!oneshot[killer]) oneshot[killer] = 1
	if (!timeleft && wpnindex != CSW_HEGRENADE) oneshot[killer] += 1
	else oneshot[killer] = 1
	oneshot[killer] = min(3, oneshot[killer])
	//client_print(killer, print_chat, "%i", oneshot[killer])
	
	// get last kill
	new players_ct[32], players_t[32], ict, ite
	get_players(players_ct,ict,"ae","CT")   
	get_players(players_t,ite,"ae","TERRORIST")
	if (ict == 0 || ite == 0) g_lastkill = 1
	
	// check revenge
	new g_revenge
	if (victim == revenge[killer])
	{
		g_revenge = 1
		revenge[killer] = 0
	}

	// hud 1
	new check_sound
	if (oneshot[killer] > 1)
	{
		if (oneshot[killer] == 2) show_hud(killer, ONESHOT_2KILL)
		else if (oneshot[killer] == 3) show_hud(killer, ONESHOT_3KILL)
	}
	else if (g_lastkill)
	{
		g_lastkill = 0
		show_hud(killer, KILL_LAST)
	}	
	else if (g_revenge)
	{
		play_sound(killer, KILL_REVENGE)
		show_hud(killer, KILL_REVENGE)
	}
	else if ((wpnindex != CSW_KNIFE) && (wpnindex != CSW_HEGRENADE) && !can_see_fm(killer, victim)) 
	{
		if (headshot)
		{
			if (kills[killer] == 1)
			{
				play_sound(killer, KILL_HEADSHOT)
				check_sound = 1
			}
			show_hud(killer, WALLSHOT_HEADSHOT)
		}
		else show_hud(killer, WALLSHOT)
	}
	else if (headshot && wpnindex)
	{
		if (kills[killer] == 1)
		{
			play_sound(killer, KILL_HEADSHOT)
			check_sound = 1
		}
		show_hud(killer, KILL_HEADSHOT)
	}
	else if (wpnindex == CSW_KNIFE)
	{
		if (kills[killer] == 1)
		{
			play_sound(killer, KILL_KNIFE)
			check_sound = 1
		}
		show_hud(killer, KILL_KNIFE)
	}
	else if (wpnindex == CSW_HEGRENADE)
	{
		if (kills[killer] == 1)
		{
			play_sound(killer, KILL_HEGRENADE)
			check_sound = 1
		}
		show_hud(killer, KILL_HEGRENADE)
	}
	else
	{
		show_hud(killer, KILL_NONE)
	}
	
	
	// hud 2
	if (g_firstkill)
	{
		g_firstkill = 0
		show_hud(killer, KILL_FIRST)
		if (!check_sound) play_sound(killer, KILL_1)
	}
	else
	{
		show_hud(killer, kills[killer])
		if (!check_sound) play_sound(killer, kills[killer])
	}

}
public bomb_defused(id)
{
	show_hud(id, C4_DEFUSE)
	play_sound(id, C4_DEFUSE)
}
public bomb_planted(id)
{
	show_hud(id, C4_SET)
	play_sound(id, C4_SET)
}


// #################### SHOW HUD ####################
show_hud(id, idhud)
{
	if (!is_user_connected(id)) return;
	
	new type_cvar = get_pcvar_num(cvar_type)
	if (type_cvar == 1) show_spr(id, idhud)
	else if (type_cvar == 2) show_msg(id, idhud)
}
play_sound(id, idhud)
{
	if (!is_user_connected(id)) return;
	
	new sound[64], team[32], sex[32], cs_team
	if (nst_get_mod_runing()==NST_MOD_ZB3) cs_team = nst_get_user_team(id)
	else cs_team = get_user_team(id)
		
	if (cs_team==1) team = "T"
	else team = "CT"
	if (get_user_sex(id) == 2) sex = "woman"
	else sex = "man"
	format(sound, charsmax(sound), "%s", get_hud_data(idhud, HUD_SOUND))
	format(sound, charsmax(sound), sound, sex, team)
	
	PlaySound(id, sound)
}

show_msg(id, idhud)
{
	new msg[64]
	format(msg, charsmax(msg), "%s", get_hud_data(idhud, HUD_MSGTEXT))

	set_hudmessage(0, 204, 0, -1.0, 0.65, 1, 0.02, 3.0, 0.3, 0.3, 2)
	show_hudmessage(id, msg)
}
show_spr(id, idspr)
{
	if (idspr >= KILL_NONE) hide_spr(id, 2)
	else hide_spr(id, 1)

	spr_action(id, idspr, 1)
	
	if (idspr < KILL_NONE)
	{
		if (task_exists(id+TASK_HIDESPR)) remove_task(id+TASK_HIDESPR)
		set_task(get_pcvar_float(cvar_time_show), "task_hidehud", id+TASK_HIDESPR)
	}
} 
public task_hidehud(taskid)
{
	new id = ID_HIDESPR
	hide_spr(id, 2)
	hide_spr(id, 1)

}
hide_spr(id, idspr)
{
	if (idspr == 1)
	{
		for (new i = KILL_1; i <= C4_SET; i++)
		{
			spr_action(id, i, 0)
		}
	}
	else if (idspr == 2)
	{
		for (new i = KILL_NONE; i <= ONESHOT_3KILL; i++)
		{
			spr_action(id, i, 0)
		}
	}
}  
spr_action(id, spr, run)
{	
	new sprname[64]
	format(sprname, charsmax(sprname), "%s", get_hud_data(spr, HUD_SPRNAME))

	message_begin(MSG_ONE,iconstatus,{0,0,0},id)
	write_byte(run) // status (0=hide, 1=show, 2=flash)
	write_string(sprname) // sprite name
	message_end()
}
get_hud_data(idhud, type)
{
	new value[64], sprname[33], sound[64], msgtext[32]
	
	switch (idhud)
	{
		case KILL_1:
		{
			sprname = "kill_1"
			sound = "vox/kill/%s/kill_1_%s"
			msgtext = "1 KILL"
		}
		case KILL_2:
		{
			sprname = "kill_2"
			sound = "vox/kill/%s/kill_2_%s"
			msgtext = "2 KILL"
		}
		case KILL_3:
		{
			sprname = "kill_3"
			sound = "vox/kill/%s/kill_3_%s"
			msgtext = "3 KILL"
		}
		case KILL_4:
		{
			sprname = "kill_4"
			sound = "vox/kill/%s/kill_4_%s"
			msgtext = "4 KILL"
		}
		case KILL_5:
		{
			sprname = "kill_5"
			sound = "vox/kill/%s/kill_5_%s"
			msgtext = "5 KILL"
		}
		case KILL_6:
		{
			sprname = "kill_6"
			sound = "vox/kill/%s/kill_6_%s"
			msgtext = "6 KILL"
		}
		case KILL_7:
		{
			sprname = "kill_7"
			sound = "vox/kill/%s/kill_7_%s"
			msgtext = "7 KILL"
		}
		case KILL_8:
		{
			sprname = "kill_8"
			sound = "vox/kill/%s/kill_8_%s"
			msgtext = "8 KILL"
		}
		case KILL_FIRST:
		{
			sprname = "kill_first"
			msgtext = "FIRST KILL"
			client_print(id, print_chat, "Ban duoc cong %d EXP khi danh duoc %s", 50, FIRST_KILL)
		}
		case C4_DEFUSE:
		{
			sprname = "c4_defuse"
			sound = "vox/kill/c4_defuse"
			client_print(id, print_chat, "Ban duoc cong %d EXP khi go %s thanh cong", 50, C4)
		}
		case C4_SET:
		{
			sprname = "c4_set"
			sound = "vox/kill/c4_set"
			client_print(id, print_chat, "Ban duoc cong %d EXP khi dat %s thanh cong", 50, C4)
		}
	
	
		case KILL_NONE:
		{
			sprname = "kill_none"
		}
		case KILL_HEGRENADE:
		{
			sprname = "kill_he"
			sound = "vox/kill/%s/grenade_%s"
			msgtext = "GRENADE KILL"
		}
		case KILL_HEADSHOT:
		{
			sprname = "kill_headshot"
			sound = "vox/kill/%s/headshot_%s"
			msgtext = "HEADSHOT"
		}
		case KILL_KNIFE:
		{
			sprname = "kill_knife"
			sound = "vox/kill/%s/knife_%s"
			msgtext = "KNIFE KILL"
		}
		case KILL_LAST:
		{
			sprname = "kill_last"
			client_print(id, print_chat, "Ban duoc cong %d EXP khi danh duoc %s", 50, LAST_KILL)
		}
		case KILL_REVENGE:
		{
			sprname = "kill_revenge"
			sound = "vox/kill/%s/revenge_%s"
			msgtext = "REVENGE"
		}
		case WALLSHOT:
		{
			sprname = "wall_shot"
			msgtext = "WALLSHOOT"
		}
		case WALLSHOT_HEADSHOT:
		{
			sprname = "wall_shot_hs"
			msgtext = "WALLSHOOT HEADSHOT"
		}
		case ONESHOT_2KILL:
		{
			sprname = "1shot_2kill"
			msgtext = "ONE SHOT 2 KILL"
		}
		case ONESHOT_3KILL:
		{
			sprname = "1shot_3kill"
			msgtext = "ONE SHOT MULTIKILL"
		}
	}

	if (type==HUD_SOUND) format(value, charsmax(value), "%s", sound)
	else if (type==HUD_MSGTEXT) format(value, charsmax(value), "%s", msgtext)
	else if (type==HUD_SPRNAME) format(value, charsmax(value), "%s", sprname)
	
	return value;
}
get_user_sex(id)
{
	new mod_runing, sex
	mod_runing = nst_get_mod_runing()
	if ( (mod_runing == NST_MOD_ZB3 || mod_runing == NST_MOD_ZBU || mod_runing == NST_MOD_ZBS) && nst_zb_get_user_zombie(id) )
	{
		sex = nst_zb_get_user_sex(id)
	}
	else
	{
		sex = nst_get_user_sex(id)
	}

	return sex;
}
// Plays a sound on clients
PlaySound(id, const sound[])
{
	if (equal(sound[strlen(sound)-4], ".mp3"))
		client_cmd(id, "mp3 play ^"sound/%s^"", sound)
	else
		client_cmd(id, "spk ^"%s^"", sound)
}
bool:can_see_fm(entindex1, entindex2)
{
	if ((!g_FM_Running) || !entindex1 || !entindex2)
		return false
//  new ent1, ent2

	if (pev_valid(entindex1) && pev_valid(entindex1))
	{
		new flags = pev(entindex1, pev_flags)
		if (flags & EF_NODRAW || flags & FL_NOTARGET)
		{
			return false
		}

		new Float:lookerOrig[3]
		new Float:targetBaseOrig[3]
		new Float:targetOrig[3]
		new Float:temp[3]

		pev(entindex1, pev_origin, lookerOrig)
		pev(entindex1, pev_view_ofs, temp)
		lookerOrig[0] += temp[0]
		lookerOrig[1] += temp[1]
		lookerOrig[2] += temp[2]

		pev(entindex2, pev_origin, targetBaseOrig)
		pev(entindex2, pev_view_ofs, temp)
		targetOrig[0] = targetBaseOrig [0] + temp[0]
		targetOrig[1] = targetBaseOrig [1] + temp[1]
		targetOrig[2] = targetBaseOrig [2] + temp[2]

		engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the had of seen player
		if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater))
		{
			return false
		} 
		else 
		{
			new Float:flFraction
			get_tr2(0, TraceResult:TR_flFraction, flFraction)
			if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
			{
				return true
			}
			else
			{
				targetOrig[0] = targetBaseOrig [0]
				targetOrig[1] = targetBaseOrig [1]
				targetOrig[2] = targetBaseOrig [2]
				engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the body of seen player
				get_tr2(0, TraceResult:TR_flFraction, flFraction)
				if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
				{
					return true
				}
				else
				{
					targetOrig[0] = targetBaseOrig [0]
					targetOrig[1] = targetBaseOrig [1]
					targetOrig[2] = targetBaseOrig [2] - 17.0
					engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the legs of seen player
					get_tr2(0, TraceResult:TR_flFraction, flFraction)
					if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
					{
						return true
					}
				}
			}
		}
	}
	return false
}

Anh giải thích dùm em luôn, từng dòng nha anh
+REP...:-*

---------- Post added at 20:08 ---------- Previous post was at 20:07 ----------

Cái chỗ clien_print đó, anh ạ, em thêm mỗi chỗ đó thôi, cái chỗ switch ấy
 
Ha ha, chết Dias rồi, ở đó mà ngồi giải thích từng dòng. Ha ha.... Tốn thời gian quá
 
Ha ha, chết Dias rồi, ở đó mà ngồi giải thích từng dòng. Ha ha.... Tốn thời gian quá

nGƯỜI ta làm new bie mà anh...đâu hiểu gì...
Em thích nhất là cách dạy của Ngoc Vinh....Cần hỏi gì ổng viết hẳn 1 chương trình test, ghi chú từng dòng 1....nhờ vậy mà em học autoit rất là nhanh ^^....
 
Giải thích từng dòng=> Tôi có thể đoán được rằng cậu là người có kiến thức về english không được tốt cho lăm, nếu ko nói quá thì là tệ hại, và toán học có lẽ cũng không giỏi >:). Có giải thích thì liệu cậu có thực sự hiểu được không khi mà nền móng căn bản mình chưa nắm vững hay nói trắng ra là chưa học. Nếu dias giải thích từng dòng thì cậu cũng chỉ thể bắt chước và hiểu theo cách của cậu thôi sai hoàn toàn vs lý thuyết. Cách này rất tai hại nếu sau này mình muốn làm plugins thực sự vì ko có nền móng mà chỉ toàn bắt chước vs nhảy cóc thì sẽ chả làm nổi 1 plugins đơn giản vs 30line [-x
 
+REP +REP, tuyệt quá ...:-*

À, anh xem dùm em cái em edit kill_efect.sma của nst sao ko complie được anh?
[spoil]
PHP:
diub#include <amxmodx>
#include <fakemeta>

#include <nst_player>
#include <nst_zombie>
#include <nst_wpn>


#define PLUGIN "Effects Killer"
#define VERSION "3.0"
#define AUTHOR "NST"

#define LEVELS 8
new kills[33], Float:timekill[33], revenge[33], oneshot[33]
new iconstatus, g_firstkill, g_lastkill
new g_FM_Running
new cvar_time_kill, cvar_type, cvar_time_show

new const sound_combo[][] =
{
	"vox/kill/%s/kill_1_%s.wav", 
	"vox/kill/%s/kill_2_%s.wav", 
	"vox/kill/%s/kill_3_%s.wav", 
	"vox/kill/%s/kill_4_%s.wav", 
	"vox/kill/%s/kill_5_%s.wav", 
	"vox/kill/%s/kill_6_%s.wav", 
	"vox/kill/%s/kill_7_%s.wav", 
	"vox/kill/%s/kill_8_%s.wav", 
	"vox/kill/%s/revenge_%s.wav", 
	"vox/kill/%s/headshot_%s.wav", 
	"vox/kill/%s/knife_%s.wav", 
	"vox/kill/%s/grenade_%s.wav"
}
enum(+= 100)
{
	TASK_HIDESPR = 2000
}
#define ID_HIDESPR (taskid - TASK_HIDESPR)
enum
{
	HUD_SOUND = 1,
	HUD_MSGTEXT,
	HUD_SPRNAME
}
enum
{
	KILL_1 = 1,
	KILL_2,
	KILL_3,
	KILL_4,
	KILL_5,
	KILL_6,
	KILL_7,
	KILL_8,
	KILL_FIRST,
	C4_DEFUSE,
	C4_SET
}
enum
{
	KILL_NONE = 51,
	KILL_HEGRENADE,
	KILL_HEADSHOT,
	KILL_KNIFE,
	KILL_LAST,
	KILL_REVENGE,
	WALLSHOT,
	WALLSHOT_HEADSHOT,
	ONESHOT_2KILL,
	ONESHOT_3KILL
}


public plugin_precache()
{
	for (new i = 1; i <= 2; i++)
	{
		new sex[32]
		if (i == 1) sex = "woman"
		else sex = "man"
		
		for (new e = 0; e <= 11; e++)
		{
			new sound_ct[100], sound_t[100], team_ct[32] = "ct", team_t[32] = "t"
			format(sound_ct, 99, sound_combo[e], sex, team_ct)
			format(sound_t, 99, sound_combo[e], sex, team_t)
			//precache_sound(sound_ct)
			//precache_sound(sound_t)
		}
		
	}
	//precache_sound("misc/MultiKill/C4_Defuse.wav")
	//precache_sound("misc/MultiKill/C4_Set.wav")
	
}
public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
	register_event("DeathMsg", "event_DeathMsg", "a")
	
	cvar_time_kill = register_cvar("nst_ek_time_kill","3")
	cvar_type = register_cvar("nst_ek_type","1")
	cvar_time_show = register_cvar("nst_ek_time_show","2.0")
	
	iconstatus = get_user_msgid("StatusIcon")
	g_FM_Running = is_module_loaded("FakeMeta")
}
public event_round_start()
{
	new reset_value[33]

	g_firstkill = 1
	kills = reset_value
	revenge = reset_value
	oneshot = reset_value
}
public event_DeathMsg()
{
	// get value data
	static killer, headshot, weapon[32], wpnindex, victim
	killer = read_data(1)
	victim = read_data(2)
	headshot = read_data(3)
	read_data(4, weapon, charsmax(weapon))
	if (equali(weapon, "grenade")) format(weapon, charsmax(weapon), "hegrenade")
	format(weapon, charsmax(weapon), "weapon_%s", weapon)
	wpnindex = get_weaponid(weapon)
	
	// none killer = victim
	if (!is_user_connected(killer) || !is_user_connected(victim) || killer==victim) return;
	if (get_user_team(killer)==get_user_team(victim) && !get_cvar_num("mp_friendlyfire")) return;
	
	// reset kills of victim
	kills[victim] = 0

	// set revenge of victim
	revenge[victim] = killer

	// get num kill & one shoot multikill
	new Float:timeleft = get_gametime()-timekill[killer]
	if (timeleft <= get_pcvar_float(cvar_time_kill)) kills[killer] += 1
	else kills[killer] = 1
	if (kills[killer]>LEVELS) kills[killer] = 1
	timekill[killer] = get_gametime()

	if (!oneshot[killer]) oneshot[killer] = 1
	if (!timeleft && wpnindex != CSW_HEGRENADE) oneshot[killer] += 1
	else oneshot[killer] = 1
	oneshot[killer] = min(3, oneshot[killer])
	//client_print(killer, print_chat, "%i", oneshot[killer])
	
	// get last kill
	new players_ct[32], players_t[32], ict, ite
	get_players(players_ct,ict,"ae","CT")   
	get_players(players_t,ite,"ae","TERRORIST")
	if (ict == 0 || ite == 0) g_lastkill = 1
	
	// check revenge
	new g_revenge
	if (victim == revenge[killer])
	{
		g_revenge = 1
		revenge[killer] = 0
	}

	// hud 1
	new check_sound
	if (oneshot[killer] > 1)
	{
		if (oneshot[killer] == 2) show_hud(killer, ONESHOT_2KILL)
		else if (oneshot[killer] == 3) show_hud(killer, ONESHOT_3KILL)
	}
	else if (g_lastkill)
	{
		g_lastkill = 0
		show_hud(killer, KILL_LAST)
	}	
	else if (g_revenge)
	{
		play_sound(killer, KILL_REVENGE)
		show_hud(killer, KILL_REVENGE)
	}
	else if ((wpnindex != CSW_KNIFE) && (wpnindex != CSW_HEGRENADE) && !can_see_fm(killer, victim)) 
	{
		if (headshot)
		{
			if (kills[killer] == 1)
			{
				play_sound(killer, KILL_HEADSHOT)
				check_sound = 1
			}
			show_hud(killer, WALLSHOT_HEADSHOT)
		}
		else show_hud(killer, WALLSHOT)
	}
	else if (headshot && wpnindex)
	{
		if (kills[killer] == 1)
		{
			play_sound(killer, KILL_HEADSHOT)
			check_sound = 1
		}
		show_hud(killer, KILL_HEADSHOT)
	}
	else if (wpnindex == CSW_KNIFE)
	{
		if (kills[killer] == 1)
		{
			play_sound(killer, KILL_KNIFE)
			check_sound = 1
		}
		show_hud(killer, KILL_KNIFE)
	}
	else if (wpnindex == CSW_HEGRENADE)
	{
		if (kills[killer] == 1)
		{
			play_sound(killer, KILL_HEGRENADE)
			check_sound = 1
		}
		show_hud(killer, KILL_HEGRENADE)
	}
	else
	{
		show_hud(killer, KILL_NONE)
	}
	
	
	// hud 2
	if (g_firstkill)
	{
		g_firstkill = 0
		show_hud(killer, KILL_FIRST)
		if (!check_sound) play_sound(killer, KILL_1)
	}
	else
	{
		show_hud(killer, kills[killer])
		if (!check_sound) play_sound(killer, kills[killer])
	}

}
public bomb_defused(id)
{
	show_hud(id, C4_DEFUSE)
	play_sound(id, C4_DEFUSE)
}
public bomb_planted(id)
{
	show_hud(id, C4_SET)
	play_sound(id, C4_SET)
}


// #################### SHOW HUD ####################
show_hud(id, idhud)
{
	if (!is_user_connected(id)) return;
	
	new type_cvar = get_pcvar_num(cvar_type)
	if (type_cvar == 1) show_spr(id, idhud)
	else if (type_cvar == 2) show_msg(id, idhud)
}
play_sound(id, idhud)
{
	if (!is_user_connected(id)) return;
	
	new sound[64], team[32], sex[32], cs_team
	if (nst_get_mod_runing()==NST_MOD_ZB3) cs_team = nst_get_user_team(id)
	else cs_team = get_user_team(id)
		
	if (cs_team==1) team = "T"
	else team = "CT"
	if (get_user_sex(id) == 2) sex = "woman"
	else sex = "man"
	format(sound, charsmax(sound), "%s", get_hud_data(idhud, HUD_SOUND))
	format(sound, charsmax(sound), sound, sex, team)
	
	PlaySound(id, sound)
}

show_msg(id, idhud)
{
	new msg[64]
	format(msg, charsmax(msg), "%s", get_hud_data(idhud, HUD_MSGTEXT))

	set_hudmessage(0, 204, 0, -1.0, 0.65, 1, 0.02, 3.0, 0.3, 0.3, 2)
	show_hudmessage(id, msg)
}
show_spr(id, idspr)
{
	if (idspr >= KILL_NONE) hide_spr(id, 2)
	else hide_spr(id, 1)

	spr_action(id, idspr, 1)
	
	if (idspr < KILL_NONE)
	{
		if (task_exists(id+TASK_HIDESPR)) remove_task(id+TASK_HIDESPR)
		set_task(get_pcvar_float(cvar_time_show), "task_hidehud", id+TASK_HIDESPR)
	}
} 
public task_hidehud(taskid)
{
	new id = ID_HIDESPR
	hide_spr(id, 2)
	hide_spr(id, 1)

}
hide_spr(id, idspr)
{
	if (idspr == 1)
	{
		for (new i = KILL_1; i <= C4_SET; i++)
		{
			spr_action(id, i, 0)
		}
	}
	else if (idspr == 2)
	{
		for (new i = KILL_NONE; i <= ONESHOT_3KILL; i++)
		{
			spr_action(id, i, 0)
		}
	}
}  
spr_action(id, spr, run)
{	
	new sprname[64]
	format(sprname, charsmax(sprname), "%s", get_hud_data(spr, HUD_SPRNAME))

	message_begin(MSG_ONE,iconstatus,{0,0,0},id)
	write_byte(run) // status (0=hide, 1=show, 2=flash)
	write_string(sprname) // sprite name
	message_end()
}
get_hud_data(idhud, type)
{
	new value[64], sprname[33], sound[64], msgtext[32]
	
	switch (idhud)
	{
		case KILL_1:
		{
			sprname = "kill_1"
			sound = "vox/kill/%s/kill_1_%s"
			msgtext = "1 KILL"
		}
		case KILL_2:
		{
			sprname = "kill_2"
			sound = "vox/kill/%s/kill_2_%s"
			msgtext = "2 KILL"
		}
		case KILL_3:
		{
			sprname = "kill_3"
			sound = "vox/kill/%s/kill_3_%s"
			msgtext = "3 KILL"
		}
		case KILL_4:
		{
			sprname = "kill_4"
			sound = "vox/kill/%s/kill_4_%s"
			msgtext = "4 KILL"
		}
		case KILL_5:
		{
			sprname = "kill_5"
			sound = "vox/kill/%s/kill_5_%s"
			msgtext = "5 KILL"
		}
		case KILL_6:
		{
			sprname = "kill_6"
			sound = "vox/kill/%s/kill_6_%s"
			msgtext = "6 KILL"
		}
		case KILL_7:
		{
			sprname = "kill_7"
			sound = "vox/kill/%s/kill_7_%s"
			msgtext = "7 KILL"
		}
		case KILL_8:
		{
			sprname = "kill_8"
			sound = "vox/kill/%s/kill_8_%s"
			msgtext = "8 KILL"
		}
		case KILL_FIRST:
		{
			sprname = "kill_first"
			msgtext = "FIRST KILL"
			client_print(id, print_chat, "Ban duoc cong %d EXP khi danh duoc %s", 50, FIRST_KILL)
		}
		case C4_DEFUSE:
		{
			sprname = "c4_defuse"
			sound = "vox/kill/c4_defuse"
			client_print(id, print_chat, "Ban duoc cong %d EXP khi go %s thanh cong", 50, C4)
		}
		case C4_SET:
		{
			sprname = "c4_set"
			sound = "vox/kill/c4_set"
			client_print(id, print_chat, "Ban duoc cong %d EXP khi dat %s thanh cong", 50, C4)
		}
	
	
		case KILL_NONE:
		{
			sprname = "kill_none"
		}
		case KILL_HEGRENADE:
		{
			sprname = "kill_he"
			sound = "vox/kill/%s/grenade_%s"
			msgtext = "GRENADE KILL"
		}
		case KILL_HEADSHOT:
		{
			sprname = "kill_headshot"
			sound = "vox/kill/%s/headshot_%s"
			msgtext = "HEADSHOT"
		}
		case KILL_KNIFE:
		{
			sprname = "kill_knife"
			sound = "vox/kill/%s/knife_%s"
			msgtext = "KNIFE KILL"
		}
		case KILL_LAST:
		{
			sprname = "kill_last"
			client_print(id, print_chat, "Ban duoc cong %d EXP khi danh duoc %s", 50, LAST_KILL)
		}
		case KILL_REVENGE:
		{
			sprname = "kill_revenge"
			sound = "vox/kill/%s/revenge_%s"
			msgtext = "REVENGE"
		}
		case WALLSHOT:
		{
			sprname = "wall_shot"
			msgtext = "WALLSHOOT"
		}
		case WALLSHOT_HEADSHOT:
		{
			sprname = "wall_shot_hs"
			msgtext = "WALLSHOOT HEADSHOT"
		}
		case ONESHOT_2KILL:
		{
			sprname = "1shot_2kill"
			msgtext = "ONE SHOT 2 KILL"
		}
		case ONESHOT_3KILL:
		{
			sprname = "1shot_3kill"
			msgtext = "ONE SHOT MULTIKILL"
		}
	}

	if (type==HUD_SOUND) format(value, charsmax(value), "%s", sound)
	else if (type==HUD_MSGTEXT) format(value, charsmax(value), "%s", msgtext)
	else if (type==HUD_SPRNAME) format(value, charsmax(value), "%s", sprname)
	
	return value;
}
get_user_sex(id)
{
	new mod_runing, sex
	mod_runing = nst_get_mod_runing()
	if ( (mod_runing == NST_MOD_ZB3 || mod_runing == NST_MOD_ZBU || mod_runing == NST_MOD_ZBS) && nst_zb_get_user_zombie(id) )
	{
		sex = nst_zb_get_user_sex(id)
	}
	else
	{
		sex = nst_get_user_sex(id)
	}

	return sex;
}
// Plays a sound on clients
PlaySound(id, const sound[])
{
	if (equal(sound[strlen(sound)-4], ".mp3"))
		client_cmd(id, "mp3 play ^"sound/%s^"", sound)
	else
		client_cmd(id, "spk ^"%s^"", sound)
}
bool:can_see_fm(entindex1, entindex2)
{
	if ((!g_FM_Running) || !entindex1 || !entindex2)
		return false
//  new ent1, ent2

	if (pev_valid(entindex1) && pev_valid(entindex1))
	{
		new flags = pev(entindex1, pev_flags)
		if (flags & EF_NODRAW || flags & FL_NOTARGET)
		{
			return false
		}

		new Float:lookerOrig[3]
		new Float:targetBaseOrig[3]
		new Float:targetOrig[3]
		new Float:temp[3]

		pev(entindex1, pev_origin, lookerOrig)
		pev(entindex1, pev_view_ofs, temp)
		lookerOrig[0] += temp[0]
		lookerOrig[1] += temp[1]
		lookerOrig[2] += temp[2]

		pev(entindex2, pev_origin, targetBaseOrig)
		pev(entindex2, pev_view_ofs, temp)
		targetOrig[0] = targetBaseOrig [0] + temp[0]
		targetOrig[1] = targetBaseOrig [1] + temp[1]
		targetOrig[2] = targetBaseOrig [2] + temp[2]

		engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the had of seen player
		if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater))
		{
			return false
		} 
		else 
		{
			new Float:flFraction
			get_tr2(0, TraceResult:TR_flFraction, flFraction)
			if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
			{
				return true
			}
			else
			{
				targetOrig[0] = targetBaseOrig [0]
				targetOrig[1] = targetBaseOrig [1]
				targetOrig[2] = targetBaseOrig [2]
				engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the body of seen player
				get_tr2(0, TraceResult:TR_flFraction, flFraction)
				if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
				{
					return true
				}
				else
				{
					targetOrig[0] = targetBaseOrig [0]
					targetOrig[1] = targetBaseOrig [1]
					targetOrig[2] = targetBaseOrig [2] - 17.0
					engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the legs of seen player
					get_tr2(0, TraceResult:TR_flFraction, flFraction)
					if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
					{
						return true
					}
				}
			}
		}
	}
	return false
}
[/spoil]
Anh giải thích dùm em luôn, từng dòng nha anh
+REP...:-*
Cái chỗ clien_print đó, anh ạ, em thêm mỗi chỗ đó thôi, cái chỗ switch ấy

568 line :))....................... diub trước #include là j thế ?.. # là khai báo mà có cái j đằng trc sao mà nhận nhỉ :-?
 

nGƯỜI ta làm new bie mà anh...đâu hiểu gì...
Em thích nhất là cách dạy của Ngoc Vinh....Cần hỏi gì ổng viết hẳn 1 chương trình test, ghi chú từng dòng 1....nhờ vậy mà em học autoit rất là nhanh ^^....

Newbie thì newbie chứ, bắt đầu từ thứ đơn giản nhất, bây giờ lôi 1 plugin dài ngoằng ra, mà chưa kể plugin đó lại sử dụng 1 số native không phải của AMX nguyên bản mà là native từ plugin khác, học nhảy cóc thế này thì đúng là tôi cũng thua
 
Newbie thì newbie chứ, bắt đầu từ thứ đơn giản nhất, bây giờ lôi 1 plugin dài ngoằng ra, mà chưa kể plugin đó lại sử dụng 1 số native không phải của AMX nguyên bản mà là native từ plugin khác, học nhảy cóc thế này thì đúng là tôi cũng thua
Nói chuẩn đấy:>
Mà cái plugin kia thì sao mà lại ko compile đc=))chắc lại nghịch rồi=))
 
Cái này có thể nói nôm na nó y sì C. Muốn học cũng phải hiểu biết về khái niệm biến, hằng, kiểu dl, mảng, vòng lặp, đệ quy, etc... Nói thực thì tiếng anh ko tốt thì ko nên học lập trình nếu mình ko có tính kiên nhẫn #-o
 
1.
PHP:
diub#include <amxmodx>
-> diub là cái gì ?
Fix: ->
PHP:
#include <amxmodx>

2.
- Ở chỗ đoạn "get_hud_data(idhud, type)", dòng 339. id ở đâu ra ?.
-> Fix:
Mã:
- Dòng 278: get_hud_data(idhud, HUD_SOUND) -> get_hud_data(id, idhud, HUD_SOUND)
- Dòng 287: get_hud_data(idhud, HUD_MSGTEXT) -> get_hud_data(id, idhud, HUD_MSGTEXT)
- Dòng 332: get_hud_data(spr, HUD_SPRNAME) -> get_hud_data(id, spr, HUD_SPRNAME)

3.
- cũng cái đoạn "get_hud_data(idhud, type)", dòng 339. Mấy cái FIRST_KILL, C4, LAST_KILL ở đâu ra ?. Phải xác định nó trước, dùng #define như là #define FIRST_KILL "First Kill"... Thôi thì viết vào luôn cho lẹ ha...
-> Fix:
a.
PHP:
client_print(id, print_chat, "Ban duoc cong %d EXP khi danh duoc %s", 50, FIRST_KILL) 
// Sửa thành
client_print(id, print_chat, "Ban duoc cong %d EXP khi danh duoc %s", 50, "First Kill") // Vì khi print ra là nó sẽ hiện "Ban duoc cong 50 EXP khi danh duoc First Kill phải chứ ?. Muốn nó hiện text thì phải để dạng String chứ, bác để dạng biến thế kai sao nó hiện dc :)).

b.
PHP:
client_print(id, print_chat, "Ban duoc cong %d EXP khi go %s thanh cong", 50, C4) 
// ->
 client_print(id, print_chat, "Ban duoc cong %d EXP khi go %s thanh cong", 50, "C4") // Tương tự cái a

c. Như cái b (2 cái đều là C4 mà :)))
d.
PHP:
client_print(id, print_chat, "Ban duoc cong %d EXP khi danh duoc %s", 50, LAST_KILL) 
// -> 
client_print(id, print_chat, "Ban duoc cong %d EXP khi danh duoc %s", 50, "Last Kill")

-------------------
Đây là code đã fix...
PHP:
#include <amxmodx> 
#include <fakemeta> 

#include <nst_player> 
#include <nst_zombie> 
#include <nst_wpn> 


#define PLUGIN "Effects Killer" 
#define VERSION "3.0" 
#define AUTHOR "NST" 

#define LEVELS 8 
new kills[33], Float:timekill[33], revenge[33], oneshot[33] 
new iconstatus, g_firstkill, g_lastkill 
new g_FM_Running 
new cvar_time_kill, cvar_type, cvar_time_show 

new const sound_combo[][] = 
{ 
    "vox/kill/%s/kill_1_%s.wav",  
    "vox/kill/%s/kill_2_%s.wav",  
    "vox/kill/%s/kill_3_%s.wav",  
    "vox/kill/%s/kill_4_%s.wav",  
    "vox/kill/%s/kill_5_%s.wav",  
    "vox/kill/%s/kill_6_%s.wav",  
    "vox/kill/%s/kill_7_%s.wav",  
    "vox/kill/%s/kill_8_%s.wav",  
    "vox/kill/%s/revenge_%s.wav",  
    "vox/kill/%s/headshot_%s.wav",  
    "vox/kill/%s/knife_%s.wav",  
    "vox/kill/%s/grenade_%s.wav" 
} 
enum(+= 100) 
{ 
    TASK_HIDESPR = 2000 
} 
#define ID_HIDESPR (taskid - TASK_HIDESPR) 
enum 
{ 
    HUD_SOUND = 1, 
    HUD_MSGTEXT, 
    HUD_SPRNAME 
} 
enum 
{ 
    KILL_1 = 1, 
    KILL_2, 
    KILL_3, 
    KILL_4, 
    KILL_5, 
    KILL_6, 
    KILL_7, 
    KILL_8, 
    KILL_FIRST, 
    C4_DEFUSE, 
    C4_SET 
} 
enum 
{ 
    KILL_NONE = 51, 
    KILL_HEGRENADE, 
    KILL_HEADSHOT, 
    KILL_KNIFE, 
    KILL_LAST, 
    KILL_REVENGE, 
    WALLSHOT, 
    WALLSHOT_HEADSHOT, 
    ONESHOT_2KILL, 
    ONESHOT_3KILL 
} 


public plugin_precache() 
{ 
    for (new i = 1; i <= 2; i++) 
    { 
        new sex[32] 
        if (i == 1) sex = "woman" 
        else sex = "man" 
         
        for (new e = 0; e <= 11; e++) 
        { 
            new sound_ct[100], sound_t[100], team_ct[32] = "ct", team_t[32] = "t" 
            format(sound_ct, 99, sound_combo[e], sex, team_ct) 
            format(sound_t, 99, sound_combo[e], sex, team_t) 
            //precache_sound(sound_ct) 
            //precache_sound(sound_t) 
        } 
         
    } 
    //precache_sound("misc/MultiKill/C4_Defuse.wav") 
    //precache_sound("misc/MultiKill/C4_Set.wav") 
     
} 
public plugin_init() 
{ 
    register_plugin(PLUGIN, VERSION, AUTHOR) 
     
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0") 
    register_event("DeathMsg", "event_DeathMsg", "a") 
     
    cvar_time_kill = register_cvar("nst_ek_time_kill","3") 
    cvar_type = register_cvar("nst_ek_type","1") 
    cvar_time_show = register_cvar("nst_ek_time_show","2.0") 
     
    iconstatus = get_user_msgid("StatusIcon") 
    g_FM_Running = is_module_loaded("FakeMeta") 
} 
public event_round_start() 
{ 
    new reset_value[33] 

    g_firstkill = 1 
    kills = reset_value 
    revenge = reset_value 
    oneshot = reset_value 
} 
public event_DeathMsg() 
{ 
    // get value data 
    static killer, headshot, weapon[32], wpnindex, victim 
    killer = read_data(1) 
    victim = read_data(2) 
    headshot = read_data(3) 
    read_data(4, weapon, charsmax(weapon)) 
    if (equali(weapon, "grenade")) format(weapon, charsmax(weapon), "hegrenade") 
    format(weapon, charsmax(weapon), "weapon_%s", weapon) 
    wpnindex = get_weaponid(weapon) 
     
    // none killer = victim 
    if (!is_user_connected(killer) || !is_user_connected(victim) || killer==victim) return; 
    if (get_user_team(killer)==get_user_team(victim) && !get_cvar_num("mp_friendlyfire")) return; 
     
    // reset kills of victim 
    kills[victim] = 0 

    // set revenge of victim 
    revenge[victim] = killer 

    // get num kill & one shoot multikill 
    new Float:timeleft = get_gametime()-timekill[killer] 
    if (timeleft <= get_pcvar_float(cvar_time_kill)) kills[killer] += 1 
    else kills[killer] = 1 
    if (kills[killer]>LEVELS) kills[killer] = 1 
    timekill[killer] = get_gametime() 

    if (!oneshot[killer]) oneshot[killer] = 1 
    if (!timeleft && wpnindex != CSW_HEGRENADE) oneshot[killer] += 1 
    else oneshot[killer] = 1 
    oneshot[killer] = min(3, oneshot[killer]) 
    //client_print(killer, print_chat, "%i", oneshot[killer]) 
     
    // get last kill 
    new players_ct[32], players_t[32], ict, ite 
    get_players(players_ct,ict,"ae","CT")    
    get_players(players_t,ite,"ae","TERRORIST") 
    if (ict == 0 || ite == 0) g_lastkill = 1 
     
    // check revenge 
    new g_revenge 
    if (victim == revenge[killer]) 
    { 
        g_revenge = 1 
        revenge[killer] = 0 
    } 

    // hud 1 
    new check_sound 
    if (oneshot[killer] > 1) 
    { 
        if (oneshot[killer] == 2) show_hud(killer, ONESHOT_2KILL) 
        else if (oneshot[killer] == 3) show_hud(killer, ONESHOT_3KILL) 
    } 
    else if (g_lastkill) 
    { 
        g_lastkill = 0 
        show_hud(killer, KILL_LAST) 
    }     
    else if (g_revenge) 
    { 
        play_sound(killer, KILL_REVENGE) 
        show_hud(killer, KILL_REVENGE) 
    } 
    else if ((wpnindex != CSW_KNIFE) && (wpnindex != CSW_HEGRENADE) && !can_see_fm(killer, victim))  
    { 
        if (headshot) 
        { 
            if (kills[killer] == 1) 
            { 
                play_sound(killer, KILL_HEADSHOT) 
                check_sound = 1 
            } 
            show_hud(killer, WALLSHOT_HEADSHOT) 
        } 
        else show_hud(killer, WALLSHOT) 
    } 
    else if (headshot && wpnindex) 
    { 
        if (kills[killer] == 1) 
        { 
            play_sound(killer, KILL_HEADSHOT) 
            check_sound = 1 
        } 
        show_hud(killer, KILL_HEADSHOT) 
    } 
    else if (wpnindex == CSW_KNIFE) 
    { 
        if (kills[killer] == 1) 
        { 
            play_sound(killer, KILL_KNIFE) 
            check_sound = 1 
        } 
        show_hud(killer, KILL_KNIFE) 
    } 
    else if (wpnindex == CSW_HEGRENADE) 
    { 
        if (kills[killer] == 1) 
        { 
            play_sound(killer, KILL_HEGRENADE) 
            check_sound = 1 
        } 
        show_hud(killer, KILL_HEGRENADE) 
    } 
    else 
    { 
        show_hud(killer, KILL_NONE) 
    } 
     
     
    // hud 2 
    if (g_firstkill) 
    { 
        g_firstkill = 0 
        show_hud(killer, KILL_FIRST) 
        if (!check_sound) play_sound(killer, KILL_1) 
    } 
    else 
    { 
        show_hud(killer, kills[killer]) 
        if (!check_sound) play_sound(killer, kills[killer]) 
    } 

} 
public bomb_defused(id) 
{ 
    show_hud(id, C4_DEFUSE) 
    play_sound(id, C4_DEFUSE) 
} 
public bomb_planted(id) 
{ 
    show_hud(id, C4_SET) 
    play_sound(id, C4_SET) 
} 


// #################### SHOW HUD #################### 
show_hud(id, idhud) 
{ 
    if (!is_user_connected(id)) return; 
     
    new type_cvar = get_pcvar_num(cvar_type) 
    if (type_cvar == 1) show_spr(id, idhud) 
    else if (type_cvar == 2) show_msg(id, idhud) 
} 
play_sound(id, idhud) 
{ 
    if (!is_user_connected(id)) return; 
     
    new sound[64], team[32], sex[32], cs_team 
    if (nst_get_mod_runing()==NST_MOD_ZB3) cs_team = nst_get_user_team(id) 
    else cs_team = get_user_team(id) 
         
    if (cs_team==1) team = "T" 
    else team = "CT" 
    if (get_user_sex(id) == 2) sex = "woman" 
    else sex = "man" 
    format(sound, charsmax(sound), "%s", get_hud_data(id, idhud, HUD_SOUND)) 
    format(sound, charsmax(sound), sound, sex, team) 
     
    PlaySound(id, sound) 
} 

show_msg(id, idhud) 
{ 
    new msg[64] 
    format(msg, charsmax(msg), "%s", get_hud_data(id, idhud, HUD_MSGTEXT)) 

    set_hudmessage(0, 204, 0, -1.0, 0.65, 1, 0.02, 3.0, 0.3, 0.3, 2) 
    show_hudmessage(id, msg) 
} 
show_spr(id, idspr) 
{ 
    if (idspr >= KILL_NONE) hide_spr(id, 2) 
    else hide_spr(id, 1) 

    spr_action(id, idspr, 1) 
     
    if (idspr < KILL_NONE) 
    { 
        if (task_exists(id+TASK_HIDESPR)) remove_task(id+TASK_HIDESPR) 
        set_task(get_pcvar_float(cvar_time_show), "task_hidehud", id+TASK_HIDESPR) 
    } 
}  
public task_hidehud(taskid) 
{ 
    new id = ID_HIDESPR 
    hide_spr(id, 2) 
    hide_spr(id, 1) 

} 
hide_spr(id, idspr) 
{ 
    if (idspr == 1) 
    { 
        for (new i = KILL_1; i <= C4_SET; i++) 
        { 
            spr_action(id, i, 0) 
        } 
    } 
    else if (idspr == 2) 
    { 
        for (new i = KILL_NONE; i <= ONESHOT_3KILL; i++) 
        { 
            spr_action(id, i, 0) 
        } 
    } 
}   
spr_action(id, spr, run) 
{     
    new sprname[64] 
    format(sprname, charsmax(sprname), "%s", get_hud_data(id, spr, HUD_SPRNAME)) 

    message_begin(MSG_ONE,iconstatus,{0,0,0},id) 
    write_byte(run) // status (0=hide, 1=show, 2=flash) 
    write_string(sprname) // sprite name 
    message_end() 
} 
get_hud_data(id, idhud, type) 
{ 
    new value[64], sprname[33], sound[64], msgtext[32] 
     
    switch (idhud) 
    { 
        case KILL_1: 
        { 
            sprname = "kill_1" 
            sound = "vox/kill/%s/kill_1_%s" 
            msgtext = "1 KILL" 
        } 
        case KILL_2: 
        { 
            sprname = "kill_2" 
            sound = "vox/kill/%s/kill_2_%s" 
            msgtext = "2 KILL" 
        } 
        case KILL_3: 
        { 
            sprname = "kill_3" 
            sound = "vox/kill/%s/kill_3_%s" 
            msgtext = "3 KILL" 
        } 
        case KILL_4: 
        { 
            sprname = "kill_4" 
            sound = "vox/kill/%s/kill_4_%s" 
            msgtext = "4 KILL" 
        } 
        case KILL_5: 
        { 
            sprname = "kill_5" 
            sound = "vox/kill/%s/kill_5_%s" 
            msgtext = "5 KILL" 
        } 
        case KILL_6: 
        { 
            sprname = "kill_6" 
            sound = "vox/kill/%s/kill_6_%s" 
            msgtext = "6 KILL" 
        } 
        case KILL_7: 
        { 
            sprname = "kill_7" 
            sound = "vox/kill/%s/kill_7_%s" 
            msgtext = "7 KILL" 
        } 
        case KILL_8: 
        { 
            sprname = "kill_8" 
            sound = "vox/kill/%s/kill_8_%s" 
            msgtext = "8 KILL" 
        } 
        case KILL_FIRST: 
        { 
            sprname = "kill_first" 
            msgtext = "FIRST KILL" 
            client_print(id, print_chat, "Ban duoc cong %d EXP khi danh duoc %s", 50, "First Kill") 
        } 
        case C4_DEFUSE: 
        { 
            sprname = "c4_defuse" 
            sound = "vox/kill/c4_defuse" 
            client_print(id, print_chat, "Ban duoc cong %d EXP khi go %s thanh cong", 50, "C4") 
        } 
        case C4_SET: 
        { 
            sprname = "c4_set" 
            sound = "vox/kill/c4_set" 
            client_print(id, print_chat, "Ban duoc cong %d EXP khi dat %s thanh cong", 50, "C4") 
        } 
     
     
        case KILL_NONE: 
        { 
            sprname = "kill_none" 
        } 
        case KILL_HEGRENADE: 
        { 
            sprname = "kill_he" 
            sound = "vox/kill/%s/grenade_%s" 
            msgtext = "GRENADE KILL" 
        } 
        case KILL_HEADSHOT: 
        { 
            sprname = "kill_headshot" 
            sound = "vox/kill/%s/headshot_%s" 
            msgtext = "HEADSHOT" 
        } 
        case KILL_KNIFE: 
        { 
            sprname = "kill_knife" 
            sound = "vox/kill/%s/knife_%s" 
            msgtext = "KNIFE KILL" 
        } 
        case KILL_LAST: 
        { 
            sprname = "kill_last" 
            client_print(id, print_chat, "Ban duoc cong %d EXP khi danh duoc %s", 50, "Last Kill") 
        } 
        case KILL_REVENGE: 
        { 
            sprname = "kill_revenge" 
            sound = "vox/kill/%s/revenge_%s" 
            msgtext = "REVENGE" 
        } 
        case WALLSHOT: 
        { 
            sprname = "wall_shot" 
            msgtext = "WALLSHOOT" 
        } 
        case WALLSHOT_HEADSHOT: 
        { 
            sprname = "wall_shot_hs" 
            msgtext = "WALLSHOOT HEADSHOT" 
        } 
        case ONESHOT_2KILL: 
        { 
            sprname = "1shot_2kill" 
            msgtext = "ONE SHOT 2 KILL" 
        } 
        case ONESHOT_3KILL: 
        { 
            sprname = "1shot_3kill" 
            msgtext = "ONE SHOT MULTIKILL" 
        } 
    } 

    if (type==HUD_SOUND) format(value, charsmax(value), "%s", sound) 
    else if (type==HUD_MSGTEXT) format(value, charsmax(value), "%s", msgtext) 
    else if (type==HUD_SPRNAME) format(value, charsmax(value), "%s", sprname) 
     
    return value; 
} 
get_user_sex(id) 
{ 
    new mod_runing, sex 
    mod_runing = nst_get_mod_runing() 
    if ( (mod_runing == NST_MOD_ZB3 || mod_runing == NST_MOD_ZBU || mod_runing == NST_MOD_ZBS) && nst_zb_get_user_zombie(id) ) 
    { 
        sex = nst_zb_get_user_sex(id) 
    } 
    else 
    { 
        sex = nst_get_user_sex(id) 
    } 

    return sex; 
} 
// Plays a sound on clients 
PlaySound(id, const sound[]) 
{ 
    if (equal(sound[strlen(sound)-4], ".mp3")) 
        client_cmd(id, "mp3 play ^"sound/%s^"", sound) 
    else 
        client_cmd(id, "spk ^"%s^"", sound) 
} 
bool:can_see_fm(entindex1, entindex2) 
{ 
    if ((!g_FM_Running) || !entindex1 || !entindex2) 
        return false 
//  new ent1, ent2 

    if (pev_valid(entindex1) && pev_valid(entindex1)) 
    { 
        new flags = pev(entindex1, pev_flags) 
        if (flags & EF_NODRAW || flags & FL_NOTARGET) 
        { 
            return false 
        } 

        new Float:lookerOrig[3] 
        new Float:targetBaseOrig[3] 
        new Float:targetOrig[3] 
        new Float:temp[3] 

        pev(entindex1, pev_origin, lookerOrig) 
        pev(entindex1, pev_view_ofs, temp) 
        lookerOrig[0] += temp[0] 
        lookerOrig[1] += temp[1] 
        lookerOrig[2] += temp[2] 

        pev(entindex2, pev_origin, targetBaseOrig) 
        pev(entindex2, pev_view_ofs, temp) 
        targetOrig[0] = targetBaseOrig [0] + temp[0] 
        targetOrig[1] = targetBaseOrig [1] + temp[1] 
        targetOrig[2] = targetBaseOrig [2] + temp[2] 

        engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the had of seen player 
        if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater)) 
        { 
            return false 
        }  
        else  
        { 
            new Float:flFraction 
            get_tr2(0, TraceResult:TR_flFraction, flFraction) 
            if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2)) 
            { 
                return true 
            } 
            else 
            { 
                targetOrig[0] = targetBaseOrig [0] 
                targetOrig[1] = targetBaseOrig [1] 
                targetOrig[2] = targetBaseOrig [2] 
                engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the body of seen player 
                get_tr2(0, TraceResult:TR_flFraction, flFraction) 
                if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2)) 
                { 
                    return true 
                } 
                else 
                { 
                    targetOrig[0] = targetBaseOrig [0] 
                    targetOrig[1] = targetBaseOrig [1] 
                    targetOrig[2] = targetBaseOrig [2] - 17.0 
                    engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the legs of seen player 
                    get_tr2(0, TraceResult:TR_flFraction, flFraction) 
                    if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2)) 
                    { 
                        return true 
                    } 
                } 
            } 
        } 
    } 
    return false 
}

4. Code nào 150 dòng chở xuống tôi mới viết chi tiết :)). 568 thôi khỏi viết đi :))
 
Chỉnh sửa cuối:
ÔNg dias có chỉ chi tiết thì người ta cũng ko thể nào hiểu nổi. Lý do thì tôi đã nói ở trên và cũng đã có nhiều người nói
=> Tóm lại cho những người muốn giỏi amx code như sontung0 vs redplane, hữu cường, etc... :Đừng Nhảy Cóc
 
Back
Top