Jump to content

Problem with console commands say and teamsay


Ch3ck3r

Recommended Posts

Hi guys,

I've scripted a resource that controls my chat. It offers normal chat that reaches just the people nearby, shout chat (reaches people a bit more far away) and out-of-character chat to chat to everybody.

I want the players only to be able to chat when they are logged in.

I used an event handler on the event "onPlayerChat" and cancelEvent(true) to stop them from chatting when they are not logged in.

The problem is, if you press f8 and type in

say Hell everybody

you can chat even you are not logged in.

A simple way is to set "command.say" and "command.teamsay" to false in the acl.xml.

But I want these commands to work, when the players are logged in (it is the only way keybinds work properly).

Is there a way to achieve this?

Link to comment

No, that's the problem, it does not disable them from chatting using console and command "say" or "teamsay". I have tested it.

The simplest way i found out now is to "overwrite" the command with commandHandlers

function chatFromConsole(player, command, ...)
local message = table.concat({...}, " ")
cancelEvent(true, "Event handled by other functions")
if (command == "teamsay") then
triggerEvent("onPlayerChat", player, message, 2)
else
triggerEvent("onPlayerChat", player, message, 1)
end
end
 
addCommandHandler("say", chatFromConsole)
addCommandHandler("teamsay", chatFromConsole)

This cancel's the console command and triggers the normal chat handler which handles my chat output

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...