Page 1 of 1

Say and client command callback updates

Posted: Mon Sep 14, 2015 6:31 pm
by Ayuto
We just updated the say and client command callbacks. Four things have changed:

  1. We changed the order of the arguments passed to the callbacks.
  2. We are now passing an index instead of a PlayerInfo object to the callback.
  3. We removed the first argument of the command object in say command callbacks. It was always "say" or "say_team".
  4. Say command arguments are now properly splitted.
This is now the proper argument order for say/client/server callbacks:

Syntax: Select all

from commands.say import SayCommand

@SayCommand('test')
def on_test(command, index, team_only):
pass

Syntax: Select all

from commands.client import ClientCommand

@ClientCommand('test')
def on_test(command, index):
pass

Syntax: Select all

from commands.server import ServerCommand

@ServerCommand('test')
def on_test(command):
pass

The changes will be available in [url=build.affecta.net/job/Source.Python/49/]build #49[/url].

Posted: Mon Sep 14, 2015 6:36 pm
by stonedegg
Are we already able to get an index from a ServerCommand callback? (client index if executed with rcon, -1/None if executed from server console)

Posted: Mon Sep 14, 2015 7:38 pm
by Ayuto
No, currently it's not possible. Is there a high demand on that feature?

Posted: Mon Sep 14, 2015 9:58 pm
by stonedegg
No, not for now, but it would still be a nice thing and it would be needed if someone were to make an admin panel that gets integrated to SP like sourcemod it has. Do you actually have any plans on that?

Posted: Mon Sep 14, 2015 10:28 pm
by Ayuto
Yes, there are plans. We already created a repository, but didn't get around working on it. But that feature is not required to create an admin plugin. Authorization can/will be done through menus and/or say/client commands.

If you want to restrict the server commands your administrators can run, don't give them your rcon password. You better create a new client command e.g. restricted_rcon and do the authorization in that callback. If you want to fully mimic the rcon behaviour, you could also register another client command e.g. restricted_rcon_password, which authorizes a client.

Posted: Mon Sep 14, 2015 11:41 pm
by satoon101
To expand on points 3 and 4 in the main post, previously the command argument was the original CCommand instance passed during the say/say_team server command. In that instance, there were always exactly 2 arguments, the (say/say_team) command itself and the message sent to chat surrounded by quotes. Now, we have replaced that instance with a new CCommand instance that instead uses the actual chat message. This not only affects say commands, but say filters as well.

  • Old version:

    Syntax: Select all

    @SayCommand('test')
    def test_command(playerinfo, teamonly, command):
    say_command = command[1].split()[0]
    arguments = command[1].split(maxsplit=1)[1]
  • New version:

    Syntax: Select all

    @SayCommand('test')
    def test_command(command, index, teamonly):
    say_command = command[0]
    arguments = command.get_arg_string()