Problema rang_admin_chat, mesaje duble in chat

Discutii legate de instalarea, configurarea si modificarea unui server de Counter-Strike.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
Achilles1
Membru, skill 0
Membru, skill 0
Posts: 14
Joined: 26 Mar 2021, 01:19
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 4 times
Been thanked: 1 time

04 Apr 2021, 00:02

Salut, am sa vin cu mai multe detalii legata de problema pe care o am...
Problema 1: Atunci cand sunt spectator apar mesajele dublu in chat.
Exemplu: [Fondator][Nivel 15] Achilles: sss
*SPEC* Achilles: sss

Problema 2: Dupa infectare, cand scriu ceva in chat ma arata ca spectator, eu fiind zombie sau om.

Uitati aici sma:

Code: Select all

#include <amxmodx>
#include <amxmisc> 
#include <zplvl>

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

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

// start cstrike.inc
enum CsTeams {
	CS_TEAM_UNASSIGNED = 0,
	CS_TEAM_T = 1,
	CS_TEAM_CT = 2,
	CS_TEAM_SPECTATOR = 3
};

native CsTeams:cs_get_user_team(index);
// end cstrike.inc

// edit here
#define MAX_WORDS 192 

new g_swearsNames[MAX_WORDS][32] 
new g_swearsNum 
#define MAX_GROUPS 5
#define MAX_CHARS 48
new g_Rang[MAX_GROUPS][] = {
"Fondator",
"God",
"Moderator",
"Admin",
"Helper"
};

new g_RangFlag[MAX_GROUPS][] = {
"abcdefghijklmnopqrstu",
"abcdefghijklmnopqrsu",
"bcdefijmnopqrs",
"bcdefijmnopq",
"bcefijmno"
};

// end edit here

new g_RangFlag_Value[MAX_GROUPS];
new cvar_type, gType[2][50];
//new chat[180];
public plugin_init() {
	register_plugin("RangAdminChat", "1.2", "Achilles");
	
	register_clcmd("say","hook_say");
	register_clcmd("say_team","hook_say");
	readList()
	for(new i = 0; i < MAX_GROUPS; i++)
		g_RangFlag_Value[i] = read_flags(g_Rang[i]);
	
	cvar_type = register_cvar("amx_rang_chat","3");
	
	switch(get_pcvar_num(cvar_type)) {
		case 1 : {
			gType[0] = "^x04*%s*[Nivel %i]^x03%s^x01 : ^x04%s";
			gType[1] = "^x04*%s*[Nivel %i]^x01(%s)^x03 %s^x01 : ^x04%s";
		}
		case 2 : {
			gType[0] = "^x04(%s)[Nivel %i]^x03%s^x01 : ^x04%s";
			gType[1] = "^x04(%s)[Nivel %i]^x01(%s)^x03 %s^x01 : ^x04%s";
		}
		case 3 : {
			gType[0] = "^x03[%s][Nivel %i]^x03 %s^x01 : ^x01%s";
			gType[1] = "^x03[%s][Nivel %i]^x01(%s)^x03 %s^x01 : ^x01%s";
		}
	}
}

readList() 
{ 
    // file to read words from 
	new szCustomDir[64]
	new filename[64]
	get_configsdir( szCustomDir, 63 )
	format(filename, 63, "%s/swear/swearwords.ini", szCustomDir )

	if(!file_exists(filename) ){
		log_message("Swear Filter: file %s not found", filename) 
		return 
	} 
	new iLen 
	while( g_swearsNum < MAX_WORDS && read_file(filename, g_swearsNum ,g_swearsNames[g_swearsNum][1],30,iLen) ) 
	{ 
	if( g_swearsNames[g_swearsNum][0] == ';') continue
	g_swearsNames[g_swearsNum][0] = iLen 
	++g_swearsNum 
	}
	log_message("Swear Filter: loaded %d words",g_swearsNum ) 
} 


public hook_say(id) {
	if(is_user_bot(id))
		return PLUGIN_CONTINUE;
	
	static chat[180]
	read_args(chat, sizeof(chat) - 1);
	remove_quotes(chat);
	
	if(equali(chat,""))
		return PLUGIN_CONTINUE;
	
	if (contain(chat, "%") != -1)
	{
		replace_all(chat, charsmax(chat), "%", " ")
		return PLUGIN_HANDLED
	}
	new pos, i = 0
	while ( i < g_swearsNum )
	{
		if ( (pos = containi(chat,g_swearsNames[i][1])) != -1 ){ 
			new len = g_swearsNames[i][0] 
			while(len--)
			chat[pos++] = '*'
			continue
		}
		++i
	}
	if(is_user_admin(id)) {
		new bool:hasRang = false;
		for(new i = 0; i < MAX_GROUPS; i++) {
			if(get_user_flags(id) == read_flags(g_RangFlag[i]))  {
				switch(cs_get_user_team(id)) {
					case CS_TEAM_T : ColorChat(0, RED, gType[0],  g_Rang[i], zp_get_level(id), get_name(id), chat);
					case CS_TEAM_CT : ColorChat(0, BLUE, gType[0], g_Rang[i], zp_get_level(id), get_name(id), chat);
					case CS_TEAM_SPECTATOR : ColorChat(0, GREY, gType[0], g_Rang[i], zp_get_level(id), get_name(id), chat);
				}
				log_amx("[CHAT] %s : %s", get_name(id), chat)
				hasRang = true;
			}
		}
		if(!hasRang)
			get_team(id, chat);
	}
	else 
		get_team(id, chat);
	
	return PLUGIN_HANDLED;
}

