Skip to content

Implement messageType parameter to onClientChatMessage #1020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Aug 4, 2021

Conversation

Lpsd
Copy link
Member

@Lpsd Lpsd commented Jul 4, 2019

Resolves #1014

This PR adds the messageType parameter to the onClientChatMessage event. The possible types are as follows:

0 = player
1 = action
2 = team
3 = private
4 = internal

0, 1 and 2 follow the same structure as the onPlayerChat event.

private type is when using the /msg command
internal is for any messages sent internally by MTA (such as "login: You successfully logged in")

I have included a small test script below (clientside)

local messageTypes = {
	{id = 0, type = "player"},
	{id = 1, type = "action"},
	{id = 2, type = "team"},
	{id = 3, type = "private"},
	{id = 4, type = "internal"}
}

function getMessageTypeName(messageType)
	for i,v in ipairs(messageTypes) do
		if (tonumber(messageType) == v.id) then
			return v.type
		end
	end
	return false
end

function handleChatMessage(text, r, g, b, messageType)
	print(text, "messageType: "..messageType, getMessageTypeName(messageType))
end
addEventHandler("onClientChatMessage", root, handleChatMessage)

Also fixed a couple of typos already present in the code.

@Lpsd Lpsd changed the title Chat events Implement messageType parameter to onClientChatMessage Jul 4, 2019
@CrosRoad95
Copy link

as someone said some time ago: enum should be returned as string, not a number

@Lpsd
Copy link
Member Author

Lpsd commented Jul 4, 2019

@CrosRoad95 I have kept this consistent with onPlayerChat, which returns an integer

@qaisjp

This comment has been minimized.

@patrikjuvonen patrikjuvonen added the enhancement New feature or request label Jul 6, 2019
@patrikjuvonen patrikjuvonen added this to the Backlog milestone Jul 6, 2019
@moon91210
Copy link

I need this for a gamemode I'm working on. Could someone review this PR?

Copy link
Contributor

@qaisjp qaisjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bitstream needs bump

@Pirulax

This comment has been minimized.

@qaisjp qaisjp removed this from the Confirmed Issues milestone Dec 7, 2020
@patrikjuvonen patrikjuvonen added this to the Next Release (1.5.9) milestone Aug 4, 2021
@patrikjuvonen patrikjuvonen self-requested a review August 4, 2021 20:41
Copy link
Contributor

@patrikjuvonen patrikjuvonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, tested working. Thanks @Lpsd and @StrixG.

@patrikjuvonen patrikjuvonen merged commit 81bb2a7 into multitheftauto:master Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add messageType parameter to onClientChatMessage
7 participants