[ALL] MatterAMXX
Author: Gabe Iggy
Version: 1.5
Powered by Matterbridge, MatterAMXX is a plugin for AMXX that allows simple bridging between your game servers, Mattermost, IRC, XMPP, Gitter, Slack, Discord, Telegram, and more.
Description
Using Matterbridge API, this plugin allows you to bridge your game server with a Matterbridge installation, relaying messages from/to a growing number of protocols.
You can also bridge multiple servers together so the players can chat between each one.
Where cstrike is goes the gateway name. By default is the mod's gamedir (cstrike for Counter-Strike, valve for Half-Life, etc) but you can change it using cvars, you can add more gateway.inout entries depending on how many protocols do you want to relay messages.
Avatar Spoofing
It's possible to set up avatars for each user on protocols that support it. Unfortunately, due to limitations of AMXX and the GRIP module, user info from the Steam API can't be retrieved because it gets truncated.
However, you can host this simple PHP script to query for avatars to be used in this plugin, you just need a Steam API Key that you can obtain from the Steam Web API website.
Reveal script
PHP Code:
<?php
$ts = gmdate("D, d M Y H:i:s", time() + 2 * 3600) . " GMT";
header("Expires: $ts");
header("Pragma: cache");
header("Cache-Control: max-age=$seconds_to_cache");
header("Content-type: image/jpeg");
This will also cache each avatar and they will be deleted after a while.
Remember to create the /avatars folder! The script won't do it for you.
API
The API allows other plugins to use MatterAMXX features. Just include the matteramxx.inc file in your plugin and it should work immediately.
Reveal script
PHP Code:
/**
* Called when we get a message coming from Matterbridge
*
* This forward has 2 possible return values:
* · MATTER_IGNORE ignores the forward and posts the message as it is.
* · MATTER_SUPERCEDE prevents the message from sending.
*
* @param message[] - Message coming from Matterbridge.
*
*/
forward matteramxx_print_message(message[MESSAGE_LENGTH], username[MAX_NAME_LENGTH], protocol[MAX_NAME_LENGTH], userid[MAX_NAME_LENGTH]);
/**
* Method to send a message to the configured Matterbridge instance.
*
* @param message[] - Message you want to send
* @param username[] - Username that will appear in the protocols
* @param avatar[] - URL pointing to the avatar of this "user" (On protocols that support it)
* @param is_system - If true, message won't be printed in other game servers
* @param gateway[] - Specify the gateway we should send this message, main if empty
*
*/
native matteramxx_send_message(const message[], const username[] = "", const avatar[] = "", const bool:is_system = false, const gateway[] = "");
Remember that the plugin requires the latest version of MatterAMXX to be running in the server.
URL pointing to a picture that will be used as avatar image in system messages. (In protocols that support it)
Default: [empty string]
amx_matter_autogenerate_avatar
URL pointing to a picture that will be used as avatar image in unauthenticated player messages. (In protocols that support it)
This will mostly affect LAN servers, ID_PENDING cases, cases where Steam might be down and other specific cases.
This is generated on the user's nickname, so you must provide a link to Gravatar, Identicons, etc.
Default: [empty string]
amx_matter_player_avatar
URL pointing to a picture that will be used as avatar image in player messages. (In protocols that support it)
Note that this is dynamic based on the user's Steam ID64, if it can't be retrieved the message won't have any avatar.
Upload the PHP file I provided to your file server and use it in this cvar like "http://localhost/avatars/get_avatar.php?steamid=%s".
See "Avatar Spoofing" for more information.
Default: [empty string]
amx_matter_bridge_gateway
Gateway name to connect.
Default: [varies, depends on the game]
amx_matter_bridge_token
String token to authenticate, it's recommended that you set it up, but it will accept any connection by default.
Default: [empty string]
amx_matter_bridge_incoming
Enables incoming messages (protocols to server).
Default: 1
amx_matter_bridge_incoming_ignore_prefix
Messaging matching this in the beggining of the message will be ignored by the plugin.
It supports regex.
Plugins using the API can still catch these messages.
Default: "!"
amx_matter_bridge_incoming_dont_colorize
By default it will colorize any message with a simple format (green username) but if set to 1 it will not colorize anything, leaving the admin to handle any colorization in the matterbridge.toml file.
It will only affect Counter-Strike.
Default: 0
amx_matter_incoming_update_time
Specifies how many seconds it has to wait before querying new incoming messages.
Performance wise is tricky, lower values mean the messages will be queried instantly, while higher values will wait and bring all messages at once, both cases may cause overhead. Experiment and see what's ideal for your server.
No effect if amx_matter_bridge_incoming is 0.
Default: 3.0
amx_matter_bridge_outgoing
Enables outgoing messages (server to protocols).
Default: 1
amx_matter_bridge_outgoing_display_map
Display the current map at the start of every session.
Default: 1
amx_matter_bridge_outgoing_strip_colors
Strip color codes from player names.
It will only affect Half-Life and Adrenaline Gamer.
No effect in other games.
No effect if amx_matter_bridge_outgoing is 0.
Default: 1
amx_matter_bridge_outgoing_system_username
Name of the "user" when relying system messages.
No effect if amx_matter_bridge_outgoing is 0.
Default: [your server name]
amx_matter_bridge_outgoing_chat_mode
Select which chat messages you want to send.
1 = All chat
2 = Team chat
You must sum the values you want to send. For example, if you want to send everything the value must be 3.
No effect if amx_matter_bridge_outgoing is 0.
Default: 3
amx_matter_bridge_outgoing_chat_zwsp_at
This controls if the plugin should add a ZWSP character after the at symbol (@) to prevent unintentional or malicious pinging.
No effect if amx_matter_bridge_outgoing_chat is 0.
No effect if amx_matter_bridge_outgoing is 0.
Default: 1
amx_matter_bridge_outgoing_chat_no_repeat
Implement basic anti-spam filter. Useful for preventing taunt binds from sending multiple times.
No effect if amx_matter_bridge_outgoing_chat is 0.
No effect if amx_matter_bridge_outgoing is 0.
Default: 1
amx_matter_bridge_outgoing_kills
Transmit kill feed.
It's recommended that you to turn it off on heavy activity servers (Like CSDM/Half-Life servers with tons of players)
No effect if amx_matter_bridge_outgoing is 0.
Default 1
amx_matter_bridge_outgoing_join
Transmit when people join the server.
No effect if amx_matter_bridge_outgoing is 0.
Default: 1
amx_matter_bridge_outgoing_join_delay
Specify how many seconds the server has to wait before sending Join messages..
No effect if amx_matter_bridge_outgoing_join is 0.
Specify if the server shouldn't send quit messages if the server reached the intermission state.
No effect if amx_matter_bridge_outgoing_quit is 0.
Default: 0
amx_matter_bridge_outgoing_joinquit_count
Display playercount on each Join/Quit message.
No effect if both amx_matter_bridge_outgoing_quit and amx_matter_bridge_outgoing_join are 0.
Default: 1
amx_matter_bridge_retry_delay
In seconds, how long the server has wait before retrying a connection when it was interrupted.
No effect if amx_matter_bridge_outgoing is 0.
Default: 3.0
Change Log
1.5 Main Changes
Deprecated the usage of amx_matter_bridge_url, users are encouraged to use the new cvars amx_matter_bridge_protocol, amx_matter_bridge_host and amx_matter_bridge_port.
The plugin will no longer try to query the incoming protocol, it will now respect the format specified on the matterbridge.toml file.
Introduced system messages, a message marked as "system message" won't be printed to other game servers.
User's SteamID is now included in the Matterbridge payload.
Added cvar amx_matter_bridge_incoming_dont_colorize. Only for Counter-Strike, by default it will colorize any message with a simple format (green username) but if set to 1 it will not colorize anything, leaving the admin to handle any colorization in the matterbridge.toml file.
Fixed a lot of errors related to Counter-Strike and rendering text with colors.
Removed amx_matter_bridge_outgoing_chat and amx_matter_bridge_outgoing_chat_team cvars, these will now be managed by a single cvar: amx_matter_bridge_outgoing_chat_mode. Add the sum of the desired behavior:
Send all chat = 1
Send team chat = 2
If you want to send everything, you must put 3.
Added amx_matter_bridge_incoming_ignore_prefix. Useful to ignore bot commands.
Server messages now support multi language.
Quotes no longer get removed from players' messages.
Made Sven Co-op use the alternative language file, the game doesn't support rendering "%" in chat.
Sub plugin changes
API
Added support for system messages.
matteramxx_print_message now includes the userid field.
Plugins now can specify an alternative Matterbridge gateway.
matteramxx_send_message is now a native.
CONSOLE
Console output won't be escaped if amx_matter_rcon_code_block is on.
Ignore commands coming from other game servers.
It will now use the user id instead of the name for admin checking.
Removed support for listip/listid commands, changed error message for a better explanation.
LAG CHECKER
Fix missing localization strings.
Fixed using wrong lag percent formula.
1.4
The matteramxx_print_message() forward now includes the user's avatar and protocol.
Fixed the Killed Hamsandwich hook in TFC that was not working as it should.
Added multilingual support.
Many thanks to the language contributors:
Romanian: tom .
Turkish: Snake.
Albanian: thEsp
Russian: Natsheh
The following console variables are now protected:
amx_matter_bridge_token
amx_matter_bridge_gateway
amx_matter_bridge_url
amx_matter_player_avatar
amx_matter_autogenerate_avatar
amx_matter_system_avatar
Added new console variable: amx_matter_bridge_outgoing_chat_zwsp_at
This controls if the plugin should add a ZWSP character after the at symbol (@) to prevent unintentional or malicious pinging.
Added new console variable: amx_matter_bridge_incoming_chat_protocol
This controls if the plugin should add the message protocol in incoming messages.
The plugin (and subplugins) now pause when disabled.
Code cleanup.
New subplugins released to showcase the power of the MatterAMXX Api:
MatterAMXX Lagchecker
This plugin will notify a configured user if the CPU/FPS increase/fall past/below a defined threshold.
This will be triggered if any user says "lag".
This will also output the current values to the users notifying them if the server is not lagging.
So basically, I can register the whatsapp with the server and when someone join or leave the server, a message is sent to the group or person on whatsapp?
So basically, I can register the whatsapp with the server and when someone join or leave the server, a message is sent to the group or person on whatsapp?
You can relay messages between WhatsApp and the server, yes.
Join and Quit messages will only be sent after the user has actually joined the server (putinserver). This will prevent Join/Leave spam.
Added new console variable: amx_matter_system_avatar
Url poiting to a picture that will be used as avatar image in system messages. (In protocols that support it)
Added new console variable: amx_matter_player_avatar
Url poiting to a picture that will be used as avatar image in player messages. (In protocols that support it).
Note that this is dynamic based on the user's Steam ID64, if it can't be retrieved the message won't have any avatar.
Added new console variable: amx_matter_bridge_outgoing_strip_colors
Strip color codes from player names.
It will only affect Half-Life and Adrenaline Gamer.
Added new console variable: amx_matter_bridge_outgoing_chat_no_repeat
Implement basic anti-spam filter. Useful for preventing taunt binds from sending multiple times.
Minor code cleanup
It's now possible to set up avatars for each user on protocols that support it. Unfortunately, due to limitations of AMXX and the GRIP module, user info from the Steam API can't be retrieved because it gets truncated.
However, you can host this simple PHP script to query for avatars to be used in this plugin, you just need a Steam API Key that you can obtain from the Steam Web API website.
Visit https://pastebin.com/p9aBm1pS to get the script (Because CloudFlare is blocking the script from being posted here)
This will also cache each avatar and they will be deleted after a while.
Remember to create the /avatars folder! The script won't do it for you.
Looks like the plugin crashes on Ricochet due to it not having hamdata.ini entries, even if you disable the streaming of kill feed. (The plugin crashes upon detecting it has a Ham function, not when executing it)
Current roadmap:
Implement API so other plugins can send messages via MatterAMXX Somewhat done. Need to know why I can't read the incoming message from the other plugin. Sending works fine.
Implement simple compile defines to decide if you want to compile with HamSandwich support. (Search another way to detect death of players? Needs to be mod agnostic tho') Done (Using DeathMsg event)
Add a list of words that would be ignored when typed in the chat (Stuff like "nextmap", "rtv", etc.)
I would also like to add some checks to prevent Join messages on the first N seconds the map started, and Quit messages when we reached the intermission, to further prevent Join/Leave spam. Done
Of course add a message when the map changed, should be very easy. Done as well