Author Topic: Chat Filtering commands  (Read 2383 times)

I'm working on a prevention the use of the server command timescale, but I don't really want to remove it altogether. I've tried filtering it in the chat, and I only manage to do is not really seeing any progress. What am I doing wrong?
Code: [Select]
function servercmdmessagesent(%cl,%msg)
{
%timescale = servercmdtimescale(%cl, %t);
parent::servercmdtimescale(%cl, %t);
if(striPos(%msg, %timescale)>= 0)
{
servercmdtimescale(1);
messageClient(%client, '', "<color:00FF00>[<color:FFFFFF>Time Controls Core<color:00FF00> says: Timescale command is disabled.");
Parent::serverCmdMessageSent(%cl,%msg);
}
}
« Last Edit: December 26, 2014, 09:43:08 AM by Quinn Mallory »

You are trying to modify serverCmdMessageSent, which is for actual chat messages being sent. You need to modify serverCmdTimeScale itself.

But the area I need to be in is the chat message. This is what I'm trying to do:

Billy Goat: /timescale 2
[Time Controls Core] says: Timescale is disabled.

However, I'm trying to make it support multiplayer. It would be a bad a feature to put in. I know the syntax for the message. So far, it only supports singleplayer with it using clientcmdtimescale.

The processing of a slash command in chat isn't handled by the server at all, it's handled by the client
If you type "/timescale 2" in chat, the server never receives that message. Instead, the client catches it, and turns it into commandtoserver('timescale',2);, and sends that to the server. The server then process servercmdtimescale
You need to modify serverCmdTimescale
« Last Edit: December 26, 2014, 11:57:26 AM by Headcrab Zombie »

The processing of a slash command in chat isn't handled by the server at all, it's handled by the client
If you type "/timescale 2" in chat, the server never receives that message. Instead, the client catches it, and turns it into commandtoserver('timescale',2);, and sends that to the server. The server then process servercmdtimescale
You need to modify serverCmdTimescale
this man is correct

The processing of a slash command in chat isn't handled by the server at all, it's handled by the client
If you type "/timescale 2" in chat, the server never receives that message. Instead, the client catches it, and turns it into commandtoserver('timescale',2);, and sends that to the server. The server then process servercmdtimescale
You need to modify serverCmdTimescale

Oh ok. That I did not know. so if it was like
Code: [Select]
function servercmdtimescale(%cl, %t)
{
      if(commandtoserver('timescale', %t))
      {
                 return;
      }
};

Would I be able still use the servercmdtimescale thing in the code, I still want to use it though

I'm not sure what you're trying to do with that condition
What do you  want to be able to do with timescale? do you want it only be usable by you?
Check if %cl.bl_id is equal to your id (there's a few other cases to check, but that will cover online servers), if so, call the parent, if not, tell the client it's unusable

You should package and parent it as well.

You should package and parent it as well.
I know that, and well aware of that. Thank you.
I'm not sure what you're trying to do with that condition
What do you  want to be able to do with timescale? do you want it only be usable by you?
Check if %cl.bl_id is equal to your id (there's a few other cases to check, but that will cover online servers), if so, call the parent, if not, tell the client it's unusable

I just want to disable the command in-game, but call the timescale with the servercmdtimescale in the code I'm using. Will someone just give me a straight answer?

Code: [Select]
package noTimescale {
    function serverCmdTimeScale(%client, %scale) {
    }
};
activatePackage(noTimescale);

You might want to make it at least host-only or somtehing, which you can do like this:

Code: [Select]
package noTimescaleExceptHost {
    function serverCmdTimeScale(%client, %scale) {
        if(%client.BL_ID != getNumKeyID())
            return;
        parent::serverCmdTimeScale(%client, %scale);
    }
};
activatePackage(noTimescaleExceptHost);

You can make it super-admin only by changing the line that starts with "if" to if(!%client.isSuperAdmin).

I'm not trying to spoon feed you working code but what you're asking for is too basic to explain in a useful way that isn't just code translated to english.

Whenever you type /anything it will call serverCmdAnything on the server. It doesn't call serverCmdMessageSent. The arguments for that function are (%client, %all, %words, %after, %the, %function, %name). When you overwrite a function inside a package, to make it do its default behavior you use parent::theFunctionNameHere(%the, %arguments, %here). Since you don't want it to do the default behavior (change the timescale) you just leave this out. If you want it to do the default behavior under some condition, use an if statement and if it's true call the function. In this case I had it exit the function if it's true (with a return;) and run the function if it's false. Same thing.
« Last Edit: December 27, 2014, 01:32:43 AM by $trinick »

Code: [Select]
package noTimescale {
    function serverCmdTimeScale(%client, %scale) {
    }
};
activatePackage(noTimescale);

You might want to make it at least host-only or somtehing, which you can do like this:

Code: [Select]
package noTimescaleExceptHost {
    function serverCmdTimeScale(%client, %scale) {
        if(%client.BL_ID != getNumKeyID())
            return;
        parent::serverCmdTimeScale(%client, %scale);
    }
};
activatePackage(noTimescaleExceptHost);

You can make it super-admin only by changing the line that starts with "if" to if(!%client.isSuperAdmin).

I'm not trying to spoon feed you working code but what you're asking for is too basic to explain in a useful way that isn't just code translated to english.

Whenever you type /anything it will call serverCmdAnything on the server. It doesn't call serverCmdMessageSent. The arguments for that function are (%client, %all, %words, %after, %the, %function, %name). When you overwrite a function inside a package, to make it do its default behavior you use parent::theFunctionNameHere(%the, %arguments, %here). Since you don't want it to do the default behavior (change the timescale) you just leave this out. If you want it to do the default behavior under some condition, use an if statement and if it's true call the function. In this case I had it exit the function if it's true (with a return;) and run the function if it's false. Same thing.

FINALLY. A straight answer answer. I like that thought of making it host-only, I think I will do that. That way the host can debug the timescale. I will be sure to include the credit on some of the code man. Thanks!