[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
Ai giúp em với, cái này complie bình thường nhưng vào game thì không có hiện tượng gì xảy ra cả

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

#include <amxmodx>

#define PLUGIN "change health"
#define VERSION "1.0"
#define AUTHOR "Bui duc duy"

new mau

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_event("Mau", "change", "ab") 

}

public change(id) 
{
	show_hudmessage(id,"So mau cua ban la &d", get_user_health(id))
	mau = get_user_health(id)
	
	
	while (mau)
	{
		if (mau <= 1 )
		{
			client_print(id,print_center,"Ban dang rat yeu")
		}
		if (mau = 100)
		{
			client_print(id,print_center,"Ban dang sung suc. tien len nao")
		}
		if (mau < 100 )
		{
			client_print(id,print_center,"Ban da bi ton thuong")
		}
	}
	
	return PLUGIN_CONTINUE
	
}
 
PHP:
register_event("Health", "change", "be")

bỏ "while", "return"

@atick hem event health có sẵn param của player rồi
 
Chỉnh sửa cuối:
- Event mau chắc là mới chế :)).
- bỏ cái while vào thế kia cho nó lặp tới tết àh =='
PHP:
    while (mau)
    {
        if (mau <= 1 )
        {
            client_print(id,print_center,"Ban dang rat yeu")
        }
        if (mau = 100)
        {
            client_print(id,print_center,"Ban dang sung suc. tien len nao")
        }
        if (mau < 100 )
        {
            client_print(id,print_center,"Ban da bi ton thuong")
        }
    }
->
PHP:
        if (mau <= 1 )
        {
            client_print(id,print_center,"Ban dang rat yeu")
        } else if(mau = 100) {
            client_print(id,print_center,"Ban dang sung suc. tien len nao")
        } else if(mau < 100 ) {
            client_print(id,print_center,"Ban da bi ton thuong")
        }
- get_user_health(id) trả về integer nên sài %i dc rồi. ko cần %d
PHP:
show_hudmessage(id,"So mau cua ban la &d", get_user_health(id))
->
PHP:
show_hudmessage(id,"So mau cua ban la &i", get_user_health(id))
 
@Coders : Muốn tạo 1 cvar tắt mở thì làm nt này đúng k
PHP:
new cvar_onoff
public plugin_int()
{
cvar_onoff = register_cvar("LD_onoff", "1")
}

public ....()
if (get_pcvar_num(cvar_onoff))
// Xoắn
Vào game thì gõ LD_onoff 0 để tắt đúng k
 
Đúng rồi.............................................
 
@Dias : Thế sao làm thế này vào game chả đc cái j`
PHP:
#include <amxmodx>
#include <engine>

#define PLUGIN    "Tu Sat"
#define AUTHOR    "LegionDark"
#define VERSION    "1.0"

new cvar_onoff

public plugin_init()
	{
		register_plugin(PLUGIN,AUTHOR,VERSION)
		register_clcmd("LD_ts", "t_s")
		cvar_onoff = register_cvar("LD_onoff","1")
	}
public t_s(id)
{
	if(get_pcvar_num(cvar_onoff))
	{
	if(is_user_alive(id))
		user_kill(id)
	}else {
	client_print(id,print_center,"Plugin nay chua duoc bat")
	}
}
 
Còn cái này cũng chẳng thèm hoạt động, các anh xem dùm đi
PHP:
#define PLUGIN "change health"
#define VERSION "1.0"
#define AUTHOR "Bui duc duy"

new health

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_event ("my_heath", "change", "be") 

}

public change(id) 
{
	show_hudmessage(id,"So mau cua ban la &i", get_user_health(id))
	health = get_user_health(id)
	
	if (health = 100){
		client_print(id,print_center,"Ban dang sung suc")
	} else if (health = 1){
		client_print(id,print_center,"Ban dang rat yeu")
	} else if (health < 100){
		client_print(id,print_center,"Ban da bi ton thuong")
	}
	return PLUGIN_CONTINUE
}
 
làm j có event gì tên my_health bạn?, với lại hud msg bạn còn chưa set tọa độ nữa...
@Dias : Thế sao làm thế này vào game chả đc cái j`
PHP:
#include <amxmodx>
#include <engine>

#define PLUGIN    "Tu Sat"
#define AUTHOR    "LegionDark"
#define VERSION    "1.0"

new cvar_onoff

public plugin_init()
	{
		register_plugin(PLUGIN,AUTHOR,VERSION)
		register_clcmd("LD_ts", "t_s")
		cvar_onoff = register_cvar("LD_onoff","1")
	}
public t_s(id)
{
	if(get_pcvar_num(cvar_onoff))
	{
	if(is_user_alive(id))
		user_kill(id)
	}else {
	client_print(id,print_center,"Plugin nay chua duoc bat")
	}
}

cái này vô game, mở console gõ lệnh kill là dc rồi :s, dâu cần lan xan như thế này đâu...
 
