Client Command ?

Please post any questions about developing your plugin here. Please use the search function before posting!
MithatGuner
Junior Member
Posts: 7
Joined: Thu Jun 29, 2017 5:32 pm

Client Command ?

Postby MithatGuner » Fri Jun 30, 2017 8:49 am

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.
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Re: Client Command ?

Postby Predz » Fri Jun 30, 2017 10:39 am

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

Re: Client Command ?

Postby Ayuto » Fri Jun 30, 2017 11:39 am

You might also want to take a look at typed commands:
http://wiki.sourcepython.com/developing ... mands.html
MithatGuner
Junior Member
Posts: 7
Joined: Thu Jun 29, 2017 5:32 pm

Re: Client Command ?

Postby MithatGuner » Fri Jun 30, 2017 12:40 pm

Thanks for answer :)

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 19 guests