[AMX][Codes] Hỏi đáp về các code của AMX ...

  • Thread starter Thread starter sontung0
  • Ngày gửi Ngày gửi
Status
Không mở trả lời sau này.
mình chưa test trong game đc nhưng hình như là khi ammo pack thay đổi thì hiện lên chữ [ + % AP ]. còn 1 chức năng nữa là khi gõ /change thì thấy lượng AP thay đổi từ đầu round :|
chả hỉu sao để tiếng Nga thì compile ok , chuyển mấy cái text trong dấu " " thì compile báo lỗi

Mã:
/* [ZP] AmmoChange v1.0 */
/* Руссифицировано */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <zombieplague>

new ammo[3][33],string[21],cvarShowType,ammopacks

public plugin_init() {
	register_plugin("[ZP] AmmoChange", "1.0", "ZETA [M|E|N]")
	register_logevent("round_start", 2, "1=Round_Start")
	cvarShowType = register_cvar("ac_show_type", "1")
	
	register_clcmd("say /change","func_change",ADMIN_ALL,"")
}

public round_start() {
	new players[32],num,i
	get_players(players,num)
	
	for(i=1;i<num;i++) {
		ammo[0][players[i]] = zp_get_user_ammo_packs(players[i])
	}
}

public client_putinserver(id) {
	set_task(3.0,"func_ammo",id)
}

public func_ammo(id) {
	ammopacks = zp_get_user_ammo_packs(id)
	
	ammo[0][id] = ammopacks
	ammo[1][id] = ammopacks
	ammo[2][id] = ammopacks
	
	set_task(1.0,"change_ammo",id,_,_,"b")
}

public change_ammo(id) {
	if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
		return PLUGIN_HANDLED
		
	ammo[1][id] = zp_get_user_ammo_packs(id)
		
	if(ammo[1][id] != ammo[2][id]) {
		if(ammo[1][id] > ammo[2][id]) {
			ammopacks = ammo[1][id] - ammo[2][id]
			format(string,charsmax(string),"[ +%d аммо ]", ammopacks)
		}
		else {
			ammopacks = ammo[2][id] - ammo[1][id]
			format(string,charsmax(string),"[ -%d аммо ]", ammopacks)
		}
		
		ammo[2][id] = ammo[1][id]
		
		if(get_pcvar_num(cvarShowType)) {
			set_hudmessage(180, 180, 180, 0.51, 0.51, 0, 6.0, 3.0,_,_,3)
			show_hudmessage(id, "%s", string)
		}
		else
			client_print(id, print_center, "%s", string)
	}
	
	return PLUGIN_HANDLED
}

public client_disconnect(id) {
	ammo[0][id] = 0
	ammo[1][id] = 0
	ammo[2][id] = 0
	
	remove_task(id)
}

public func_change(id) {
	if(ammo[0][id] != ammo[2][id]) {
		if(ammo[0][id] > ammo[2][id]) {
			ammopacks = ammo[0][id] - ammo[2][id]
			client_print(id,print_chat,"[ZP] Ваше аммо уменьшилось на %d.", ammopacks)
		}
		else {
			ammopacks = ammo[2][id] - ammo[0][id]
			client_print(id,print_chat,"[ZP] Ваше аммо увеличилось на %d.", ammopacks)
		}
	}
	else 
		client_print(id,print_chat,"[ZP] Ваше аммо не изменилось.")
	return PLUGIN_HANDLED
}
 
client_print(id,print_chat,"[ZP] Ваше аммо уменьшилось на %d.", ammopacks)
client_print(id,print_chat,"[ZP] Ваше аммо увеличилось на %d.", ammopacks)
client_print(id,print_chat,"[ZP] Ваше аммо не изменилось.")

Muốn đổi language nó đi thì đổi nhưng phải để lại chữ %d.
 
có để lại mà , mình change thành
Mã:
/* [ZP] AmmoChange v1.0 */
/* Руссифицировано */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <zombieplague>

new ammo[3][33],string[21],cvarShowType,ammopacks

public plugin_init() {
	register_plugin("[ZP] AmmoChange", "1.0", "ZETA [M|E|N]")
	register_logevent("round_start", 2, "1=Round_Start")
	cvarShowType = register_cvar("ac_show_type", "1")
	
	register_clcmd("say /change","func_change",ADMIN_ALL,"")
}

