Page 1 of 1

Eroare compilare plugin chat [Rezolvat]

Posted: 10 Aug 2019, 00:56
by Pegasus6ix
Salut, am aceasta sursa de RangAdminChat iar cand incerc s-o compilez imi da urmatoarele erori :
| Afiseaza codul
//// furien_rang_chat.sma
Scripting Compiler\furien_rang_chat.sma(15) : error 001: expected token: "}", but found "-string-"
Scripting Compiler\furien_rang_chat.sma(206) : error 032: array index out of bounds (variable "Rang")
Scripting Compiler\furien_rang_chat.sma(302) : error 032: array index out of bounds (variable "Rang")
//
// 3 Errors.
// Could not locate output file compiled\furien_rang_chat.amx (compile failed).
//
// Compilation Time: 0.23 sec

Aici este sursa completa :
| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Chat/Hud"
#define VERSION "4.0"
#define AUTHOR "Aragon*"

#define TEAM_CT_NAME	"Anti Furien"
#define TEAM_T_NAME	"Furien"

new Rang[][][] = {
	{"Fondator",	"abcdefghijklmnopqrstu"},
	{"Owner",	"abcdegfhijmnopqrs"},
	{"Co-Owner"	"bcdefijmnopqrs"},
	{"GOD",		"bcdefijmnopqr"},
	{"Administrator",	"bcdefijmnopq"},
	{"Helper",	"bcehi},
	{"Slot",	"b"},
	{"V.I.P",	"bct"}
}

enum COLOR {
	NORMAL = 1,
	GREEN, 
	TEAM_COLOR, 
	GREY, 
	RED, 
	BLUE,
};

new Values[][] = {
	{255, 255, 255},
	{255, 0, 0},
	{0, 255, 0},
	{0, 0, 255}, 
	{255, 255, 0}, 
	{255, 0, 255}, 
	{0, 255, 255}, 
	{227, 96, 8}, 
	{45, 89, 116}, 
	{103, 44, 38}
}

new Float:Position[][] = {
	{0.05, 0.55}, 
	{-1.0, 0.2}, 
	{-1.0, 0.7}
}

new Float:BDPosition[][] = {
	{0.50, 0.40},
	{0.56, 0.44},
	{0.60, 0.50},
	{0.56, 0.56},
	{0.50, 0.60},
	{0.44, 0.56},
	{0.40, 0.50},
	{0.44, 0.44}
}

new Float:Flooding[33] = {0.0, ...}
new Flood[33] = {0, ...}
new MessageChannel, PlayerPos[33]

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_concmd("amx_say", "CmdSay", ADMIN_CHAT, "<message> - sends message to all players")
	register_concmd("amx_psay", "CmdPrivateSay", ADMIN_CHAT, "<name or #userid> <message> - sends private message")
	
	register_clcmd("say","Say");
	register_clcmd("say_team","SayTeam");
	register_clcmd("svip", "ServerIP");
	
	RegisterHam(Ham_TakeDamage,"player","HAM_TakeDamage");
}

public ServerIP(id) {
	new ServerIp[20];
	get_user_ip(0, ServerIp, charsmax(ServerIp)); 
	client_print(id, print_chat, "%s", ServerIp);
}
	
public CmdSay(id, level, cid) {
	if (cmd_access(id, level, cid, 2)) {
		new Message[192], Nick[32];
		read_args(Message, sizeof(Message) - 1);
		remove_quotes(Message);
		get_user_name(id, Nick, sizeof(Nick) - 1);
		
		ColorChat(0, GREEN, "(ALL)^x03 %s :^x01 %s", Nick, Message);
	}
}

public CmdPrivateSay(id, level, cid) {
	if (cmd_access(id, level, cid, 3)) {
		new Nick[32]
		read_argv(1, Nick, 31)
		new Target = cmd_target(id, Nick, 0)
		
		if (Target) {
			new Length = strlen(Nick) + 1
			
			new Message[192], TargetName[32]
			get_user_name(id, Nick, 31)
			get_user_name(Target, TargetName, 31); 
			read_args(Message, 191)
			
			if(Message[0] == '"' && Message[Length] == '"') {
				Message[0] = ' '
				Message[Length] = ' '
				Length += 2
			}
			
			remove_quotes(Message[Length])
			if(id != Target) {
				ColorChat(id, GREEN, "(%s)^x03 %s^x04 :^x01 %s", Nick, TargetName, Message[Length])
				ColorChat(Target, GREEN, "(%s)^x03 %s^x04 :^x01 %s", Nick, TargetName, Message[Length])
			}
		}
	}
	return PLUGIN_CONTINUE
}

