Jump to content

The event is not canceled


Recommended Posts

Hello, why is the message sent by the player not canceled?
 

local chatRadius = 20 

function onPlayerChatSendMessageToNearbyPlayers(messageText, messageType)
	local normalMessage = (messageType == 0) 

	if (not normalMessage) then 
		return false 
	end

	local playerName = getPlayerName(source)
	local playerX, playerY, playerZ = getElementPosition(source) 
	local playerInterior = getElementInterior(source) 
	local playerDimension = getElementDimension(source)
	local nearbyPlayers = getElementsWithinRange(playerX, playerY, playerZ, chatRadius, "player", playerInterior, playerDimension) -- get nearby players within given radius
	local messageToOutput = playerName..": "..messageText

	outputChatBox(messageToOutput, nearbyPlayers, 255, 255, 255, true) 
	cancelEvent()
end
addEventHandler("onPlayerChat", root, onPlayerChatSendMessageToNearbyPlayers)

 

Link to comment
  • Moderators
12 hours ago, tzn said:

Hello, why is the message sent by the player not canceled?

Most likely because of another resource.

 

Use the AddDebugHook function on outputChatBox, to figure out which one. (this function shows you where a MTA function is called or event is triggered)

Link to comment
On 02/07/2024 at 02:29, IIYAMA said:

Скорее всего из-за другого ресурса.

 

Используйте функцию AddDebugHook на outputChatBox, чтобы выяснить, какой именно. (эта функция показывает, где вызывается функция MTA или запускается событие)

Thank you very much! It turns out that the problem was in the playercolors resource

  • Like 1
Link to comment

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...