stock get_team(id, chat[]) {
	switch(cs_get_user_team(id)) {
		case CS_TEAM_T : ColorChat(0, RED, "%s%s [Nivel %i]^x01 : %s", is_user_alive(id) ? "" : "*MORT*", get_name(id), zp_get_level(id), chat);
		case CS_TEAM_CT : ColorChat(0, BLUE, "%s%s [Nivel %i]^x01 : %s", is_user_alive(id) ? "" : "*MORT*", get_name(id), zp_get_level(id), chat);
		case CS_TEAM_SPECTATOR : ColorChat(0, GREY, "*SPEC*%s [Nivel %i]^x01 : %s", get_name(id), zp_get_level(id), chat);
	}
	log_amx("[CHAT] %s : %s", get_name(id), chat)
}


ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...) {
	new message[256];

	switch(type) {
		case NORMAL: // clients scr_concolor cvar color
		{
			message[0] = 0x01;
		}
		case GREEN: // Green
		{
			message[0] = 0x04;
		}
		default: // White, Red, Blue
		{
			message[0] = 0x03;
		}
	}

	vformat(message[1], 251, msg, 4);
	// Make sure message is not longer than 192 character. Will crash the server.
	message[180] = '^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]);
	}
}

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();	
}

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;
}

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;
}

FindPlayer() {
	new i = -1;

	while(i <= get_maxplayers()) {
		if(is_user_connected(++i))
			return i;
	}

	return -1;
}

stock get_name (id) {
	new name[32];
	get_user_name(id, name, 31);
	return name;
}



Erorile care apar in logs:

Code: Select all

L 04/04/2021 - 00:03:28: Start of error session.
L 04/04/2021 - 00:03:28: Info (map "zm_cross") (file "addons/amxmodx/logs/error_20210404.log")
L 04/04/2021 - 00:03:28: [AMXX] Displaying debug trace (plugin "rang_admin_chat.amxx")
L 04/04/2021 - 00:03:28: [AMXX] Run time error 4: index out of bounds 
L 04/04/2021 - 00:03:28: [AMXX]    [0] rang_admin_chat1.sma::ColorChat (line 199)
L 04/04/2021 - 00:03:28: [AMXX]    [1] rang_admin_chat1.sma::get_name (line 266)
L 04/04/2021 - 00:03:28: [AMXX]    [2] rang_admin_chat1.sma::hook_say (line 136)
RoyalServer 2
User avatar
kidd0x
Utilizator neserios (tepar)
Utilizator neserios (tepar)
Posts: 1054
Joined: 06 Oct 2018, 14:41
Detinator Steam: Da
SteamID: /id/kidd0x/
Reputatie: Utilizator neserios (tepar!)
Fond eXtream: 0
Location: Constangeles
Discord: kidd0x
Has thanked: 172 times
Been thanked: 81 times

04 Apr 2021, 00:15

Foloseste chat manager a lui ocixcrom , e mul mai simplu si nu are probleme
Achilles1
Membru, skill 0
Membru, skill 0
Posts: 14
Joined: 26 Mar 2021, 01:19
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 4 times
Been thanked: 1 time

04 Apr 2021, 00:24

N3v3rM1nd wrote:
04 Apr 2021, 00:15
Foloseste chat manager a lui ocixcrom , e mul mai simplu si nu are probleme
Dar plugin-ul ala nu arata nivelul in chat, pe mine asta m-ar interesa.
User avatar
kidd0x
Utilizator neserios (tepar)
Utilizator neserios (tepar)
Posts: 1054
Joined: 06 Oct 2018, 14:41
Detinator Steam: Da
SteamID: /id/kidd0x/
Reputatie: Utilizator neserios (tepar!)
Fond eXtream: 0
Location: Constangeles
Discord: kidd0x
Has thanked: 172 times
Been thanked: 81 times

04 Apr 2021, 00:50

Achilles1 wrote:
04 Apr 2021, 00:24
N3v3rM1nd wrote:
04 Apr 2021, 00:15
Foloseste chat manager a lui ocixcrom , e mul mai simplu si nu are probleme
Dar plugin-ul ala nu arata nivelul in chat, pe mine asta m-ar interesa.
Atunci pune pluginul de rang_admin_chat primul in lista de plugine.
User avatar
levin
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3844
Joined: 24 Aug 2011, 12:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Discord: devilclass
Has thanked: 36 times
Been thanked: 594 times
Contact:

21 Apr 2021, 16:36

chat manager arată și level, doar că e făcut pentru sistemul de level al lui ocix
Pentru ajutor, faceți cerere bine detaliată, completând și respectând modelul corespunzător.
Nu-mi mai dați cereri doar pentru a mă avea în lista de prieteni.
Dacă te ajut, și mă ignori/etc > te adaug în „foe”.
Aveți grijă la cei ce încearcă să mă copieze sau să dea drept mine..Puteți lua legătura cu mine prin STEAM dacă aveți o problemă/nelămurire în acest caz! Cont de forum am doar aici.
În cazul în care utilizați ceva din ce am postat(ex: aici), e bine să fiți la curent cu modificările aduse și de aici, iar dacă sunt ceva probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se vor afișa public, doar dacă se găsește ceva critic/urgent de remediat, unele fiind coduri vechi iar unele refăcute chiar recent dar private.
* Nume pe cs1.6: eVoLuTiOn \ Nume vechi: eVo
* Atelierul meu - post2819572.html#p2819572 (închis, click link ca să vedeți de ce)
Post Reply

Return to “Probleme la servere dedicate de Counter-Strike”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 99 guests