public round_start() {
	new players[32],num,i
	get_players(players,num)
	
	for(i=1;i<num;i++) {
		ammo[0][players[i]] = zp_get_user_ammo_packs(players[i])
	}
}

public client_putinserver(id) {
	set_task(3.0,"func_ammo",id)
}

public func_ammo(id) {
	ammopacks = zp_get_user_ammo_packs(id)
	
	ammo[0][id] = ammopacks
	ammo[1][id] = ammopacks
	ammo[2][id] = ammopacks
	
	set_task(1.0,"change_ammo",id,_,_,"b")
}

public change_ammo(id) {
	if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
		return PLUGIN_HANDLED
		
	ammo[1][id] = zp_get_user_ammo_packs(id)
		
	if(ammo[1][id] != ammo[2][id]) {
		if(ammo[1][id] > ammo[2][id]) {
			ammopacks = ammo[1][id] - ammo[2][id]
			format(string,charsmax(string)," +%d аммо ", ammopacks)
		}
		else {
			ammopacks = ammo[2][id] - ammo[1][id]
			format(string,charsmax(string)," -%d аммо ", ammopacks)
		}
		
		ammo[2][id] = ammo[1][id]
		
		if(get_pcvar_num(cvarShowType)) {
			set_hudmessage(180, 180, 180, 0.51, 0.51, 0, 6.0, 3.0,_,_,3)
			show_hudmessage(id, "%s", string)
		}
		else
			client_print(id, print_center, "%s", string)
	}
	
	return PLUGIN_HANDLED
}

public client_disconnect(id) {
	ammo[0][id] = 0
	ammo[1][id] = 0
	ammo[2][id] = 0
	
	remove_task(id)
}

public func_change(id) {
	if(ammo[0][id] != ammo[2][id]) {
		if(ammo[0][id] > ammo[2][id]) {
			ammopacks = ammo[0][id] - ammo[2][id]
			client_print(id,print_chat,"[ZP] Your AP was decreased by %d.", ammopacks)
		}
		else {
			ammopacks = ammo[2][id] - ammo[0][id]
			client_print(id,print_chat,"[ZP] Your AP was increased by %d.", ammopacks)
		}
	}
	else 
		client_print(id,print_chat,"[ZP] Not changed.")
	return PLUGIN_HANDLED
}
nó báo lỗi thế này :
//// zp_ammochange.sma
// D:\Game\CS ZP\cstrike\addons\amxmodx\scripting\zp_ammochange.sma(1) : error 0
10: invalid function or declaration
//
// 1 Error.
// Could not locate output file compiled\zp_ammochange.amx (compile failed).
//
// Compilation Time: 0.55 sec
 
Chỉnh sửa cuối:
compile nó báo lỗi đó đó T_T , bạn ông compile sau khi sửa language hay trước ? ko sửa language thì nó ko báo lỗi U_U

thử sửa 1 chữ cái thui nó cũng ra lỗi lun @@

khó hỉu wá , tui sửa cái cvar cũng bị lỗi , nói chung sửa bất cứ gì cũng ra cái lỗi đó , ko bít compiler có bị gì ko nữa , ông sửa rùi compile lại rùi send tui file amxx đc hok T_T
cvarShowType = register_cvar("ac_show_type", "0")
format(string,charsmax(string)," +%d AP ", ammopacks)
format(string,charsmax(string)," -%d AP ", ammopacks)
client_print(id,print_chat,"[ZP] Your AP was decreased by %d.", ammopacks)
client_print(id,print_chat,"[ZP] Your AP was increased by %d.", ammopacks)
client_print(id,print_chat,"[ZP] Not changed.")
 
