Skip to content

Add natives to get chat trigger strings#1816

Merged
peace-maker merged 1 commit intoalliedmodders:masterfrom
sirdigbot:get-chat-triggers
Dec 2, 2022
Merged

Add natives to get chat trigger strings#1816
peace-maker merged 1 commit intoalliedmodders:masterfrom
sirdigbot:get-chat-triggers

Conversation

@sirdigbot
Copy link
Contributor

The main utility of being able to know what the chat triggers are is if you want to display to clients how to type commands.
e.g. Welcome to the server! Type !rules for the server rules.

Or for chat processing, I guess.

Although I've never even encountered a server that has changed the chat triggers--so it's usually fine for plugins to just assume that ! and / are correct--it's still allowed to be changed, and currently the only way to get the actual chat triggers is processing the core.cfg file manually.

Tested with the following code:

#include <sourcemod>

public void OnPluginStart()
{
    char buffer[32];
    int written;
    
    written = GetPublicChatTriggers(buffer, sizeof(buffer));
    PrintToServer("Public Triggers: '%s', written=%i", buffer, written);
    
    written = GetSilentChatTriggers(buffer, sizeof(buffer));
    PrintToServer("Silent Triggers: '%s', written=%i", buffer, written);
    
    // Outputs
    // Public Triggers: '!', written=1
    // Silent Triggers: '/', written=1

}

@sirdigbot
Copy link
Contributor Author

I know it's an extremely specific feature but I figure the upkeep on it has got to be essentially zero just because it's so minimal

Copy link
Member

@peace-maker peace-maker left a comment

Choose a reason for hiding this comment

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

I could have used that as well for some help messages. Thanks for working on this and sorry for the delay!

@peace-maker peace-maker merged commit 3b4a343 into alliedmodders:master Dec 2, 2022
@sirdigbot sirdigbot deleted the get-chat-triggers branch December 12, 2022 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants