Skip to content

Conversation

@antoniostassi
Copy link

@antoniostassi antoniostassi commented Feb 17, 2025

Summary

This will simply prevent the message to be sent if the first letter of the msg is "/"

@antoniostassi antoniostassi marked this pull request as draft February 17, 2025 02:16
@antoniostassi antoniostassi changed the title Cancel bool Prevent message to be sent Feb 17, 2025
@antoniostassi antoniostassi marked this pull request as ready for review February 17, 2025 12:56
@razor950
Copy link

I would probably just change it to

private void Chat_OnChatMessage(Player player, string msg)
{
    if (!chatMsgOverride && !string.IsNullOrEmpty(msg))
        BuildMessage(player, msg);
}

Server admins can handle the rest on their server plugin end, for example they could check if msg has a "/" and just call chatPlugin!.chatMsgOverride = true; on their end.

The above assumes chatPlugin is the HogWarpChat variable

@antoniostassi
Copy link
Author

I would probably just change it to

private void Chat_OnChatMessage(Player player, string msg)
{
    if (!chatMsgOverride && !string.IsNullOrEmpty(msg))
        BuildMessage(player, msg);
}

Server admins can handle the rest on their server plugin end, for example they could check if msg has a "/" and just call chatPlugin!.chatMsgOverride = true; on their end.

The above assumes chatPlugin is the HogWarpChat variable

I tried this solution but I remember I had some problems of "timing", the chatMsgOverride variable wouldn't be updated in time to prevent the BuildMessage function to be triggered.
Maybe I'm wrong, but when I tried it I got some problems. (:

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