@redplane:
- Ông viết plugin example luôn đi. Ông nói tui làm, ông nói dc 1 tý là ông lại bận... Làm thế có phải mất thời gian ko (:|. Hoặc ko mún viết plugin thì nói hết lun đi==". Cái sáng nay ông đưa tui=> ko work.

@Legion:
- Fixed. Thử lại đi
PHP:
#include <amxmodx> 
#include <engine> 

#define PLUGIN    "Tu Sat" 
#define AUTHOR    "LegionDark" 
#define VERSION    "1.0" 

new cvar_onoff 

public plugin_init() 
{ 
	register_plugin(PLUGIN,AUTHOR,VERSION) 
	register_clcmd("LD_ts", "t_s") 
	cvar_onoff = register_cvar("LD_onoff","1") 
} 
public t_s(id) 
{ 
	if(get_pcvar_num(cvar_onoff)) 
	{ 
		if(is_user_alive(id)) 
			user_kill(id) 
		else
			client_print(id,print_center,"Plugin nay chua duoc bat") 
	} 
}
 
Chỉnh sửa cuối:
@Dias: Chuẩn rồi, chạy ngon ơ, nhưng tại sao sửa thế lại đc nhỉ ??
Àh quên, làm thế nào để nó in ra màn hình giống mấy plug của anh Tùng nhỉ, dùng print_console à, với lại print_center nó in ra đâu, sao k thấy ???
 
Chỉnh sửa cuối:
@legiondark: Thế này có được ko???Chạy ngon?
PHP:
#include <amxmodx> 
#include <engine> 

#define PLUGIN    "Tu Sat" 
#define AUTHOR    "LegionDark" 
#define VERSION    "1.0" 

new cvar_onoff 

public plugin_init() 
{ 
    register_plugin(PLUGIN,AUTHOR,VERSION) 
    register_event("LD_ts", "t_s","ab") 
    cvar_onoff = register_cvar("LD_onoff","1") 
} 
public t_s(id) 
{ 
   new logiondark=get_cvar_num("LD_onoff")
     if (logiondark!1) {
              client_print(id,print_center,"Plugin nay chua duoc bat") 
     } else if(is_user_alive(id)) {
            user_kill(id) 
      }
}

Hì, viết chay có khi sai chính tả đây ^^

---------- Post added at 21:06 ---------- Previous post was at 21:02 ----------

@Dias: Chuẩn rồi, chạy ngon ơ, nhưng tại sao sửa thế lại đc nhỉ ??
Àh quên, làm thế nào để nó in ra màn hình giống mấy plug của anh Tùng nhỉ, dùng print_console à, với lại print_center nó in ra đâu, sao k thấy ???

Hình như là show_hudmessage() đấy, (in mãi mãi, ko bị mất như print)
Set màu chữ thì dùng nst_color_saytext()
hình như thế

---------- Post added at 21:09 ---------- Previous post was at 21:06 ----------

làm j có event gì tên my_health bạn?, với lại hud msg bạn còn chưa set tọa độ nữa...
/QUOTE]

Vậy set tọa độ kiểu gì bạn??
Tại mình đọc trong inc nó bảo là : const event nên là mình tưởng đặt tên gì cũng được ^^ hóa ra không phải thế ha?
 
@duy: Mới học đc cái event àh, sao thích nó thế =)), ta còn chưa tìm hiểu xem event là cái j` đây =))
 
@buiduchuy111:
- Set tọa độ thì chỉ kó set_hudmessage có thôi, client_print ko có. Chỉ có 1 cách set thôi. đó là khi làm plugin phải làm = AMX Studio. rồi trên tool nó có cái tool tạo HudMessage. ấn vô rồi kéo theo ý thích (X, Y). X là dọc, Y là ngang

@legiondark:
- Mở ngoặc nhưng ko đóng ngoặc
 
Lỗi tùm lum, nhờ các coders sửa hộ
PHP:
#include <amxmodx>
#include <engine>
#include <engine>


#define PLUGIN    "Suicide Bombings"
#define AUTHOR    "LegionDark"
#define VERSION    "1.0"

new cvar_onoff
new cvar_fradius
new cvar_fdamage
new explodespr

public plugin_precache()
{
	explodespr = precache_model("sprites/zerogxplode.spr")
}

public plugin_init()
	{
		register_plugin(PLUGIN,AUTHOR,VERSION)
		register_concmd("LD_sb", "sui_bomb")
		cvar_onoff = register_cvar("LD_onoff","1")
		cvar_fradius = register_cvar("LD_sb_radius", "100")
		cvar_fdamage = register_cvar("LD_sb_dmg","100")
	}
public sui_bomb(id)
{
	static float:origin(3)
	entity_get_vector(id,EV_VEC_origin,origin)
	if(get_pcvar_num(cvar_onoff))
	{
	if(is_user_alive(id))
		user_kill(id)
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(3);
		write_coord(floatround(origin[0]));
		write_coord(floatround(origin[1]));
		write_coord(floatround(origin[2]));
		write_short(explodespr);
		write_byte(40);
		write_byte(12);
		write_byte(40);
		message_end();
		radius_damage(origin,get_pcvar_float(cvar_fdamage),get_pcvar_float(cvar_fradius))		
	else 
	client_print(id,print_center,"Plugin nay chua duoc bat")
	}	
}
 
vài event thườg dùg cho newbie vọc nà.
Health
Damage
HLTV
DeathMsg
CurWeapon
TraceAttack
 
Ai có thể HD cho em cách tách các câu lệnh không cần thiết đi ra không :(
anh red share cho cái plugins mà không biết tách các câu lệnh kiểu gì :((
 
Thành công, mặc dù vẫn còn lỗi nhưng coi như thành công 75 % rồi
Hình đây:

SuiBom.jpg


Và đây là lỗi :

SuiBom2.jpg


(k hiểu vì sao mình check alive rồi mà vẫn bị lỗi này)
P/s : Sau khi chỉnh radius lên 1000 thì ta có kết quả là die cả phòng =))
 

Attachments

  • SuiBom.jpg
    SuiBom.jpg
    55.1 KB · Đọc: 1
  • legion_haut.jpg
    legion_haut.jpg
    15.4 KB · Đọc: 2
  • SuiBom2.jpg
    SuiBom2.jpg
    30.3 KB · Đọc: 1
Chỉnh sửa cuối:
Back
Top