Say and client command callback updates

Official Announcements about Source.Python.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Say and client command callback updates

Postby Ayuto » Mon Sep 14, 2015 6:31 pm

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].
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Mon Sep 14, 2015 6:36 pm

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)
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Mon Sep 14, 2015 7:38 pm

No, currently it's not possible. Is there a high demand on that feature?
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Mon Sep 14, 2015 9:58 pm

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?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Mon Sep 14, 2015 10:28 pm

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.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Sep 14, 2015 11:41 pm

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()
Image

Return to “News & Announcements”

Who is online

Users browsing this forum: No registered users and 5 guests