General > Developers Corner

PlayerSay running after ULX

(1/2) > >>

StaTiiKxKALEB:
I'm running into an issue with blocking chat messages. It's more of a test than something I'd actually use, but it's good for the future. It blocks chat for team chat and public chat but how would I make it so it also blocks it in psay and asay? I'm going to guess the reason why it's still being shown in ULX commands is because ULX is running first, correct?

--- Code: --- local function blockCmds( ply, text, public )
    if M.Config.EnableBlockedWords then
        for _, v in pairs(M.BlockedWords) do
            if string.find(text, v) then
                return ""
            end
        end
    end
end
hook.Add( "PlayerSay", "blockCmds", blockCmds)

--- End code ---

roastchicken:

--- Quote from: StaTiiKxKALEB on May 13, 2016, 09:27:25 AM ---I'm running into an issue with blocking chat messages. It's more of a test than something I'd actually use, but it's good for the future. It blocks chat for team chat and public chat but how would I make it so it also blocks it in psay and asay? I'm going to guess the reason why it's still being shown in ULX commands is because ULX is running first, correct?

-snipped code-

--- End quote ---

Incorrect.

Team and public chat are both chat messages handled by the server itself, and as such they trigger the PlayerSay hook. PSay and ASay are not handled by the server, but instead by ULX, and therefor do not trigger the PlayerSay hook.

The only way I can think to block PSay or ASay would be to recreate the commands yourself, adding in a check for these blocked words and aborting if one is found.

StaTiiKxKALEB:

--- Quote from: roastchicken on May 13, 2016, 03:19:33 PM ---Incorrect.

Team and public chat are both chat messages handled by the server itself, and as such they trigger the PlayerSay hook. PSay and ASay are not handled by the server, but instead by ULX, and therefor do not trigger the PlayerSay hook.

The only way I can think to block PSay or ASay would be to recreate the commands yourself, adding in a check for these blocked words and aborting if one is found.

--- End quote ---
Thanks man, I wasn't trying to imply that ULX was doing it, I was just stating what I thought it'd be. Thanks for the help man. I appreciate it.

JamminR:

--- Quote from: roastchicken on May 13, 2016, 03:19:33 PM ---The only way I can think to block PSay or ASay would be to recreate the commands yourself, adding in a check for these blocked words and aborting if one is found.

--- End quote ---

ULibCommandCalled would likely be better.
Return false if blocked word(s) are found in args, command used was "ulx asay" or "ulx psay", do whatever to calling player.

StaTiiKxKALEB:

--- Quote from: JamminR on May 13, 2016, 06:22:14 PM ---ULibCommandCalled would likely be better.
Return false if blocked word(s) are found in args, command used was "ulx asay" or "ulx psay", do whatever to calling player.

--- End quote ---
Know of a place where it's used so I can see the efficient way to use it?

Navigation

[0] Message Index

[#] Next page

Go to full version