View Single Post
eyal282
Veteran Member
Join Date: Aug 2011
Old 02-21-2018 , 05:48   Re: How to let everyone talk with each other.
Reply With Quote #7

Quote:
Originally Posted by nikita2150 View Post
Okay, I see no one understood me, I'll ask another question.
How to let a *DEAD* admin talk in the cheat with live and dead players.
Thank you in advance.
I made an API plugin called ”Chat Revamp”. It’s yet to be able to allow chats that shouldn’t be sent to be sent but I’ll fix it today and post you another plugin that allows dead chat.

Tell me if this works after you adjust the cvars.


Code:
#include <sourcemod>
#include <sdktools>

public Plugin:myinfo = 
{
	name = "Chat Revamp ( Chat Processor )",
	author = "Eyal282 ( FuckTheSchool )",
	description = "Allows plugins to intercept chat communications between players and edit them",
	version = "1.3",
	url = "<- URL ->"
}

new Handle:fw_ChatSent = INVALID_HANDLE;
new Handle:fw_ChatSent_Post = INVALID_HANDLE;

new Handle:cvHideNameChange = INVALID_HANDLE;
new Handle:cvDeadChat = INVALID_HANDLE;


public Action:CR_OnChatSent(&Receiver, &Sender, &bChat, String:Tag[], String:Name[], String:Message[], &WillSend)
{
	if(WillSend)
	{
		if(GetConVarBool(cvHideNameChange))
		{	
			if(StrContains(Tag, "Name", false) != -1 && CheckCommandAccess(Sender, "sm_kick", ADMFLAG_KICK))
			{
				if(!CheckCommandAccess(Receiver, "sm_kick", ADMFLAG_KICK))
					return Plugin_Handled;
			}
		}
	}
	else
	{
		if(GetConVarBool(cvDeadChat))
		{
			if(StrContains(Tag, "Dead", false) != -1)
			{
				if(StrContains(Tag, "All") != -1 || GetClientTeam(Sender) == GetClientTeam(Receiver))
					WillSend = true;
			}
		}
	}
	return Plugin_Continue;
}

public Action:CR_OnChatSent_Post(Receiver, Sender, bChat, String:Tag[], String:Name[], String:Message[])
{
	if(!GetConVarBool(cvHideNameChange))
		return Plugin_Continue;
		
	else if(StrContains(Tag, "Name", false) != -1 && CheckCommandAccess(Sender, "sm_kick", ADMFLAG_KICK))
		PrintToChat(Sender, "Your name change is only shown to admins!");
	
	return Plugin_Continue;
}
public OnPluginStart()
{	
	HookUserMessage(GetUserMessageId("SayText2"), Message_SayText2, true);
	
	// public Action:CR_OnChatSent(&Sender, &bChat, String:Tag[], String:Name[], String:Message[], &Something, &OtherSomething, players[], &playersNum)
	
	// @param Receiver			The client receiving the message.
	// @param Sender			The client sending the message.
	// @param bChat				Unsure, I think whether or not the message is printed in console not only in chat.
	// @param String:Tag[]		Message display tags ( Changing will not affect who will see it, but it acts as a format of message, Example: #L4D_Chat_All, #L4D_Chat_Infected )
	// @param String:Name[]		Name of the sender.
	// @param String:Message[]	The message the client sends.
	// @param WillSend			Will the message actually be sent without changing this to true? Change to true if you want to force the message to be sent even if it shouldn't.

	// @Return					Even to allow chat to send, Odd to disallow chat to send. Plugin_Stop will act as Plugin_Continue due to that.
	
	// @Note					Tag in L4D2 and probably all games will contain "Name" when the chat message is a name change.

	// @Note					All parameters are copied back to the forward.
	fw_ChatSent = CreateGlobalForward("CR_OnChatSent", ET_Event, Param_CellByRef, Param_CellByRef, Param_String, Param_String, Param_String, Param_CellByRef, Param_CellByRef, Param_Array, Param_CellByRef, Param_CellByRef);
	
	// public Action:CR_OnChatSent_Post(Receiver, Sender, bChat, String:Tag[], String:Name[], String:Message[])
	
	// @Note: The parameters on post and pre are identical.
	// @Note: Tag in L4D2 and probably all games will contain "Name" when the chat message is a name change.
	fw_ChatSent_Post = CreateGlobalForward("CR_OnChatSent_Post", ET_Ignore, Param_Cell, Param_Cell, Param_String, Param_String, Param_String, Param_Cell, Param_Cell, Param_Array, Param_Cell);
	
	
	cvHideNameChange = CreateConVar("cr_hide_admin_name_change", "1", "If set to 1, only admins can see name changes");
	cvDeadChat = CreateConVar("cr_dead_chat", "0", "If set to 1, dead players can chat.");
}

