Jump to content

[Help] onClientChatMessage


Fire Monkey

Recommended Posts

Hi guys, I make spy mode for admin.

I using onClientChatMessage function for get chat box from favorite player, but i want know is method are normal and optimized ?

Server side:

addCommandHandler("spy",
function (player, command, target)
	if target then
		local ppl = getPlayerFromName(target)
		if ppl then
			setElementData(ppl, "spy", thePlayer)
			outputChatBox("Enabled on: "..getPlayerName(ppl).."", player, 255, 255, 255)
		end
	else
		outputChatBox("USAGE: /"..command.." <Player-Name>", player, 255, 255, 255)
	end
end)

addEvent("spy:ShowChat", true)
addEventHandler("spy:ShowChat", root,
function (root, message)
	local spy = getElementData(root, "spy")
	if spy then
		outputChatBox("[SPY-Mode] "..getPlayerName(root)..": "..message, spy, 255, 255, 255)
	end
end)

Client side:

local lastMessage = nil

addEventHandler("onClientChatMessage", getRootElement(),
function (message)
	if not getElementData(getLocalPlayer(), "spy") then
		return false
	end
	if message == "" or message == " " then
		if lastMessage == message then
			return
		end
	end
	lastMessage = message
	triggerServerEvent("spy:ShowChat", getLocalPlayer(), getLocalPlayer(), message)
end)

And i want unlimited admin can active on player and see chat box.

Do you have idea?

Link to comment
On 24/09/2020 at 02:33, RekZ said:

All the chat system is Server side for what i known, why you dont get the chat in the server side ? Sending the client's information to the server is an inefficient in this case i think.

It is not possible to receive messages sent to the player from the server side.

On 24/09/2020 at 12:28, xPeacefulDreams said:

Could you explain what you exactly mean by Spy Mode and what you are trying to listen in to? I can imagine you're trying to read the private messages or something?

I guess the question is, what are you trying to monitor? When the player sends a message/chat, or when the player receives a message/chat from someone else?

 

 

I want to check when a chat box is sent to the player.

Link to comment
  • MTA Anti-Cheat Team

It's still not clear what you are trying to do, and I think it's due to the language barrier.

On your server gamemode, what types of chat output are only shown to the players themselves, and not globally? For example: PM, local chat, team chat, any interfaces that people can talk to others with?

I would advise to implement logging for each of them, and if it can't wait (in the case of OutputServerLog not being enough, your admins really need to have it at their immediate disposal) to make a window that records all of such communication and in which your admins can filter by player name to see all of it for a specific player.

Edited by Dutchman101
Link to comment
3 hours ago, Dutchman101 said:

It's still not clear what you are trying to do, and I think it's due to the language barrier.

On your server gamemode, what types of chat output are only shown to the players themselves, and not globally? For example: PM, local chat, team chat, any interfaces that people can talk to others with?

I would advise to implement logging for each of them, and if it can't wait (in the case of OutputServerLog not being enough, your admins really need to have it at their immediate disposal) to make a window that records all of such communication and in which your admins can filter by player name to see all of it for a specific player.

I always use outputChatBox and I have no custom function.

I want to see chat box sent to a specific player.

Link to comment
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...