Chỉnh sửa cuối:
vẫn bị @@. chả hỉu nổi , mấy plugin khác compile ok , mà sao cái này ... ông sửa dùm tui rùi compile giúp cái :(
 
Đang dùng điện thoại thì làm làm sao...mà chả có Cs để setup amxx vào khi ngoài net..
 
__Chief__ a.k.a -Wesker-

Xong rồi đây, lỗi ở dòng 83 #:-s thừa 1 cái dấu "
[spoil]
PHP:
//* [ZP] AmmoChange v1.0 *//

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <zombieplague>

new ammo[3][33],string[21],cvarShowType,ammopacks

public plugin_init() {
	register_plugin("[ZP] AmmoChange", "1.0", "ZETA [M|E|N]")
	register_logevent("round_start", 2, "1=Round_Start")
	cvarShowType = register_cvar("ac_show_type", "1")
	
	register_clcmd("say /change","func_change",ADMIN_ALL,"")
}

public round_start() {
	new players[32],num,i
	get_players(players,num)
	
	for(i=1;i<num;i++) {
		ammo[0][players[i]] = zp_get_user_ammo_packs(players[i])
	}
}

public client_putinserver(id) {
	set_task(3.0,"func_ammo",id)
}

public func_ammo(id) {
	ammopacks = zp_get_user_ammo_packs(id)
	
	ammo[0][id] = ammopacks
	ammo[1][id] = ammopacks
	ammo[2][id] = ammopacks
	
	set_task(1.0,"change_ammo",id,_,_,"b")
}

public change_ammo(id) {
	if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
		return PLUGIN_HANDLED
		
	ammo[1][id] = zp_get_user_ammo_packs(id)
		
	if(ammo[1][id] != ammo[2][id]) {
		if(ammo[1][id] > ammo[2][id]) {
			ammopacks = ammo[1][id] - ammo[2][id]
			format(string,charsmax(string),"[ +%d аммо ]", ammopacks)
		}
		else {
			ammopacks = ammo[2][id] - ammo[1][id]
			format(string,charsmax(string),"[ -%d аммо ]", ammopacks)
		}
		
		ammo[2][id] = ammo[1][id]
		
		if(get_pcvar_num(cvarShowType)) {
			set_hudmessage(180, 180, 180, 0.51, 0.51, 0, 6.0, 3.0,_,_,3)
			show_hudmessage(id, "%s", string)
		}
		else
			client_print(id, print_center, "%s", string)
	}
	
	return PLUGIN_HANDLED
}

public client_disconnect(id) {
	ammo[0][id] = 0
	ammo[1][id] = 0
	ammo[2][id] = 0
	
	remove_task(id)
}

public func_change(id) {
	if(ammo[0][id] != ammo[2][id]) {
		if(ammo[0][id] > ammo[2][id]) {
			ammopacks = ammo[0][id] - ammo[2][id]
			client_print(id,print_chat,"[ZP] Your AP was decreased by %d.", ammopacks)
		}
		else {
			ammopacks = ammo[2][id] - ammo[0][id]
			client_print(id,print_chat,"[ZP] Your AP was decreased by %d.", ammopacks)
		}
	}
	else 
		client_print(id,print_chat,"[ZP] Your AP was increased by %d.")
	return PLUGIN_HANDLED
}
[/spoil]

Tôi fix xong lỗi rồi đấy, trong cái file attach ở dưới có cả file source và file amxx. Cái file sma mình chưa edit hết các tiếng Nga nên bạn về làm nốt có gì report lại
View attachment ZP.Ammo_Change.rar
 
cảm ơn nhìu lắm , chưa test nhưng cứ cảm ơn ^^

____

ko đc , vẫn bị lỗi như thế , quái thật , bạn compile có bị ko ?
 
Chỉnh sửa cuối:
vậy nhờ bạn sửa thành tiếng anh hết rùi compile cho mình lun đc ko ? gửi cho mình cái file .amxx đi
cvarShowType = register_cvar("ac_show_type", "0")


format(string,charsmax(string)," +%d AP ", ammopacks)

format(string,charsmax(string)," -%d AP ", ammopacks)



public func_change(id) {
if(ammo[0][id] != ammo[2][id]) {
if(ammo[0][id] > ammo[2][id]) {
ammopacks = ammo[0][id] - ammo[2][id]
client_print(id,print_chat,"[ZP] Your AP was decreased by %d.", ammopacks)
}
else {
ammopacks = ammo[2][id] - ammo[0][id]
client_print(id,print_chat,"[ZP] Your AP was increased by %d.", ammopacks)
}
}
else
client_print(id,print_chat,"[ZP] Not changed.")

__________________

cái bạn gửi mình thì ko bị lỗi nhưng chỉ cần mình sửa 1 chữ cái trong " " là lỗi @@
 
Chỉnh sửa cuối:
Thế thì đừng có sửa thêm :|.. Mặc định nó như thế nào để yên đi.
 
Lỗi là do bắt nguồn từ 2 dấu ", vì khi check code và compile thấy báo lỗi đúng dòng thừa " nên hiểu ra ngay.
 
Status
Không mở trả lời sau này.
Back
Top