[CS:GO] Strange behavior of custom commands

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
copyerfiled
Junior Member
Posts: 16
Joined: Wed Jan 23, 2019 9:40 am

[CS:GO] Strange behavior of custom commands

Postby copyerfiled » Thu Mar 07, 2019 9:20 am

Hello!
I use python-valve for connect to csgo server via RCON.
If I use naitive commands, the response always comes, a message that returns to the server console.
For example, I send the status command via RCON
RCON response:

Code: Select all

hostname: myserver
...
os      :  Linux
type    :  community dedicated
map     : de_mirage
players : 1 humans, 9 bots (10/0 max) (not hibernating)

# userid name uniqueid connected ping loss state rate adr
...
#13 "Zane" BOT active 64
#14 "Cory" BOT active 64
#15 "Dave" BOT active 64
...



CONSOLE response:

Code: Select all

hostname: myserver
...
os      :  Linux
type    :  community dedicated
map     : de_mirage
players : 1 humans, 9 bots (10/0 max) (not hibernating)

# userid name uniqueid connected ping loss state rate adr
...
#13 "Zane" BOT active 64
#14 "Cory" BOT active 64
#15 "Dave" BOT active 64
...



This behavior for naitive commands, but if I use custom commands via RCON, i have response only server console.

Code: Select all

@TypedServerCommand('test')
def on_test(command_info):
    print('blablabla')


Maybe there's an opportunity to do so that custom commands behave well?
Maybe I something doing wrong?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [CS:GO] Strange behavior of custom commands

Postby Ayuto » Thu Mar 07, 2019 10:01 am

The print() function directly writes to sys.stdout. It doesn't include any more logic. However, you can use this to have the same behaviour like standard commands.

Syntax: Select all

from core import console_message

console_message('blablabla')
Alternatively, you can replace sys.stdout like described here:
https://github.com/Source-Python-Dev-Te ... #L488-L498

Then you can use print() and it redirects the message through console_message().
User avatar
copyerfiled
Junior Member
Posts: 16
Joined: Wed Jan 23, 2019 9:40 am

Re: [CS:GO] Strange behavior of custom commands

Postby copyerfiled » Sat Mar 16, 2019 9:17 pm

Ayuto wrote:The print() function directly writes to sys.stdout. It doesn't include any more logic. However, you can use this to have the same behaviour like standard commands.

Syntax: Select all

from core import console_message

console_message('blablabla')
Alternatively, you can replace sys.stdout like described here:
https://github.com/Source-Python-Dev-Te ... #L488-L498

Then you can use print() and it redirects the message through console_message().


It's exactly what I needed. Thank you!

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 28 guests