Author Topic: How to block chat from script ?  (Read 1229 times)

0 Members and 1 Guest are viewing this topic.

Offline Szaman

  • Soldier
  • **
  • Posts: 145
How to block chat from script ?
« on: August 20, 2013, 06:42:56 pm »
Hi,

I would like to find out how to block the chat of player - for example: when message starts with "/" sign it should not be shown to the public.

The documentation says:
Quote
procedure OnPlayerSpeak(ID: Byte; Text: string);
 
 NOTE: This event runs in a new thread! So using functions like
       GetURL or Sleep will not cause the Server to freeze while
       the function processes.
 
 Parameter Info:
  ID (Byte): Player ID of the person who just spoke.
  Text (String): Self Explanitory.
 
 Description:
  This procedure will be called every time a player speaks.

There is no such thing like result which could be set when I don't want to show the chat message.
Setting Text to '' also not works.

Could you help me with that, please ?

Thanks in advance :)

Best regards,
Szaman.
« Last Edit: August 20, 2013, 06:46:15 pm by Szaman »

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Re: How to block chat from script ?
« Reply #1 on: August 20, 2013, 07:04:15 pm »
At the moment it's impossible to block player's normal text. You can only block commands.
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID

Offline skrX

  • Soldier
  • **
  • Posts: 112
  • x ye.
Re: How to block chat from script ?
« Reply #2 on: August 21, 2013, 02:09:50 am »
Code: [Select]
procedure OnPlayerSpeak(ID: byte; Text: string);
begin
if Length(text) > 1 then
begin
if Copy(text,1,1) = '/' then
begin
WriteConsole(ID,'Commands beginning with "/" must be typed into the console.',$FFFFFF);
end;
end;
end;

I'm not sure about that, or for that matter.
« Last Edit: August 21, 2013, 02:13:54 am by skrX »

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: How to block chat from script ?
« Reply #3 on: August 21, 2013, 03:51:13 am »
That note is a lie. It runs in main thread. Removed from wiki page.
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline Szaman

  • Soldier
  • **
  • Posts: 145
Re: How to block chat from script ?
« Reply #4 on: August 21, 2013, 04:50:24 pm »
Thank you all very much for your responses.

Is this functionality - blocking chat messages - is in near plans of developing Soldat ?

@skrX - yeah, that's will work... but will also display the message which the user typed in. And I would like to prevent showing passwords in (for example):
Code: [Select]
/login Szaman top_secret_password_123if the user will type it in chat not as a command...

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: How to block chat from script ?
« Reply #5 on: August 21, 2013, 05:26:37 pm »
If you are concerned about somebody discovering an accidental release of a password (by doing /login ... as speech rather than a command), one option is to warn the user that they tried the correct password, and because it was publicly mentioned in the some /login text, you could change their password and pm them it. This will prevent others from being able to access the account. Although if they aren't paying attention or something and never got the message, there should be some safeguard so that they don't lose access to their account. More thought would need to be put into this idea.

Offline Szaman

  • Soldier
  • **
  • Posts: 145
Re: How to block chat from script ?
« Reply #6 on: August 21, 2013, 05:55:26 pm »
Thanks! This idea with private-messaging a new (changed) password is great! :)

I think it's very good by-pass of this missing functionality of hiding chat messages.

Thanks one more time :)

Offline AL

  • Major(1)
  • Posts: 10
  • ...
Re: How to block chat from script ?
« Reply #7 on: August 26, 2013, 04:31:44 am »
I remember trying to find some sort of workaround to block player speech a while ago for a troll script, but never succeeded. For what I wanted to do, there was no alternative unfortunately. I might even at one stage have considered trying to redraw the whole chat history and ommit a single line to hide what a player said, but there were too many text events I couldn't track (eg graphics restart/direct imput lines from alt-tab).