public Say(id) {
	new Float:MaxChat = 0.5
	
	if (MaxChat && !(get_user_flags(id) & ADMIN_IMMUNITY)) {
		new Float:Time = get_gametime()
		
		if (Flooding[id] > Time) {
			if (Flood[id] >= 3) {
				client_print(id, print_notify, "** Stop flooding the server! **")
				Flooding[id] = Time + MaxChat + 3.0
				return PLUGIN_HANDLED
			}
			Flood[id]++
		}
		else if (Flood[id])
			Flood[id]--
		
		Flooding[id] = Time + MaxChat
	}
	
	new Nick[32];
	get_user_name(id, Nick, sizeof(Nick) - 1);
	
	new Message[192];
	read_args(Message, sizeof(Message) - 1);
	remove_quotes(Message);
	
	if(equali(Message,"") || is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	new Said[6], i = 0
	read_argv(1, Said, 5)
	
	while(Said == '@')
		i++
	
	if (i && i <= 3 && access(id, ADMIN_CHAT)) {	
		new Color = 0			
		switch(Said) {
			case 'r': 
				Color = 1
			case 'g': 
				Color = 2
			case 'b': 
				Color = 3
			case 'y': 
				Color = 4
			case 'm': 
				Color = 5
			case 'c': 
				Color = 6
			case 'o': 
				Color = 7
			
		}
		new n, s = i
		if (Color) {
			n++
			s++
		}
		while (Said[s] && isspace(Said[s])) {
			n++
			s++
		}
		
		if (++MessageChannel > 6 || MessageChannel < 3)
			MessageChannel = 3
		
		new Float:VerticalPosition = Position[i-1][1] + float(MessageChannel) / 35.0
		
		new HMessage[128];
		formatex(HMessage,sizeof(HMessage)-1,"%s : %s", Nick, Message[i+n])
		
		HudMessage(0, HMessage, Values[Color][0], Values[Color][1], Values[Color][2], Position[i-1][0], VerticalPosition, 0, 12.0, 6.0, 0.1, 1.5)
		client_print(0, print_notify, "%s : %s", Nick, Message[i+n])
		return PLUGIN_HANDLED;
	}
	
	else if(is_user_admin(id)) {
		for(new i = 0; i < sizeof Rang; i++) {
			if(get_user_flags(id) == read_flags(Rang [1])) {
				switch(get_user_team(id)) {
					case 1: 
						ColorChat(0, RED, "%s%s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Rang[0], Message);
					case 2:
						ColorChat(0, BLUE, "%s%s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Rang[0], Message);
					case 3:
						ColorChat(0, GREY, "%s^x04 (%s) :^x01 %s",Nick, Rang[0], Message);
				}
				return PLUGIN_HANDLED;
			}
		}
		
		switch(get_user_team(id)) {
			case 1: 
				ColorChat(0, RED, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 2:
				ColorChat(0, BLUE, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 3:
				ColorChat(0, GREY, "%s^x04 :^x01 %s",Nick, Message);
		}
		return PLUGIN_HANDLED;
	}
	else {
		switch(get_user_team(id)) {
			case 1: 
				ColorChat(0, RED, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 2:
				ColorChat(0, BLUE, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 3:
				ColorChat(0, GREY, "%s^x04 :^x01 %s",Nick, Message);
		}
		return PLUGIN_HANDLED;
		
	}
	return PLUGIN_CONTINUE;
}

public SayTeam(id) {
	new Float:MaxChat = 0.5
	
	if (MaxChat && !(get_user_flags(id) & ADMIN_IMMUNITY)) {
		new Float:Time = get_gametime()
		
		if (Flooding[id] > Time) {
			if (Flood[id] >= 3) {
				client_print(id, print_notify, "** Stop flooding the server! **")
				Flooding[id] = Time + MaxChat + 3.0
				return PLUGIN_HANDLED
			}
			Flood[id]++
		}
		else if (Flood[id])
			Flood[id]--
		
		Flooding[id] = Time + MaxChat
	}
	
	new Nick[32];
	get_user_name(id, Nick, sizeof(Nick) - 1);
	
	static Message[192];
	read_args(Message, sizeof(Message) - 1);
	remove_quotes(Message);
	
	if(equali(Message,"") || is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	new Said[2]
	read_argv(1, Said, 1)
	
	if (Said[0] == '@') {
		if (is_user_admin(id))
			ColorChat(id, RED, "(ADMIN)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
		else
			ColorChat(id, RED, "(PLAYER)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
		
		new Players[32], Num;
		get_players(Players, Num, "c");
		
		for (new i = 0; i < Num; ++i) {
			if (Players != id && get_user_flags(Players) & ADMIN_CHAT) {
				if (is_user_admin(id))
					ColorChat(Players, RED, "(ADMIN)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
				else
					ColorChat(Players, RED, "(PLAYER)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
			}
		}
		return PLUGIN_HANDLED;
	}
	
	else if(is_user_admin(id)) {
		for(new i = 0; i < sizeof Rang; i++) {
			new Players[32],Num;
			get_players(Players, Num, "c");
			
			if(get_user_flags(id) == read_flags(Rang [i][1])) {
				for(new X = 0; X < Num; X++) {
					switch(get_user_team(id)) {
						case 1: {
							if(get_user_team(Players[X]) == 1)
								ColorChat(Players[X], RED, "%s(%s) %s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Rang[i][0], Message);
						}
						case 2: {
							if(get_user_team(Players[X]) == 2)
								ColorChat(Players[X], BLUE, "%s(%s) %s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Rang[i][0], Message);
						}
						case 3: {
							if(get_user_team(Players[X]) == 3)
								ColorChat(Players[X], GREY, "(Spectator) %s^x04 (%s) :^x01 %s",Nick, Rang[i][0], Message);
						}
					}
				}
				return PLUGIN_HANDLED;
			}
		}
		new Players[32],Num;
		get_players(Players, Num, "c");
		
		for(new X = 0; X < Num; X++) {
			switch(get_user_team(id)) {
				case 1: {
					if(get_user_team(Players[X]) == 1)
						ColorChat(Players[X], RED, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Message);
				}
				case 2: {
					if(get_user_team(Players[X]) == 2)
						ColorChat(Players[X], BLUE, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Message);
				}
				case 3: {
					if(get_user_team(Players[X]) == 3)
						ColorChat(Players[X], GREY, "(Spectator) %s^x04 :^x01 %s",Nick, Message);
				}
			}
		}
		return PLUGIN_HANDLED;
	}
	else {
		new Players[32],Num;
		get_players(Players, Num, "c");
		
		for(new X = 0; X < Num; X++) {
			switch(get_user_team(id)) {
				case 1: {
					if(get_user_team(Players[X]) == 1)
						ColorChat(Players[X], RED, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Message);
				}
				case 2: {
					if(get_user_team(Players[X]) == 2)
						ColorChat(Players[X], BLUE, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Message);
				}
				case 3: {
					if(get_user_team(Players[X]) == 3)
						ColorChat(Players[X], GREY, "(Spectator) %s^x04 :^x01 %s",Nick, Message);
				}
			}
		}
		return PLUGIN_HANDLED;
	}
	return PLUGIN_CONTINUE;
}

public HAM_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) {
	if(is_user_connected(attacker) && is_user_connected(victim) && attacker != victim)  {
		if(is_user_alive(attacker) && get_user_team(victim) != get_user_team(attacker)) {
			new Pos = ++PlayerPos[attacker]
			if(Pos >= sizeof(BDPosition))
				Pos = PlayerPos[attacker] = 0
			
			new Damage[16];
			formatex(Damage,sizeof(Damage)-1,"%d", floatround(damage));
			
			HudMessage(attacker, Damage, 50, 205, 50, Float:BDPosition[Pos][0], Float:BDPosition[Pos][1], 2, 1.0, 2.5, 0.02, 0.02)
		}
	}
}


#define clamp_byte(%1)       ( clamp( %1, 0, 255 ) )
#define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) )
				
stock HudMessage(const id, const message[], red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 6.0, Float:holdtime = 3.0, Float:fadeintime = 0.1, Float:fadeouttime = 1.5) {
	new count = 1, players[32];
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players[i])) {	
				new color = pack_color(clamp_byte(red), clamp_byte(green), clamp_byte(blue))
				
				message_begin(MSG_ONE_UNRELIABLE, SVC_DIRECTOR, _, players[i]);
				write_byte(strlen(message) + 31);
				write_byte(DRC_CMD_MESSAGE);
				write_byte(effects);
				write_long(color);
				write_long(_:x);
				write_long(_:y);	
				write_long(_:fadeintime);
				write_long(_:fadeouttime);
				write_long(_:holdtime);
				write_long(_:fxtime);
				write_string(message);
				message_end();
			}
		}
	}
}

new TeamName[][] =  {
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
};

stock ColorChat(id, COLOR:type, const msg[],...) {
	new Message[252];
	switch(type) {
		case NORMAL:
			Message[0] = 0x01;
		case GREEN:
			Message[0] = 0x04;
		default:
		Message[0] = 0x03;
	}
	
	vformat(Message[1], 251, msg, 4);
	Message[192] = '^0';
	new Team, ColorChange, index, MSG_Type;
	
	if(id) {
		MSG_Type = MSG_ONE;
		index = id;
	}
	else {
		index = FindPlayer();
		MSG_Type = MSG_ALL;
	}
	
	Team = get_user_team(index);
	ColorChange = ColorSelection(index, MSG_Type, type);
	
	ShowColorMessage(index, MSG_Type, Message);
	
	if(ColorChange) 
		Team_Info(index, MSG_Type, TeamName[Team]);
}

stock ShowColorMessage(id, type, message[]) {
	static bool:saytext_used;
	static get_user_msgid_saytext;
	
	if(!saytext_used) {
		get_user_msgid_saytext = get_user_msgid("SayText");
		saytext_used = true;
	}
	message_begin(type, get_user_msgid_saytext, _, id);
	write_byte(id);
	write_string(message);
	message_end();   
}

stock Team_Info(id, type, team[]) {
	static bool:teaminfo_used;
	static get_user_msgid_teaminfo;
	
	if(!teaminfo_used) {
		get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
		teaminfo_used = true;
	}
	message_begin(type, get_user_msgid_teaminfo, _, id);
	write_byte(id);
	write_string(team);
	message_end();
	
	return 1;
}

stock ColorSelection(index, type, COLOR:Type) {
	switch(Type) {
		case RED:
			return Team_Info(index, type, TeamName[1]);
		case BLUE:
			return Team_Info(index, type, TeamName[2]);
		case GREY:
			return Team_Info(index, type, TeamName[0]);
	}
	return 0;
}

stock FindPlayer() {
	new i = -1;
	
	while(i <= get_maxplayers()) {
		if(is_user_connected(++i))
			return i;
	}
	
	return -1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/


Ma poate ajuta cineva ?

Re: Eroare compilare plugin chat

Posted: 10 Aug 2019, 01:26
by levin

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Chat/Hud"
#define VERSION "4.0"
#define AUTHOR "Aragon*"

#define TEAM_CT_NAME	"Anti Furien"
#define TEAM_T_NAME	"Furien"

new Rang[][][] = {
	{"Fondator",	"abcdefghijklmnopqrstu"},
	{"Owner",	"abcdegfhijmnopqrs"},
	{"Co-Owner",	"bcdefijmnopqrs"},
	{"GOD",		"bcdefijmnopqr"},
	{"Administrator",	"bcdefijmnopq"},
	{"Helper",	"bcehi"},
	{"Slot",	"b"},
	{"V.I.P",	"bct"}
}

enum COLOR {
	NORMAL = 1,
	GREEN, 
	TEAM_COLOR, 
	GREY, 
	RED, 
	BLUE,
};

new Values[][] = {
	{255, 255, 255},
	{255, 0, 0},
	{0, 255, 0},
	{0, 0, 255}, 
	{255, 255, 0}, 
	{255, 0, 255}, 
	{0, 255, 255}, 
	{227, 96, 8}, 
	{45, 89, 116}, 
	{103, 44, 38}
}

new Float:Position[][] = {
	{0.05, 0.55}, 
	{-1.0, 0.2}, 
	{-1.0, 0.7}
}

new Float:BDPosition[][] = {
	{0.50, 0.40},
	{0.56, 0.44},
	{0.60, 0.50},
	{0.56, 0.56},
	{0.50, 0.60},
	{0.44, 0.56},
	{0.40, 0.50},
	{0.44, 0.44}
}

new Float:Flooding[33] = {0.0, ...}
new Flood[33] = {0, ...}
new MessageChannel, PlayerPos[33]

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_concmd("amx_say", "CmdSay", ADMIN_CHAT, "<message> - sends message to all players")
	register_concmd("amx_psay", "CmdPrivateSay", ADMIN_CHAT, "<name or #userid> <message> - sends private message")
	
	register_clcmd("say","Say");
	register_clcmd("say_team","SayTeam");
	register_clcmd("svip", "ServerIP");
	
	RegisterHam(Ham_TakeDamage,"player","HAM_TakeDamage");
}

public ServerIP(id) {
	new ServerIp[20];
	get_user_ip(0, ServerIp, charsmax(ServerIp)); 
	client_print(id, print_chat, "%s", ServerIp);
}
	
public CmdSay(id, level, cid) {
	if (cmd_access(id, level, cid, 2)) {
		new Message[192], Nick[32];
		read_args(Message, sizeof(Message) - 1);
		remove_quotes(Message);
		get_user_name(id, Nick, sizeof(Nick) - 1);
		
		ColorChat(0, GREEN, "(ALL)^x03 %s :^x01 %s", Nick, Message);
	}
}

public CmdPrivateSay(id, level, cid) {
	if (cmd_access(id, level, cid, 3)) {
		new Nick[32]
		read_argv(1, Nick, 31)
		new Target = cmd_target(id, Nick, 0)
		
		if (Target) {
			new Length = strlen(Nick) + 1
			
			new Message[192], TargetName[32]
			get_user_name(id, Nick, 31)
			get_user_name(Target, TargetName, 31); 
			read_args(Message, 191)
			
			if(Message[0] == '"' && Message[Length] == '"') {
				Message[0] = ' '
				Message[Length] = ' '
				Length += 2
			}
			
			remove_quotes(Message[Length])
			if(id != Target) {
				ColorChat(id, GREEN, "(%s)^x03 %s^x04 :^x01 %s", Nick, TargetName, Message[Length])
				ColorChat(Target, GREEN, "(%s)^x03 %s^x04 :^x01 %s", Nick, TargetName, Message[Length])
			}
		}
	}
	return PLUGIN_CONTINUE
}

public Say(id) {
	new Float:MaxChat = 0.5
	
	if (MaxChat && !(get_user_flags(id) & ADMIN_IMMUNITY)) {
		new Float:Time = get_gametime()
		
		if (Flooding[id] > Time) {
			if (Flood[id] >= 3) {
				client_print(id, print_notify, "** Stop flooding the server! **")
				Flooding[id] = Time + MaxChat + 3.0
				return PLUGIN_HANDLED
			}
			Flood[id]++
		}
		else if (Flood[id])
			Flood[id]--
		
		Flooding[id] = Time + MaxChat
	}
	
	new Nick[32];
	get_user_name(id, Nick, sizeof(Nick) - 1);
	
	new Message[192];
	read_args(Message, sizeof(Message) - 1);
	remove_quotes(Message);
	
	if(equali(Message,"") || is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	new Said[6], i = 0
	read_argv(1, Said, 5)
	
	while(Said[i] == '@')	i++
	
	if (i && i <= 3 && access(id, ADMIN_CHAT)) {	
		new Color = 0			
		switch(Said[i]) {
			case 'r': 
				Color = 1
			case 'g': 
				Color = 2
			case 'b': 
				Color = 3
			case 'y': 
				Color = 4
			case 'm': 
				Color = 5
			case 'c': 
				Color = 6
			case 'o': 
				Color = 7
			
		}
		new n, s = i
		if (Color) {
			n++
			s++
		}
		while (Said[s] && isspace(Said[s])) {
			n++
			s++
		}
		
		if (++MessageChannel > 6 || MessageChannel < 3)
			MessageChannel = 3
		
		new Float:VerticalPosition = Position[i-1][1] + float(MessageChannel) / 35.0
		
		new HMessage[128];
		formatex(HMessage,sizeof(HMessage)-1,"%s : %s", Nick, Message[i+n])
		
		HudMessage(0, HMessage, Values[Color][0], Values[Color][1], Values[Color][2], Position[i-1][0], VerticalPosition, 0, 12.0, 6.0, 0.1, 1.5)
		client_print(0, print_notify, "%s : %s", Nick, Message[i+n])
		return PLUGIN_HANDLED;
	}
	
	else if(is_user_admin(id)) {
		for(new i = 0; i < sizeof Rang; i++) {
			if(get_user_flags(id) == read_flags(Rang [1][i])) {
				switch(get_user_team(id)) {
					case 1: 
						ColorChat(0, RED, "%s%s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Rang[0], Message);
					case 2:
						ColorChat(0, BLUE, "%s%s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Rang[0], Message);
					case 3:
						ColorChat(0, GREY, "%s^x04 (%s) :^x01 %s",Nick, Rang[0], Message);
				}
				return PLUGIN_HANDLED;
			}
		}
		
		switch(get_user_team(id)) {
			case 1: 
				ColorChat(0, RED, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 2:
				ColorChat(0, BLUE, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 3:
				ColorChat(0, GREY, "%s^x04 :^x01 %s",Nick, Message);
		}
		return PLUGIN_HANDLED;
	}
	else {
		switch(get_user_team(id)) {
			case 1: 
				ColorChat(0, RED, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 2:
				ColorChat(0, BLUE, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 3:
				ColorChat(0, GREY, "%s^x04 :^x01 %s",Nick, Message);
		}
		return PLUGIN_HANDLED;
		
	}
	return PLUGIN_CONTINUE;
}

public SayTeam(id) {
	new Float:MaxChat = 0.5
	
	if (MaxChat && !(get_user_flags(id) & ADMIN_IMMUNITY)) {
		new Float:Time = get_gametime()
		
		if (Flooding[id] > Time) {
			if (Flood[id] >= 3) {
				client_print(id, print_notify, "** Stop flooding the server! **")
				Flooding[id] = Time + MaxChat + 3.0
				return PLUGIN_HANDLED
			}
			Flood[id]++
		}
		else if (Flood[id])
			Flood[id]--
		
		Flooding[id] = Time + MaxChat
	}
	
	new Nick[32];
	get_user_name(id, Nick, sizeof(Nick) - 1);
	
	static Message[192];
	read_args(Message, sizeof(Message) - 1);
	remove_quotes(Message);
	
	if(equali(Message,"") || is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	new Said[2]
	read_argv(1, Said, 1)
	
	if (Said[0] == '@') {
		if (is_user_admin(id))
			ColorChat(id, RED, "(ADMIN)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
		else
			ColorChat(id, RED, "(PLAYER)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
		
		new Players[32], Num;
		get_players(Players, Num, "c");
		
		for (new i = 0; i < Num; ++i) {
			if (Players[i] != id && get_user_flags(Players[i]) & ADMIN_CHAT) {
				if (is_user_admin(id))
					ColorChat(Players[i], RED, "(ADMIN)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
				else
					ColorChat(Players[i], RED, "(PLAYER)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
			}
		}
		return PLUGIN_HANDLED;
	}
	
	else if(is_user_admin(id)) {
		for(new i = 0; i < sizeof Rang; i++) {
			new Players[32],Num;
			get_players(Players, Num, "c");
			
			if(get_user_flags(id) == read_flags(Rang [i][1])) {
				for(new X = 0; X < Num; X++) {
					switch(get_user_team(id)) {
						case 1: {
							if(get_user_team(Players[X]) == 1)
								ColorChat(Players[X], RED, "%s(%s) %s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Rang[i][0], Message);
						}
						case 2: {
							if(get_user_team(Players[X]) == 2)
								ColorChat(Players[X], BLUE, "%s(%s) %s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Rang[i][0], Message);
						}
						case 3: {
							if(get_user_team(Players[X]) == 3)
								ColorChat(Players[X], GREY, "(Spectator) %s^x04 (%s) :^x01 %s",Nick, Rang[i][0], Message);
						}
					}
				}
				return PLUGIN_HANDLED;
			}
		}
		new Players[32],Num;
		get_players(Players, Num, "c");
		
		for(new X = 0; X < Num; X++) {
			switch(get_user_team(id)) {
				case 1: {
					if(get_user_team(Players[X]) == 1)
						ColorChat(Players[X], RED, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Message);
				}
				case 2: {
					if(get_user_team(Players[X]) == 2)
						ColorChat(Players[X], BLUE, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Message);
				}
				case 3: {
					if(get_user_team(Players[X]) == 3)
						ColorChat(Players[X], GREY, "(Spectator) %s^x04 :^x01 %s",Nick, Message);
				}
			}
		}
		return PLUGIN_HANDLED;
	}
	else {
		new Players[32],Num;
		get_players(Players, Num, "c");
		
		for(new X = 0; X < Num; X++) {
			switch(get_user_team(id)) {
				case 1: {
					if(get_user_team(Players[X]) == 1)
						ColorChat(Players[X], RED, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Message);
				}
				case 2: {
					if(get_user_team(Players[X]) == 2)
						ColorChat(Players[X], BLUE, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Message);
				}
				case 3: {
					if(get_user_team(Players[X]) == 3)
						ColorChat(Players[X], GREY, "(Spectator) %s^x04 :^x01 %s",Nick, Message);
				}
			}
		}
		return PLUGIN_HANDLED;
	}
	return PLUGIN_CONTINUE;
}

public HAM_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) {
	if(is_user_connected(attacker) && is_user_connected(victim) && attacker != victim)  {
		if(is_user_alive(attacker) && get_user_team(victim) != get_user_team(attacker)) {
			new Pos = ++PlayerPos[attacker]
			if(Pos >= sizeof(BDPosition))
				Pos = PlayerPos[attacker] = 0
			
			new Damage[16];
			formatex(Damage,sizeof(Damage)-1,"%d", floatround(damage));
			
			HudMessage(attacker, Damage, 50, 205, 50, Float:BDPosition[Pos][0], Float:BDPosition[Pos][1], 2, 1.0, 2.5, 0.02, 0.02)
		}
	}
}


#define clamp_byte(%1)       ( clamp( %1, 0, 255 ) )
#define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) )
				
stock HudMessage(const id, const message[], red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 6.0, Float:holdtime = 3.0, Float:fadeintime = 0.1, Float:fadeouttime = 1.5) {
	new count = 1, players[32];
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players[i])) {	
				new color = pack_color(clamp_byte(red), clamp_byte(green), clamp_byte(blue))
				
				message_begin(MSG_ONE_UNRELIABLE, SVC_DIRECTOR, _, players[i]);
				write_byte(strlen(message) + 31);
				write_byte(DRC_CMD_MESSAGE);
				write_byte(effects);
				write_long(color);
				write_long(_:x);
				write_long(_:y);	
				write_long(_:fadeintime);
				write_long(_:fadeouttime);
				write_long(_:holdtime);
				write_long(_:fxtime);
				write_string(message);
				message_end();
			}
		}
	}
}

new TeamName[][] =  {
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
};

stock ColorChat(id, COLOR:type, const msg[],...) {
	new Message[252];
	switch(type) {
		case NORMAL:
			Message[0] = 0x01;
		case GREEN:
			Message[0] = 0x04;
		default:
		Message[0] = 0x03;
	}
	
	vformat(Message[1], 251, msg, 4);
	Message[192] = '^0';
	new Team, ColorChange, index, MSG_Type;
	
	if(id) {
		MSG_Type = MSG_ONE;
		index = id;
	}
	else {
		index = FindPlayer();
		MSG_Type = MSG_ALL;
	}
	
	Team = get_user_team(index);
	ColorChange = ColorSelection(index, MSG_Type, type);
	
	ShowColorMessage(index, MSG_Type, Message);
	
	if(ColorChange) 
		Team_Info(index, MSG_Type, TeamName[Team]);
}

stock ShowColorMessage(id, type, message[]) {
	static bool:saytext_used;
	static get_user_msgid_saytext;
	
	if(!saytext_used) {
		get_user_msgid_saytext = get_user_msgid("SayText");
		saytext_used = true;
	}
	message_begin(type, get_user_msgid_saytext, _, id);
	write_byte(id);
	write_string(message);
	message_end();   
}

stock Team_Info(id, type, team[]) {
	static bool:teaminfo_used;
	static get_user_msgid_teaminfo;
	
	if(!teaminfo_used) {
		get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
		teaminfo_used = true;
	}
	message_begin(type, get_user_msgid_teaminfo, _, id);
	write_byte(id);
	write_string(team);
	message_end();
	
	return 1;
}

stock ColorSelection(index, type, COLOR:Type) {
	switch(Type) {
		case RED:
			return Team_Info(index, type, TeamName[1]);
		case BLUE:
			return Team_Info(index, type, TeamName[2]);
		case GREY:
			return Team_Info(index, type, TeamName[0]);
	}
	return 0;
}

stock FindPlayer() {
	new i = -1;
	
	while(i <= get_maxplayers()) {
		if(is_user_connected(++i))
			return i;
	}
	
	return -1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/

Re: Eroare compilare plugin chat

Posted: 10 Aug 2019, 01:46
by Pegasus6ix
L E V I N wrote:
10 Aug 2019, 01:26

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Chat/Hud"
#define VERSION "4.0"
#define AUTHOR "Aragon*"

#define TEAM_CT_NAME	"Anti Furien"
#define TEAM_T_NAME	"Furien"

new Rang[][][] = {
	{"Fondator",	"abcdefghijklmnopqrstu"},
	{"Owner",	"abcdegfhijmnopqrs"},
	{"Co-Owner",	"bcdefijmnopqrs"},
	{"GOD",		"bcdefijmnopqr"},
	{"Administrator",	"bcdefijmnopq"},
	{"Helper",	"bcehi"},
	{"Slot",	"b"},
	{"V.I.P",	"bct"}
}

enum COLOR {
	NORMAL = 1,
	GREEN, 
	TEAM_COLOR, 
	GREY, 
	RED, 
	BLUE,
};

new Values[][] = {
	{255, 255, 255},
	{255, 0, 0},
	{0, 255, 0},
	{0, 0, 255}, 
	{255, 255, 0}, 
	{255, 0, 255}, 
	{0, 255, 255}, 
	{227, 96, 8}, 
	{45, 89, 116}, 
	{103, 44, 38}
}

new Float:Position[][] = {
	{0.05, 0.55}, 
	{-1.0, 0.2}, 
	{-1.0, 0.7}
}

new Float:BDPosition[][] = {
	{0.50, 0.40},
	{0.56, 0.44},
	{0.60, 0.50},
	{0.56, 0.56},
	{0.50, 0.60},
	{0.44, 0.56},
	{0.40, 0.50},
	{0.44, 0.44}
}

new Float:Flooding[33] = {0.0, ...}
new Flood[33] = {0, ...}
new MessageChannel, PlayerPos[33]

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_concmd("amx_say", "CmdSay", ADMIN_CHAT, "<message> - sends message to all players")
	register_concmd("amx_psay", "CmdPrivateSay", ADMIN_CHAT, "<name or #userid> <message> - sends private message")
	
	register_clcmd("say","Say");
	register_clcmd("say_team","SayTeam");
	register_clcmd("svip", "ServerIP");
	
	RegisterHam(Ham_TakeDamage,"player","HAM_TakeDamage");
}

public ServerIP(id) {
	new ServerIp[20];
	get_user_ip(0, ServerIp, charsmax(ServerIp)); 
	client_print(id, print_chat, "%s", ServerIp);
}
	
public CmdSay(id, level, cid) {
	if (cmd_access(id, level, cid, 2)) {
		new Message[192], Nick[32];
		read_args(Message, sizeof(Message) - 1);
		remove_quotes(Message);
		get_user_name(id, Nick, sizeof(Nick) - 1);
		
		ColorChat(0, GREEN, "(ALL)^x03 %s :^x01 %s", Nick, Message);
	}
}

public CmdPrivateSay(id, level, cid) {
	if (cmd_access(id, level, cid, 3)) {
		new Nick[32]
		read_argv(1, Nick, 31)
		new Target = cmd_target(id, Nick, 0)
		
		if (Target) {
			new Length = strlen(Nick) + 1
			
			new Message[192], TargetName[32]
			get_user_name(id, Nick, 31)
			get_user_name(Target, TargetName, 31); 
			read_args(Message, 191)
			
			if(Message[0] == '"' && Message[Length] == '"') {
				Message[0] = ' '
				Message[Length] = ' '
				Length += 2
			}
			
			remove_quotes(Message[Length])
			if(id != Target) {
				ColorChat(id, GREEN, "(%s)^x03 %s^x04 :^x01 %s", Nick, TargetName, Message[Length])
				ColorChat(Target, GREEN, "(%s)^x03 %s^x04 :^x01 %s", Nick, TargetName, Message[Length])
			}
		}
	}
	return PLUGIN_CONTINUE
}

public Say(id) {
	new Float:MaxChat = 0.5
	
	if (MaxChat && !(get_user_flags(id) & ADMIN_IMMUNITY)) {
		new Float:Time = get_gametime()
		
		if (Flooding[id] > Time) {
			if (Flood[id] >= 3) {
				client_print(id, print_notify, "** Stop flooding the server! **")
				Flooding[id] = Time + MaxChat + 3.0
				return PLUGIN_HANDLED
			}
			Flood[id]++
		}
		else if (Flood[id])
			Flood[id]--
		
		Flooding[id] = Time + MaxChat
	}
	
	new Nick[32];
	get_user_name(id, Nick, sizeof(Nick) - 1);
	
	new Message[192];
	read_args(Message, sizeof(Message) - 1);
	remove_quotes(Message);
	
	if(equali(Message,"") || is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	new Said[6], i = 0
	read_argv(1, Said, 5)
	
	while(Said[i] == '@')	i++
	
	if (i && i <= 3 && access(id, ADMIN_CHAT)) {	
		new Color = 0			
		switch(Said[i]) {
			case 'r': 
				Color = 1
			case 'g': 
				Color = 2
			case 'b': 
				Color = 3
			case 'y': 
				Color = 4
			case 'm': 
				Color = 5
			case 'c': 
				Color = 6
			case 'o': 
				Color = 7
			
		}
		new n, s = i
		if (Color) {
			n++
			s++
		}
		while (Said[s] && isspace(Said[s])) {
			n++
			s++
		}
		
		if (++MessageChannel > 6 || MessageChannel < 3)
			MessageChannel = 3
		
		new Float:VerticalPosition = Position[i-1][1] + float(MessageChannel) / 35.0
		
		new HMessage[128];
		formatex(HMessage,sizeof(HMessage)-1,"%s : %s", Nick, Message[i+n])
		
		HudMessage(0, HMessage, Values[Color][0], Values[Color][1], Values[Color][2], Position[i-1][0], VerticalPosition, 0, 12.0, 6.0, 0.1, 1.5)
		client_print(0, print_notify, "%s : %s", Nick, Message[i+n])
		return PLUGIN_HANDLED;
	}
	
	else if(is_user_admin(id)) {
		for(new i = 0; i < sizeof Rang; i++) {
			if(get_user_flags(id) == read_flags(Rang [1][i])) {
				switch(get_user_team(id)) {
					case 1: 
						ColorChat(0, RED, "%s%s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Rang[0], Message);
					case 2:
						ColorChat(0, BLUE, "%s%s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Rang[0], Message);
					case 3:
						ColorChat(0, GREY, "%s^x04 (%s) :^x01 %s",Nick, Rang[0], Message);
				}
				return PLUGIN_HANDLED;
			}
		}
		
		switch(get_user_team(id)) {
			case 1: 
				ColorChat(0, RED, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 2:
				ColorChat(0, BLUE, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 3:
				ColorChat(0, GREY, "%s^x04 :^x01 %s",Nick, Message);
		}
		return PLUGIN_HANDLED;
	}
	else {
		switch(get_user_team(id)) {
			case 1: 
				ColorChat(0, RED, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 2:
				ColorChat(0, BLUE, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 3:
				ColorChat(0, GREY, "%s^x04 :^x01 %s",Nick, Message);
		}
		return PLUGIN_HANDLED;
		
	}
	return PLUGIN_CONTINUE;
}

public SayTeam(id) {
	new Float:MaxChat = 0.5
	
	if (MaxChat && !(get_user_flags(id) & ADMIN_IMMUNITY)) {
		new Float:Time = get_gametime()
		
		if (Flooding[id] > Time) {
			if (Flood[id] >= 3) {
				client_print(id, print_notify, "** Stop flooding the server! **")
				Flooding[id] = Time + MaxChat + 3.0
				return PLUGIN_HANDLED
			}
			Flood[id]++
		}
		else if (Flood[id])
			Flood[id]--
		
		Flooding[id] = Time + MaxChat
	}
	
	new Nick[32];
	get_user_name(id, Nick, sizeof(Nick) - 1);
	
	static Message[192];
	read_args(Message, sizeof(Message) - 1);
	remove_quotes(Message);
	
	if(equali(Message,"") || is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	new Said[2]
	read_argv(1, Said, 1)
	
	if (Said[0] == '@') {
		if (is_user_admin(id))
			ColorChat(id, RED, "(ADMIN)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
		else
			ColorChat(id, RED, "(PLAYER)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
		
		new Players[32], Num;
		get_players(Players, Num, "c");
		
		for (new i = 0; i < Num; ++i) {
			if (Players[i] != id && get_user_flags(Players[i]) & ADMIN_CHAT) {
				if (is_user_admin(id))
					ColorChat(Players[i], RED, "(ADMIN)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
				else
					ColorChat(Players[i], RED, "(PLAYER)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
			}
		}
		return PLUGIN_HANDLED;
	}
	
	else if(is_user_admin(id)) {
		for(new i = 0; i < sizeof Rang; i++) {
			new Players[32],Num;
			get_players(Players, Num, "c");
			
			if(get_user_flags(id) == read_flags(Rang [i][1])) {
				for(new X = 0; X < Num; X++) {
					switch(get_user_team(id)) {
						case 1: {
							if(get_user_team(Players[X]) == 1)
								ColorChat(Players[X], RED, "%s(%s) %s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Rang[i][0], Message);
						}
						case 2: {
							if(get_user_team(Players[X]) == 2)
								ColorChat(Players[X], BLUE, "%s(%s) %s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Rang[i][0], Message);
						}
						case 3: {
							if(get_user_team(Players[X]) == 3)
								ColorChat(Players[X], GREY, "(Spectator) %s^x04 (%s) :^x01 %s",Nick, Rang[i][0], Message);
						}
					}
				}
				return PLUGIN_HANDLED;
			}
		}
		new Players[32],Num;
		get_players(Players, Num, "c");
		
		for(new X = 0; X < Num; X++) {
			switch(get_user_team(id)) {
				case 1: {
					if(get_user_team(Players[X]) == 1)
						ColorChat(Players[X], RED, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Message);
				}
				case 2: {
					if(get_user_team(Players[X]) == 2)
						ColorChat(Players[X], BLUE, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Message);
				}
				case 3: {
					if(get_user_team(Players[X]) == 3)
						ColorChat(Players[X], GREY, "(Spectator) %s^x04 :^x01 %s",Nick, Message);
				}
			}
		}
		return PLUGIN_HANDLED;
	}
	else {
		new Players[32],Num;
		get_players(Players, Num, "c");
		
		for(new X = 0; X < Num; X++) {
			switch(get_user_team(id)) {
				case 1: {
					if(get_user_team(Players[X]) == 1)
						ColorChat(Players[X], RED, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Message);
				}
				case 2: {
					if(get_user_team(Players[X]) == 2)
						ColorChat(Players[X], BLUE, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Message);
				}
				case 3: {
					if(get_user_team(Players[X]) == 3)
						ColorChat(Players[X], GREY, "(Spectator) %s^x04 :^x01 %s",Nick, Message);
				}
			}
		}
		return PLUGIN_HANDLED;
	}
	return PLUGIN_CONTINUE;
}

public HAM_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) {
	if(is_user_connected(attacker) && is_user_connected(victim) && attacker != victim)  {
		if(is_user_alive(attacker) && get_user_team(victim) != get_user_team(attacker)) {
			new Pos = ++PlayerPos[attacker]
			if(Pos >= sizeof(BDPosition))
				Pos = PlayerPos[attacker] = 0
			
			new Damage[16];
			formatex(Damage,sizeof(Damage)-1,"%d", floatround(damage));
			
			HudMessage(attacker, Damage, 50, 205, 50, Float:BDPosition[Pos][0], Float:BDPosition[Pos][1], 2, 1.0, 2.5, 0.02, 0.02)
		}
	}
}


#define clamp_byte(%1)       ( clamp( %1, 0, 255 ) )
#define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) )
				
stock HudMessage(const id, const message[], red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 6.0, Float:holdtime = 3.0, Float:fadeintime = 0.1, Float:fadeouttime = 1.5) {
	new count = 1, players[32];
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players[i])) {	
				new color = pack_color(clamp_byte(red), clamp_byte(green), clamp_byte(blue))
				
				message_begin(MSG_ONE_UNRELIABLE, SVC_DIRECTOR, _, players[i]);
				write_byte(strlen(message) + 31);
				write_byte(DRC_CMD_MESSAGE);
				write_byte(effects);
				write_long(color);
				write_long(_:x);
				write_long(_:y);	
				write_long(_:fadeintime);
				write_long(_:fadeouttime);
				write_long(_:holdtime);
				write_long(_:fxtime);
				write_string(message);
				message_end();
			}
		}
	}
}

new TeamName[][] =  {
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
};

stock ColorChat(id, COLOR:type, const msg[],...) {
	new Message[252];
	switch(type) {
		case NORMAL:
			Message[0] = 0x01;
		case GREEN:
			Message[0] = 0x04;
		default:
		Message[0] = 0x03;
	}
	
	vformat(Message[1], 251, msg, 4);
	Message[192] = '^0';
	new Team, ColorChange, index, MSG_Type;
	
	if(id) {
		MSG_Type = MSG_ONE;
		index = id;
	}
	else {
		index = FindPlayer();
		MSG_Type = MSG_ALL;
	}
	
	Team = get_user_team(index);
	ColorChange = ColorSelection(index, MSG_Type, type);
	
	ShowColorMessage(index, MSG_Type, Message);
	
	if(ColorChange) 
		Team_Info(index, MSG_Type, TeamName[Team]);
}

stock ShowColorMessage(id, type, message[]) {
	static bool:saytext_used;
	static get_user_msgid_saytext;
	
	if(!saytext_used) {
		get_user_msgid_saytext = get_user_msgid("SayText");
		saytext_used = true;
	}
	message_begin(type, get_user_msgid_saytext, _, id);
	write_byte(id);
	write_string(message);
	message_end();   
}

stock Team_Info(id, type, team[]) {
	static bool:teaminfo_used;
	static get_user_msgid_teaminfo;
	
	if(!teaminfo_used) {
		get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
		teaminfo_used = true;
	}
	message_begin(type, get_user_msgid_teaminfo, _, id);
	write_byte(id);
	write_string(team);
	message_end();
	
	return 1;
}

stock ColorSelection(index, type, COLOR:Type) {
	switch(Type) {
		case RED:
			return Team_Info(index, type, TeamName[1]);
		case BLUE:
			return Team_Info(index, type, TeamName[2]);
		case GREY:
			return Team_Info(index, type, TeamName[0]);
	}
	return 0;
}

stock FindPlayer() {
	new i = -1;
	
	while(i <= get_maxplayers()) {
		if(is_user_connected(++i))
			return i;
	}
	
	return -1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Apreciez ajutorul, pluginul se compileaza dar nu mai functioneaza :( totusi am admin dar cand scriu ceva in chat nu mai apar gradele

Re: Eroare compilare plugin chat

Posted: 10 Aug 2019, 15:02
by levin

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Chat/Hud"
#define VERSION "4.0"
#define AUTHOR "Aragon*"

#define TEAM_CT_NAME	"Anti Furien"
#define TEAM_T_NAME	"Furien"

new Rang[][][] = {
	{"Fondator",	"abcdefghijklmnopqrstu"},
	{"Owner",	"abcdegfhijmnopqrs"},
	{"Co-Owner",	"bcdefijmnopqrs"},
	{"GOD",		"bcdefijmnopqr"},
	{"Administrator",	"bcdefijmnopq"},
	{"Helper",	"bcehi"},
	{"Slot",	"b"},
	{"V.I.P",	"bct"}
}

enum COLOR {
	NORMAL = 1,
	GREEN, 
	TEAM_COLOR, 
	GREY, 
	RED, 
	BLUE,
};

new Values[][] = {
	{255, 255, 255},
	{255, 0, 0},
	{0, 255, 0},
	{0, 0, 255}, 
	{255, 255, 0}, 
	{255, 0, 255}, 
	{0, 255, 255}, 
	{227, 96, 8}, 
	{45, 89, 116}, 
	{103, 44, 38}
}

new Float:Position[][] = {
	{0.05, 0.55}, 
	{-1.0, 0.2}, 
	{-1.0, 0.7}
}

new Float:BDPosition[][] = {
	{0.50, 0.40},
	{0.56, 0.44},
	{0.60, 0.50},
	{0.56, 0.56},
	{0.50, 0.60},
	{0.44, 0.56},
	{0.40, 0.50},
	{0.44, 0.44}
}

new Float:Flooding[33] = {0.0, ...}
new Flood[33] = {0, ...}
new MessageChannel, PlayerPos[33]

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_concmd("amx_say", "CmdSay", ADMIN_CHAT, "<message> - sends message to all players")
	register_concmd("amx_psay", "CmdPrivateSay", ADMIN_CHAT, "<name or #userid> <message> - sends private message")
	
	register_clcmd("say","Say");
	register_clcmd("say_team","SayTeam");
	register_clcmd("svip", "ServerIP");
	
	RegisterHam(Ham_TakeDamage,"player","HAM_TakeDamage");
}

public ServerIP(id) {
	new ServerIp[20];
	get_user_ip(0, ServerIp, charsmax(ServerIp)); 
	client_print(id, print_chat, "%s", ServerIp);
}
	
public CmdSay(id, level, cid) {
	if (cmd_access(id, level, cid, 2)) {
		new Message[192], Nick[32];
		read_args(Message, sizeof(Message) - 1);
		remove_quotes(Message);
		get_user_name(id, Nick, sizeof(Nick) - 1);
		
		ColorChat(0, GREEN, "(ALL)^x03 %s :^x01 %s", Nick, Message);
	}
}

public CmdPrivateSay(id, level, cid) {
	if (cmd_access(id, level, cid, 3)) {
		new Nick[32]
		read_argv(1, Nick, 31)
		new Target = cmd_target(id, Nick, 0)
		
		if (Target) {
			new Length = strlen(Nick) + 1
			
			new Message[192], TargetName[32]
			get_user_name(id, Nick, 31)
			get_user_name(Target, TargetName, 31); 
			read_args(Message, 191)
			
			if(Message[0] == '"' && Message[Length] == '"') {
				Message[0] = ' '
				Message[Length] = ' '
				Length += 2
			}
			
			remove_quotes(Message[Length])
			if(id != Target) {
				ColorChat(id, GREEN, "(%s)^x03 %s^x04 :^x01 %s", Nick, TargetName, Message[Length])
				ColorChat(Target, GREEN, "(%s)^x03 %s^x04 :^x01 %s", Nick, TargetName, Message[Length])
			}
		}
	}
	return PLUGIN_CONTINUE
}

public Say(id) {
	new Float:MaxChat = 0.5
	
	if (MaxChat && !(get_user_flags(id) & ADMIN_IMMUNITY)) {
		new Float:Time = get_gametime()
		
		if (Flooding[id] > Time) {
			if (Flood[id] >= 3) {
				client_print(id, print_notify, "** Stop flooding the server! **")
				Flooding[id] = Time + MaxChat + 3.0
				return PLUGIN_HANDLED
			}
			Flood[id]++
		}
		else if (Flood[id])
			Flood[id]--
		
		Flooding[id] = Time + MaxChat
	}
	
	new Nick[32];
	get_user_name(id, Nick, sizeof(Nick) - 1);
	
	new Message[192];
	read_args(Message, sizeof(Message) - 1);
	remove_quotes(Message);
	
	if(equali(Message,"") || is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	new Said[6], i = 0
	read_argv(1, Said, 5)
	
	while(Said[i] == '@')	i++
	
	if (i && i <= 3 && access(id, ADMIN_CHAT)) {	
		new Color = 0			
		switch(Said[i]) {
			case 'r': 
				Color = 1
			case 'g': 
				Color = 2
			case 'b': 
				Color = 3
			case 'y': 
				Color = 4
			case 'm': 
				Color = 5
			case 'c': 
				Color = 6
			case 'o': 
				Color = 7
			
		}
		new n, s = i
		if (Color) {
			n++
			s++
		}
		while (Said[s] && isspace(Said[s])) {
			n++
			s++
		}
		
		if (++MessageChannel > 6 || MessageChannel < 3)
			MessageChannel = 3
		
		new Float:VerticalPosition = Position[i-1][1] + float(MessageChannel) / 35.0
		
		new HMessage[128];
		formatex(HMessage,sizeof(HMessage)-1,"%s : %s", Nick, Message[i+n])
		
		HudMessage(0, HMessage, Values[Color][0], Values[Color][1], Values[Color][2], Position[i-1][0], VerticalPosition, 0, 12.0, 6.0, 0.1, 1.5)
		client_print(0, print_notify, "%s : %s", Nick, Message[i+n])
		return PLUGIN_HANDLED;
	}
	
	else if(is_user_admin(id)) {
		for(new i = 0; i < sizeof Rang; i++) {
			if(get_user_flags(id) == read_flags(Rang[i][1])) {
				switch(get_user_team(id)) {
					case 1: 
						ColorChat(0, RED, "%s%s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Rang[i][0], Message);
					case 2:
						ColorChat(0, BLUE, "%s%s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Rang[i][0], Message);
					case 3:
						ColorChat(0, GREY, "%s^x04 (%s) :^x01 %s",Nick, Rang[i][0], Message);
				}
				return PLUGIN_HANDLED;
			}
		}
		
		switch(get_user_team(id)) {
			case 1: 
				ColorChat(0, RED, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 2:
				ColorChat(0, BLUE, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 3:
				ColorChat(0, GREY, "%s^x04 :^x01 %s",Nick, Message);
		}
		return PLUGIN_HANDLED;
	}
	else {
		switch(get_user_team(id)) {
			case 1: 
				ColorChat(0, RED, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 2:
				ColorChat(0, BLUE, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 3:
				ColorChat(0, GREY, "%s^x04 :^x01 %s",Nick, Message);
		}
		return PLUGIN_HANDLED;
		
	}
	return PLUGIN_CONTINUE;
}

public SayTeam(id) {
	new Float:MaxChat = 0.5
	
	if (MaxChat && !(get_user_flags(id) & ADMIN_IMMUNITY)) {
		new Float:Time = get_gametime()
		
		if (Flooding[id] > Time) {
			if (Flood[id] >= 3) {
				client_print(id, print_notify, "** Stop flooding the server! **")
				Flooding[id] = Time + MaxChat + 3.0
				return PLUGIN_HANDLED
			}
			Flood[id]++
		}
		else if (Flood[id])
			Flood[id]--
		
		Flooding[id] = Time + MaxChat
	}
	
	new Nick[32];
	get_user_name(id, Nick, sizeof(Nick) - 1);
	
	static Message[192];
	read_args(Message, sizeof(Message) - 1);
	remove_quotes(Message);
	
	if(equali(Message,"") || is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	new Said[2]
	read_argv(1, Said, 1)
	
	if (Said[0] == '@') {
		if (is_user_admin(id))
			ColorChat(id, RED, "(ADMIN)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
		else
			ColorChat(id, RED, "(PLAYER)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
		
		new Players[32], Num;
		get_players(Players, Num, "c");
		
		for (new i = 0; i < Num; ++i) {
			if (Players[i] != id && get_user_flags(Players[i]) & ADMIN_CHAT) {
				if (is_user_admin(id))
					ColorChat(Players[i], RED, "(ADMIN)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
				else
					ColorChat(Players[i], RED, "(PLAYER)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
			}
		}
		return PLUGIN_HANDLED;
	}
	
	else if(is_user_admin(id)) {
		for(new i = 0; i < sizeof Rang; i++) {
			new Players[32],Num;
			get_players(Players, Num, "c");
			
			if(get_user_flags(id) == read_flags(Rang [i][1])) {
				for(new X = 0; X < Num; X++) {
					switch(get_user_team(id)) {
						case 1: {
							if(get_user_team(Players[X]) == 1)
								ColorChat(Players[X], RED, "%s(%s) %s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Rang[i][0], Message);
						}
						case 2: {
							if(get_user_team(Players[X]) == 2)
								ColorChat(Players[X], BLUE, "%s(%s) %s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Rang[i][0], Message);
						}
						case 3: {
							if(get_user_team(Players[X]) == 3)
								ColorChat(Players[X], GREY, "(Spectator) %s^x04 (%s) :^x01 %s",Nick, Rang[i][0], Message);
						}
					}
				}
				return PLUGIN_HANDLED;
			}
		}
		new Players[32],Num;
		get_players(Players, Num, "c");
		
		for(new X = 0; X < Num; X++) {
			switch(get_user_team(id)) {
				case 1: {
					if(get_user_team(Players[X]) == 1)
						ColorChat(Players[X], RED, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Message);
				}
				case 2: {
					if(get_user_team(Players[X]) == 2)
						ColorChat(Players[X], BLUE, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Message);
				}
				case 3: {
					if(get_user_team(Players[X]) == 3)
						ColorChat(Players[X], GREY, "(Spectator) %s^x04 :^x01 %s",Nick, Message);
				}
			}
		}
		return PLUGIN_HANDLED;
	}
	else {
		new Players[32],Num;
		get_players(Players, Num, "c");
		
		for(new X = 0; X < Num; X++) {
			switch(get_user_team(id)) {
				case 1: {
					if(get_user_team(Players[X]) == 1)
						ColorChat(Players[X], RED, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Message);
				}
				case 2: {
					if(get_user_team(Players[X]) == 2)
						ColorChat(Players[X], BLUE, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Message);
				}
				case 3: {
					if(get_user_team(Players[X]) == 3)
						ColorChat(Players[X], GREY, "(Spectator) %s^x04 :^x01 %s",Nick, Message);
				}
			}
		}
		return PLUGIN_HANDLED;
	}
	return PLUGIN_CONTINUE;
}

public HAM_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) {
	if(is_user_connected(attacker) && is_user_connected(victim) && attacker != victim)  {
		if(is_user_alive(attacker) && get_user_team(victim) != get_user_team(attacker)) {
			new Pos = ++PlayerPos[attacker]
			if(Pos >= sizeof(BDPosition))
				Pos = PlayerPos[attacker] = 0
			
			new Damage[16];
			formatex(Damage,sizeof(Damage)-1,"%d", floatround(damage));
			
			HudMessage(attacker, Damage, 50, 205, 50, Float:BDPosition[Pos][0], Float:BDPosition[Pos][1], 2, 1.0, 2.5, 0.02, 0.02)
		}
	}
}


#define clamp_byte(%1)       ( clamp( %1, 0, 255 ) )
#define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) )
				
stock HudMessage(const id, const message[], red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 6.0, Float:holdtime = 3.0, Float:fadeintime = 0.1, Float:fadeouttime = 1.5) {
	new count = 1, players[32];
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players[i])) {	
				new color = pack_color(clamp_byte(red), clamp_byte(green), clamp_byte(blue))
				
				message_begin(MSG_ONE_UNRELIABLE, SVC_DIRECTOR, _, players[i]);
				write_byte(strlen(message) + 31);
				write_byte(DRC_CMD_MESSAGE);
				write_byte(effects);
				write_long(color);
				write_long(_:x);
				write_long(_:y);	
				write_long(_:fadeintime);
				write_long(_:fadeouttime);
				write_long(_:holdtime);
				write_long(_:fxtime);
				write_string(message);
				message_end();
			}
		}
	}
}

new TeamName[][] =  {
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
};

stock ColorChat(id, COLOR:type, const msg[],...) {
	new Message[252];
	switch(type) {
		case NORMAL:
			Message[0] = 0x01;
		case GREEN:
			Message[0] = 0x04;
		default:
		Message[0] = 0x03;
	}
	
	vformat(Message[1], 251, msg, 4);
	Message[192] = '^0';
	new Team, ColorChange, index, MSG_Type;
	
	if(id) {
		MSG_Type = MSG_ONE;
		index = id;
	}
	else {
		index = FindPlayer();
		MSG_Type = MSG_ALL;
	}
	
	Team = get_user_team(index);
	ColorChange = ColorSelection(index, MSG_Type, type);
	
	ShowColorMessage(index, MSG_Type, Message);
	
	if(ColorChange) 
		Team_Info(index, MSG_Type, TeamName[Team]);
}

stock ShowColorMessage(id, type, message[]) {
	static bool:saytext_used;
	static get_user_msgid_saytext;
	
	if(!saytext_used) {
		get_user_msgid_saytext = get_user_msgid("SayText");
		saytext_used = true;
	}
	message_begin(type, get_user_msgid_saytext, _, id);
	write_byte(id);
	write_string(message);
	message_end();   
}

stock Team_Info(id, type, team[]) {
	static bool:teaminfo_used;
	static get_user_msgid_teaminfo;
	
	if(!teaminfo_used) {
		get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
		teaminfo_used = true;
	}
	message_begin(type, get_user_msgid_teaminfo, _, id);
	write_byte(id);
	write_string(team);
	message_end();
	
	return 1;
}

stock ColorSelection(index, type, COLOR:Type) {
	switch(Type) {
		case RED:
			return Team_Info(index, type, TeamName[1]);
		case BLUE:
			return Team_Info(index, type, TeamName[2]);
		case GREY:
			return Team_Info(index, type, TeamName[0]);
	}
	return 0;
}

stock FindPlayer() {
	new i = -1;
	
	while(i <= get_maxplayers()) {
		if(is_user_connected(++i))
			return i;
	}
	
	return -1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/

Re: Eroare compilare plugin chat

Posted: 10 Aug 2019, 19:01
by Pegasus6ix
L E V I N wrote:
10 Aug 2019, 15:02

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Chat/Hud"
#define VERSION "4.0"
#define AUTHOR "Aragon*"

#define TEAM_CT_NAME	"Anti Furien"
#define TEAM_T_NAME	"Furien"

new Rang[][][] = {
	{"Fondator",	"abcdefghijklmnopqrstu"},
	{"Owner",	"abcdegfhijmnopqrs"},
	{"Co-Owner",	"bcdefijmnopqrs"},
	{"GOD",		"bcdefijmnopqr"},
	{"Administrator",	"bcdefijmnopq"},
	{"Helper",	"bcehi"},
	{"Slot",	"b"},
	{"V.I.P",	"bct"}
}

enum COLOR {
	NORMAL = 1,
	GREEN, 
	TEAM_COLOR, 
	GREY, 
	RED, 
	BLUE,
};

new Values[][] = {
	{255, 255, 255},
	{255, 0, 0},
	{0, 255, 0},
	{0, 0, 255}, 
	{255, 255, 0}, 
	{255, 0, 255}, 
	{0, 255, 255}, 
	{227, 96, 8}, 
	{45, 89, 116}, 
	{103, 44, 38}
}

new Float:Position[][] = {
	{0.05, 0.55}, 
	{-1.0, 0.2}, 
	{-1.0, 0.7}
}

new Float:BDPosition[][] = {
	{0.50, 0.40},
	{0.56, 0.44},
	{0.60, 0.50},
	{0.56, 0.56},
	{0.50, 0.60},
	{0.44, 0.56},
	{0.40, 0.50},
	{0.44, 0.44}
}

new Float:Flooding[33] = {0.0, ...}
new Flood[33] = {0, ...}
new MessageChannel, PlayerPos[33]

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_concmd("amx_say", "CmdSay", ADMIN_CHAT, "<message> - sends message to all players")
	register_concmd("amx_psay", "CmdPrivateSay", ADMIN_CHAT, "<name or #userid> <message> - sends private message")
	
	register_clcmd("say","Say");
	register_clcmd("say_team","SayTeam");
	register_clcmd("svip", "ServerIP");
	
	RegisterHam(Ham_TakeDamage,"player","HAM_TakeDamage");
}

public ServerIP(id) {
	new ServerIp[20];
	get_user_ip(0, ServerIp, charsmax(ServerIp)); 
	client_print(id, print_chat, "%s", ServerIp);
}
	
public CmdSay(id, level, cid) {
	if (cmd_access(id, level, cid, 2)) {
		new Message[192], Nick[32];
		read_args(Message, sizeof(Message) - 1);
		remove_quotes(Message);
		get_user_name(id, Nick, sizeof(Nick) - 1);
		
		ColorChat(0, GREEN, "(ALL)^x03 %s :^x01 %s", Nick, Message);
	}
}

public CmdPrivateSay(id, level, cid) {
	if (cmd_access(id, level, cid, 3)) {
		new Nick[32]
		read_argv(1, Nick, 31)
		new Target = cmd_target(id, Nick, 0)
		
		if (Target) {
			new Length = strlen(Nick) + 1
			
			new Message[192], TargetName[32]
			get_user_name(id, Nick, 31)
			get_user_name(Target, TargetName, 31); 
			read_args(Message, 191)
			
			if(Message[0] == '"' && Message[Length] == '"') {
				Message[0] = ' '
				Message[Length] = ' '
				Length += 2
			}
			
			remove_quotes(Message[Length])
			if(id != Target) {
				ColorChat(id, GREEN, "(%s)^x03 %s^x04 :^x01 %s", Nick, TargetName, Message[Length])
				ColorChat(Target, GREEN, "(%s)^x03 %s^x04 :^x01 %s", Nick, TargetName, Message[Length])
			}
		}
	}
	return PLUGIN_CONTINUE
}

public Say(id) {
	new Float:MaxChat = 0.5
	
	if (MaxChat && !(get_user_flags(id) & ADMIN_IMMUNITY)) {
		new Float:Time = get_gametime()
		
		if (Flooding[id] > Time) {
			if (Flood[id] >= 3) {
				client_print(id, print_notify, "** Stop flooding the server! **")
				Flooding[id] = Time + MaxChat + 3.0
				return PLUGIN_HANDLED
			}
			Flood[id]++
		}
		else if (Flood[id])
			Flood[id]--
		
		Flooding[id] = Time + MaxChat
	}
	
	new Nick[32];
	get_user_name(id, Nick, sizeof(Nick) - 1);
	
	new Message[192];
	read_args(Message, sizeof(Message) - 1);
	remove_quotes(Message);
	
	if(equali(Message,"") || is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	new Said[6], i = 0
	read_argv(1, Said, 5)
	
	while(Said[i] == '@')	i++
	
	if (i && i <= 3 && access(id, ADMIN_CHAT)) {	
		new Color = 0			
		switch(Said[i]) {
			case 'r': 
				Color = 1
			case 'g': 
				Color = 2
			case 'b': 
				Color = 3
			case 'y': 
				Color = 4
			case 'm': 
				Color = 5
			case 'c': 
				Color = 6
			case 'o': 
				Color = 7
			
		}
		new n, s = i
		if (Color) {
			n++
			s++
		}
		while (Said[s] && isspace(Said[s])) {
			n++
			s++
		}
		
		if (++MessageChannel > 6 || MessageChannel < 3)
			MessageChannel = 3
		
		new Float:VerticalPosition = Position[i-1][1] + float(MessageChannel) / 35.0
		
		new HMessage[128];
		formatex(HMessage,sizeof(HMessage)-1,"%s : %s", Nick, Message[i+n])
		
		HudMessage(0, HMessage, Values[Color][0], Values[Color][1], Values[Color][2], Position[i-1][0], VerticalPosition, 0, 12.0, 6.0, 0.1, 1.5)
		client_print(0, print_notify, "%s : %s", Nick, Message[i+n])
		return PLUGIN_HANDLED;
	}
	
	else if(is_user_admin(id)) {
		for(new i = 0; i < sizeof Rang; i++) {
			if(get_user_flags(id) == read_flags(Rang[i][1])) {
				switch(get_user_team(id)) {
					case 1: 
						ColorChat(0, RED, "%s%s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Rang[i][0], Message);
					case 2:
						ColorChat(0, BLUE, "%s%s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Rang[i][0], Message);
					case 3:
						ColorChat(0, GREY, "%s^x04 (%s) :^x01 %s",Nick, Rang[i][0], Message);
				}
				return PLUGIN_HANDLED;
			}
		}
		
		switch(get_user_team(id)) {
			case 1: 
				ColorChat(0, RED, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 2:
				ColorChat(0, BLUE, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 3:
				ColorChat(0, GREY, "%s^x04 :^x01 %s",Nick, Message);
		}
		return PLUGIN_HANDLED;
	}
	else {
		switch(get_user_team(id)) {
			case 1: 
				ColorChat(0, RED, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 2:
				ColorChat(0, BLUE, "%s%s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", Nick, Message);
			case 3:
				ColorChat(0, GREY, "%s^x04 :^x01 %s",Nick, Message);
		}
		return PLUGIN_HANDLED;
		
	}
	return PLUGIN_CONTINUE;
}

public SayTeam(id) {
	new Float:MaxChat = 0.5
	
	if (MaxChat && !(get_user_flags(id) & ADMIN_IMMUNITY)) {
		new Float:Time = get_gametime()
		
		if (Flooding[id] > Time) {
			if (Flood[id] >= 3) {
				client_print(id, print_notify, "** Stop flooding the server! **")
				Flooding[id] = Time + MaxChat + 3.0
				return PLUGIN_HANDLED
			}
			Flood[id]++
		}
		else if (Flood[id])
			Flood[id]--
		
		Flooding[id] = Time + MaxChat
	}
	
	new Nick[32];
	get_user_name(id, Nick, sizeof(Nick) - 1);
	
	static Message[192];
	read_args(Message, sizeof(Message) - 1);
	remove_quotes(Message);
	
	if(equali(Message,"") || is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	new Said[2]
	read_argv(1, Said, 1)
	
	if (Said[0] == '@') {
		if (is_user_admin(id))
			ColorChat(id, RED, "(ADMIN)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
		else
			ColorChat(id, RED, "(PLAYER)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
		
		new Players[32], Num;
		get_players(Players, Num, "c");
		
		for (new i = 0; i < Num; ++i) {
			if (Players[i] != id && get_user_flags(Players[i]) & ADMIN_CHAT) {
				if (is_user_admin(id))
					ColorChat(Players[i], RED, "(ADMIN)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
				else
					ColorChat(Players[i], RED, "(PLAYER)^x04 %s^x03 :^x01 %s", Nick, Message[1]);
			}
		}
		return PLUGIN_HANDLED;
	}
	
	else if(is_user_admin(id)) {
		for(new i = 0; i < sizeof Rang; i++) {
			new Players[32],Num;
			get_players(Players, Num, "c");
			
			if(get_user_flags(id) == read_flags(Rang [i][1])) {
				for(new X = 0; X < Num; X++) {
					switch(get_user_team(id)) {
						case 1: {
							if(get_user_team(Players[X]) == 1)
								ColorChat(Players[X], RED, "%s(%s) %s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Rang[i][0], Message);
						}
						case 2: {
							if(get_user_team(Players[X]) == 2)
								ColorChat(Players[X], BLUE, "%s(%s) %s^x04 (%s) :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Rang[i][0], Message);
						}
						case 3: {
							if(get_user_team(Players[X]) == 3)
								ColorChat(Players[X], GREY, "(Spectator) %s^x04 (%s) :^x01 %s",Nick, Rang[i][0], Message);
						}
					}
				}
				return PLUGIN_HANDLED;
			}
		}
		new Players[32],Num;
		get_players(Players, Num, "c");
		
		for(new X = 0; X < Num; X++) {
			switch(get_user_team(id)) {
				case 1: {
					if(get_user_team(Players[X]) == 1)
						ColorChat(Players[X], RED, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Message);
				}
				case 2: {
					if(get_user_team(Players[X]) == 2)
						ColorChat(Players[X], BLUE, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Message);
				}
				case 3: {
					if(get_user_team(Players[X]) == 3)
						ColorChat(Players[X], GREY, "(Spectator) %s^x04 :^x01 %s",Nick, Message);
				}
			}
		}
		return PLUGIN_HANDLED;
	}
	else {
		new Players[32],Num;
		get_players(Players, Num, "c");
		
		for(new X = 0; X < Num; X++) {
			switch(get_user_team(id)) {
				case 1: {
					if(get_user_team(Players[X]) == 1)
						ColorChat(Players[X], RED, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_T_NAME, Nick, Message);
				}
				case 2: {
					if(get_user_team(Players[X]) == 2)
						ColorChat(Players[X], BLUE, "%s(%s) %s^x04 :^x01 %s", is_user_alive(id) ? "" : "*Mort* ", TEAM_CT_NAME, Nick, Message);
				}
				case 3: {
					if(get_user_team(Players[X]) == 3)
						ColorChat(Players[X], GREY, "(Spectator) %s^x04 :^x01 %s",Nick, Message);
				}
			}
		}
		return PLUGIN_HANDLED;
	}
	return PLUGIN_CONTINUE;
}

public HAM_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) {
	if(is_user_connected(attacker) && is_user_connected(victim) && attacker != victim)  {
		if(is_user_alive(attacker) && get_user_team(victim) != get_user_team(attacker)) {
			new Pos = ++PlayerPos[attacker]
			if(Pos >= sizeof(BDPosition))
				Pos = PlayerPos[attacker] = 0
			
			new Damage[16];
			formatex(Damage,sizeof(Damage)-1,"%d", floatround(damage));
			
			HudMessage(attacker, Damage, 50, 205, 50, Float:BDPosition[Pos][0], Float:BDPosition[Pos][1], 2, 1.0, 2.5, 0.02, 0.02)
		}
	}
}


#define clamp_byte(%1)       ( clamp( %1, 0, 255 ) )
#define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) )
				
stock HudMessage(const id, const message[], red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 6.0, Float:holdtime = 3.0, Float:fadeintime = 0.1, Float:fadeouttime = 1.5) {
	new count = 1, players[32];
	
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
		for(new i = 0; i < count; i++) {
			if(is_user_connected(players[i])) {	
				new color = pack_color(clamp_byte(red), clamp_byte(green), clamp_byte(blue))
				
				message_begin(MSG_ONE_UNRELIABLE, SVC_DIRECTOR, _, players[i]);
				write_byte(strlen(message) + 31);
				write_byte(DRC_CMD_MESSAGE);
				write_byte(effects);
				write_long(color);
				write_long(_:x);
				write_long(_:y);	
				write_long(_:fadeintime);
				write_long(_:fadeouttime);
				write_long(_:holdtime);
				write_long(_:fxtime);
				write_string(message);
				message_end();
			}
		}
	}
}

new TeamName[][] =  {
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
};

stock ColorChat(id, COLOR:type, const msg[],...) {
	new Message[252];
	switch(type) {
		case NORMAL:
			Message[0] = 0x01;
		case GREEN:
			Message[0] = 0x04;
		default:
		Message[0] = 0x03;
	}
	
	vformat(Message[1], 251, msg, 4);
	Message[192] = '^0';
	new Team, ColorChange, index, MSG_Type;
	
	if(id) {
		MSG_Type = MSG_ONE;
		index = id;
	}
	else {
		index = FindPlayer();
		MSG_Type = MSG_ALL;
	}
	
	Team = get_user_team(index);
	ColorChange = ColorSelection(index, MSG_Type, type);
	
	ShowColorMessage(index, MSG_Type, Message);
	
	if(ColorChange) 
		Team_Info(index, MSG_Type, TeamName[Team]);
}

stock ShowColorMessage(id, type, message[]) {
	static bool:saytext_used;
	static get_user_msgid_saytext;
	
	if(!saytext_used) {
		get_user_msgid_saytext = get_user_msgid("SayText");
		saytext_used = true;
	}
	message_begin(type, get_user_msgid_saytext, _, id);
	write_byte(id);
	write_string(message);
	message_end();   
}

stock Team_Info(id, type, team[]) {
	static bool:teaminfo_used;
	static get_user_msgid_teaminfo;
	
	if(!teaminfo_used) {
		get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
		teaminfo_used = true;
	}
	message_begin(type, get_user_msgid_teaminfo, _, id);
	write_byte(id);
	write_string(team);
	message_end();
	
	return 1;
}

stock ColorSelection(index, type, COLOR:Type) {
	switch(Type) {
		case RED:
			return Team_Info(index, type, TeamName[1]);
		case BLUE:
			return Team_Info(index, type, TeamName[2]);
		case GREY:
			return Team_Info(index, type, TeamName[0]);
	}
	return 0;
}

stock FindPlayer() {
	new i = -1;
	
	while(i <= get_maxplayers()) {
		if(is_user_connected(++i))
			return i;
	}
	
	return -1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Functioneaza, multumesc frumos, apreciez.

Re: Eroare compilare plugin chat [Rezolvat]

Posted: 14 Aug 2019, 12:35
by WHOAMI?
Marcat ca "Rezolvat"