Page 1 of 1

[Cs:s] How to block kill command in console

Posted: Sat Oct 15, 2022 11:04 am
by cssbestrpg
Hi, i have issues to block kill command, whem you type it in console, it suppose to block, but it allows still kill yourself in console, it doesn't send the message in chat.
Here is the code i tried:

Syntax: Select all

from commands.client import ClientCommand
from commands import CommandReturn
from colors import GREEN, LIGHT_GREEN
from messages import SayText2

@ClientCommand('kill')
def kill_command(command, index):
SayText2(f"{GREEN}[ZR] » {LIGHT_GREEN}You can't {GREEN}suicide!").send(index)
return CommandReturn.BLOCK

Re: [Cs:s] How to block kill command in console

Posted: Sun Oct 16, 2022 4:30 am
by L'In20Cible
kill is technically a server command, not a client one. Using ServerCommand should work. However, you cannot access the index of the player issuing it because GetCommandIndex don't seem to be currently exported to Python.

EDIT: GetCommandIndex has been exported as commands.get_command_index into 3422d53. With this commit, you can do the following:

Syntax: Select all

from colors import GREEN, LIGHT_GREEN
from commands import get_command_index
from commands.server import ServerCommand
from commands import CommandReturn
from messages import SayText2

YOU_CANT_SUICIDE_MSG = SayText2(
f"{GREEN}[ZR] » {LIGHT_GREEN}You can't {GREEN}suicide!"
)

@ServerCommand('kill')
def kill_command(command):
YOU_CANT_SUICIDE_MSG.send(get_command_index())
return CommandReturn.BLOCK

Re: [Cs:s] How to block kill command in console

Posted: Sat Oct 22, 2022 11:19 am
by Ayuto
Just wanted to let you now that a new build is now available that includes get_command_index().

Re: [Cs:s] How to block kill command in console

Posted: Sat Oct 22, 2022 11:30 am
by cssbestrpg
Ayuto wrote:Just wanted to let you now that a new build is now available that includes get_command_index().

Thanks for let me know of new build, but i already did compile myself the build few days ago that includes get_command_index()
Btw does the get_command_index() get index of ther user who executed the server command or just from console ones?