Raised This Month: $ Target: $400
 0% 

[SOLVE]My code make say team message print to everyone.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GarbageBox
Senior Member
Join Date: Feb 2010
Old 07-29-2011 , 14:53   [SOLVE]My code make say team message print to everyone.
Reply With Quote #1

I want to re-write the say team and I'm using a stock version color chat.
But when I test it, I found out that it print the team say message to another team.
How can fix it?
Code:
new szName[32], szTag[24];
new iPlayers[32], iNum;
//...
public hook_say_team(id)
{
	new szMessages[192];
	read_args(szMessages, 191);
	remove_quotes(szMessages);	
	
	get_user_name(id, szName, 31);
	
	new szAlive = is_user_alive(id);
	
	if(szMessages[0] != '@')
	{
		new szTeam[33], szDead[33];
		if(get_user_team(id) == 1)
		{
			szTeam = "(TR)";
			szDead = "*DEAD*";
		}
		else if(get_user_team(id) == 2)
		{
			szTeam = "(CT)";
			szDead = "*DEAD*";
		}
		else if(get_user_team(id) == 3)
		{
			szTeam = "(SPEC)";
			szDead = "";
		}
		(szAlive ? client_printc(0, "^x04%s ^x03%s ^x01: %s", szTeam, szName, szMessages) : client_printc(0, "^x01%s ^x04%s ^x03%s ^x01: %s", szDead, szTeam, szName, szMessages));
	}
	else
	{
		if(get_user_flags(id) & ADMIN_ADMIN)
			szTag = "(ADMIN)"
		else
			szTag = "(PLAYER)"
			
		get_players(iPlayers , iNum , "ch");
		
		for(new i = 0; i < iNum; i++)
		{
			if(get_user_flags(iPlayers[i]) & ADMIN_CHAT)
			{
				client_printc(iPlayers[i], "^x04%s ^x03%s ^x01: %s", szTag, szName, szMessages[1]);
			}
			if(get_user_flags(iPlayers[i]) & ADMIN_USER)
			{
				client_printc(id, "^x04%s ^x03%s ^x01: %s", szTag, szName, szMessages[1]);
			}
		}
	}
}

stock client_printc(const id, const string[], {Float, Sql, Resul,_}:...)
{
	new msg[191], players[32], count = 1;
	vformat(msg, sizeof msg - 1, string, 3);
	
	replace_all(msg,190,"\g","^4");
	replace_all(msg,190,"\y","^1");
	replace_all(msg,190,"\t","^3");
	
	if(id)
		players[0] = id;
	else
		get_players(players,count,"ch");
	
	new index;
	for (new i = 0 ; i < count ; i++)
	{
		index = players[i];
		message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, index);
		write_byte(index);
		write_string(msg);
		message_end();  
	}  
}
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others

Last edited by GarbageBox; 07-30-2011 at 06:28.
GarbageBox is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-29-2011 , 16:12   Re: My code make say team message print to everyone.
Reply With Quote #2

Code:
		(szAlive ? client_printc(0, "^x04%s ^x03%s ^x01: %s", szTeam, szName, szMessages) : client_printc(0, "^x01%s ^x04%s ^x03%s ^x01: %s", szDead, szTeam, szName, szMessages));
That's why. You are using 0 for player index to print to, which is all players.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 07-30-2011 , 01:15   Re: My code make say team message print to everyone.
Reply With Quote #3

If I use id, it will print the message to myself only, other teammate can't see.
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-30-2011 , 02:16   Re: My code make say team message print to everyone.
Reply With Quote #4

You have to make a loop and determine whether you want to display the message to the player or not by checking his team. And if you want to show the message to him, put that line there. (the client_printc line with the id of the user you are checking).
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode