Page 1 of 1

Client Command ?

Posted: Fri Jun 30, 2017 8:49 am
by MithatGuner
Hi im new at source.python
example :
in sourcemod i do

Code: Select all

RegConsoleCmd("sm_test", TEST);

public Action TEST(int client, int args)
{
 PrintToChat(client, "HELLO WORLD!);
}

how can i do this in source.python
sorry for my bad english.

Re: Client Command ?

Posted: Fri Jun 30, 2017 10:39 am
by Predz
Hi, in SourcePython we use Python decorators to register commands to functions.

Syntax: Select all

from commands.client import ClientCommand
from commands.say import SayCommand

## Registering a console command
@ClientCommand(<command/list of commands>)
def _registered_client_command_function(command, pindex):
## command is a CCommand Instance
## pindex is the index of the player calling
## player is a Players instance
player = Player(pindex)
args = command.arg_string

@SayCommand(.....)
def _registered_say_command_function(command, pindex, teamonly):
## teamonly is a boolean.
## True if was in team only chat. Otherwise False

Re: Client Command ?

Posted: Fri Jun 30, 2017 11:39 am
by Ayuto
You might also want to take a look at typed commands:
http://wiki.sourcepython.com/developing ... mands.html

Re: Client Command ?

Posted: Fri Jun 30, 2017 12:40 pm
by MithatGuner
Thanks for answer :)