public Action:Message_SayText2(UserMsg msg_id, Handle:Bf, const int[] players, int playersNum, bool reliable, bool init)
{
	new Sender = BfReadByte(Bf);
	
	if(Sender <= 0 || Sender > MaxClients)
		return Plugin_Continue;
		
	new bChat = BfReadByte(Bf);
	
	new String:Tag[50];
	BfReadString(Bf, Tag, sizeof(Tag));
	
	new String:Name[64];
	BfReadString(Bf, Name, sizeof(Name));
	
	new String:Message[300];
	BfReadString(Bf, Message, sizeof(Message));

	new Handle:DP = CreateDataPack();
		
	RequestFrame(SendMessage, DP);
	
	WritePackCell(DP, Sender);
	WritePackCell(DP, bChat);
	WritePackString(DP, Tag);
	WritePackString(DP, Name);
	WritePackString(DP, Message);
	
	WritePackCell(DP, playersNum);
	
	for(new i=0;i < playersNum;i++)
		WritePackCell(DP, players[i]);
		
	return Plugin_Handled;
}

public SendMessage(Handle:DP)
{
	ResetPack(DP);
	new Sender = ReadPackCell(DP);
	new bChat = ReadPackCell(DP);
	new String:Tag[50];
	ReadPackString(DP, Tag, sizeof(Tag));
	new String:Name[64];
	ReadPackString(DP, Name, sizeof(Name));
	new String:Message[300];
	ReadPackString(DP, Message, sizeof(Message));
	new players[MAXPLAYERS];
	new playersNum = ReadPackCell(DP);

	for(new i=0;i < playersNum;i++)
	{
		players[i] = ReadPackCell(DP);
	}
	
	CloseHandle(DP);

	new ReturnValue;
	
	for(new id=1;id <= MaxClients;id++)
	{
		if(!IsClientInGame(id))
			continue;
			
		else if(IsFakeClient(id))
			continue;
			
		new bool:WillSend;
		for(new i=0;i < playersNum;i++)
		{
			if(players[i] == id)
			{
				WillSend = true;
			}
		}
		Call_StartForward(fw_ChatSent);
		
		Call_PushCellRef(id);
		Call_PushCellRef(Sender);
		Call_PushCellRef(bChat);
		Call_PushStringEx(Tag, sizeof(Tag), SM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
		Call_PushStringEx(Name, sizeof(Name), SM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);	
		Call_PushStringEx(Message, sizeof(Message), SM_PARAM_STRING_UTF8|SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);	
		Call_PushCellRef(WillSend);
			
		Call_Finish(ReturnValue);
			
		if((ReturnValue & 1) == 1 || !WillSend)
				return;
				
		static UserMsg:SayText;
		if(!SayText)
			SayText = GetUserMessageId("SayText2");
		
		new Handle:Bf = StartMessageOne("SayText2", id, USERMSG_BLOCKHOOKS);
		BfWriteByte(Bf, Sender);
		BfWriteByte(Bf, bChat);
		BfWriteString(Bf, Tag);
		BfWriteString(Bf, Name);
		BfWriteString(Bf, Message); 
		EndMessage()
	
		Call_StartForward(fw_ChatSent_Post);
		
		Call_PushCell(id);
		Call_PushCell(Sender);
		Call_PushCell(bChat);
		Call_PushString(Tag);
		Call_PushString(Name);	
		Call_PushString(Message);	
		
		Call_Finish(ReturnValue);
	}
}
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 02-21-2018 at 11:57.
eyal282 is offline