Lets say that we have kick menu with reason selection. One of the reasons is "other" how can we ask for the reason to be typed through text input after player selects "other"? Then after that we want to be able to print both player and the reason.
Also this is for csgo
Thanks in advance! :)
Kick menu->reason: other->text input
Re: Kick menu->reason: other->text input
The only and the most obvious text input area in CS:S is its chat area.
You can go with something like selecting the player in your popup menu, but entering the reason through chat just after that.
Would kick selected in a popup player with the proper reason.
also, motd
You can go with something like selecting the player in your popup menu, but entering the reason through chat just after that.
!kr Stop voice spamming
Would kick selected in a popup player with the proper reason.
also, motd

My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam
Hail, Companion. [...] Hands to yourself, sneak thief.

Re: Kick menu->reason: other->text input
iPlayer wrote:The only and the most obvious text input area in CS:S is its chat area.
You can go with something like selecting the player in your popup menu, but entering the reason through chat just after that.!kr Stop voice spamming
Would kick selected in a popup player with the proper reason.
also, motd
Well the problem is that I don't know how can I pass the option.value to @Saycommands function or whatever is the way to do that.
Re: Kick menu->reason: other->text input
You need to store them in a dict or something like that.
I made a small example how it could look like:
I made a small example how it could look like:
Syntax: Select all
# =============================================================================
# >> IMPORTS
# =============================================================================
from filters.players import PlayerIter
from messages import SayText2
from players.entity import Player
from menus import PagedMenu
from menus import PagedOption
from commands.say import SayCommand
from commands.say import SayFilter
from listeners import OnClientDisconnect
# =============================================================================
# >> CONSTANTS
# =============================================================================
KICK_NO_REASON = 0
KICK_WITH_REASON = 1
# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
class Info(object):
def __init__(self, userid, name, wait_for_reason=False):
self.userid = userid
self.name = name
self.wait_for_reason = wait_for_reason
info_dict = {}
# =============================================================================
# >> KICK MENU
# =============================================================================
kick_menu = PagedMenu()
kick_menu.append(PagedOption('Kick without reason', KICK_NO_REASON))
kick_menu.append(PagedOption('Kick with reason', KICK_WITH_REASON))
@kick_menu.register_select_callback
def on_menu_select(menu, index, option):
info = info_dict[index]
try:
player_to_kick = Player.from_userid(info.userid)
except ValueError:
del info_dict[index]
SayText2('{} is not on the server anymore.'.format(info.name))
return
if option.value == KICK_NO_REASON:
player_to_kick.kick()
elif option.value == KICK_WITH_REASON:
info.wait_for_reason = True
SayText2('Enter a reason for kicking {}.'.format(info.name)).send(index)
# =============================================================================
# >> PLAYER MENU
# =============================================================================
player_menu = PagedMenu('Select a player to kick:')
@player_menu.register_build_callback
def on_player_menu_build(menu, index):
menu.clear()
for player in PlayerIter():
menu.append(PagedOption(player.name, player.userid))
@player_menu.register_select_callback
def on_player_menu_select(menu, index, option):
userid = option.value
try:
player_to_kick = Player.from_userid(userid)
except ValueError:
SayText2('{} is not on the server anymore.'.format(option.text))
else:
info_dict[index] = Info(userid, option.text)
kick_menu.send(index)
# =============================================================================
# >> KICK COMMAND
# =============================================================================
@SayCommand('!kick')
def on_kick(command, index, team_only):
player_menu.send(index)
# =============================================================================
# >> REASON FILTER
# =============================================================================
@SayFilter
def on_say(command, index, team_only):
info = info_dict.pop(index, None)
if info is None or not info.wait_for_reason:
return
try:
player_to_kick = Player.from_userid(info.userid)
except ValueError:
SayText2('{} is not on the server anymore.'.format(info.name))
else:
player_to_kick.kick(command.command_string)
# =============================================================================
# >> CLIENT DISCONNECT
# =============================================================================
@OnClientDisconnect
def on_client_disconnect(index):
# Cleanup if existant
info_dict.pop(index, 0)
Re: Kick menu->reason: other->text input
Ayuto wrote:You need to store them in a dict or something like that.
I made a small example how it could look like:Syntax: Select all
# =============================================================================
# >> IMPORTS
# =============================================================================
from filters.players import PlayerIter
from messages import SayText2
from players.entity import Player
from menus import PagedMenu
from menus import PagedOption
from commands.say import SayCommand
from commands.say import SayFilter
from listeners import OnClientDisconnect
# =============================================================================
# >> CONSTANTS
# =============================================================================
KICK_NO_REASON = 0
KICK_WITH_REASON = 1
# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
class Info(object):
def __init__(self, userid, name, wait_for_reason=False):
self.userid = userid
self.name = name
self.wait_for_reason = wait_for_reason
info_dict = {}
# =============================================================================
# >> KICK MENU
# =============================================================================
kick_menu = PagedMenu()
kick_menu.append(PagedOption('Kick without reason', KICK_NO_REASON))
kick_menu.append(PagedOption('Kick with reason', KICK_WITH_REASON))
@kick_menu.register_select_callback
def on_menu_select(menu, index, option):
info = info_dict[index]
try:
player_to_kick = Player.from_userid(info.userid)
except ValueError:
del info_dict[index]
SayText2('{} is not on the server anymore.'.format(info.name))
return
if option.value == KICK_NO_REASON:
player_to_kick.kick()
elif option.value == KICK_WITH_REASON:
info.wait_for_reason = True
SayText2('Enter a reason for kicking {}.'.format(info.name)).send(index)
# =============================================================================
# >> PLAYER MENU
# =============================================================================
player_menu = PagedMenu('Select a player to kick:')
@player_menu.register_build_callback
def on_player_menu_build(menu, index):
menu.clear()
for player in PlayerIter():
menu.append(PagedOption(player.name, player.userid))
@player_menu.register_select_callback
def on_player_menu_select(menu, index, option):
userid = option.value
try:
player_to_kick = Player.from_userid(userid)
except ValueError:
SayText2('{} is not on the server anymore.'.format(option.text))
else:
info_dict[index] = Info(userid, option.text)
kick_menu.send(index)
# =============================================================================
# >> KICK COMMAND
# =============================================================================
@SayCommand('!kick')
def on_kick(command, index, team_only):
player_menu.send(index)
# =============================================================================
# >> REASON FILTER
# =============================================================================
@SayFilter
def on_say(command, index, team_only):
info = info_dict.pop(index, None)
if info is None or not info.wait_for_reason:
return
try:
player_to_kick = Player.from_userid(info.userid)
except ValueError:
SayText2('{} is not on the server anymore.'.format(info.name))
else:
player_to_kick.kick(command.command_string)
# =============================================================================
# >> CLIENT DISCONNECT
# =============================================================================
@OnClientDisconnect
def on_client_disconnect(index):
# Cleanup if existant
info_dict.pop(index, 0)
Thank you this was exactly what I was looking for.
-
- Member
- Posts: 43
- Joined: Mon Oct 02, 2017 7:57 am
- Location: Moscow
- Contact:
Re: Kick menu->reason: other->text input
What if I want to show reason to a player after I kicked him? player.kick("reason") shows reason only in console.
I mean, something else than "You were kicked from server" popup window.
Sourcemod version is: KickClient(client, "You were kicked");
I mean, something else than "You were kicked from server" popup window.
Sourcemod version is: KickClient(client, "You were kicked");
Re: Kick menu->reason: other->text input
The reason isn't only shown in the console. A popup als appears that displays your reason.
Re: Kick menu->reason: other->text input
If I remember correctly, CS:GO popup will always display the default text regardless of our reason. CS:S definitely displays your own reason - that's true, but CS:GO will just tell something like "Kicked by server" or something.

My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam
Hail, Companion. [...] Hands to yourself, sneak thief.

-
- Member
- Posts: 43
- Joined: Mon Oct 02, 2017 7:57 am
- Location: Moscow
- Contact:
Re: Kick menu->reason: other->text input
Sourcemod KickClient(client, "Game ended");
https://ibb.co/mmQpkG
SourcePython player.kick("End of game")
https://ibb.co/eLmjKb
As you can see, everybody is right somehow :)
https://ibb.co/mmQpkG
SourcePython player.kick("End of game")
https://ibb.co/eLmjKb
As you can see, everybody is right somehow :)
Re: Kick menu->reason: other->text input
Well, then it's probably due to the fact that they call client->Disconnect(<reason>) on the client. I will test that today, when I get home.
Re: Kick menu->reason: other->text input
A quick test has shown that calling client->Disconnect() properly shows the reason in CS:GO. The next build will fix this issue:
https://github.com/Source-Python-Dev-Te ... 37e4c50d10
https://github.com/Source-Python-Dev-Te ... 37e4c50d10
-
- Member
- Posts: 43
- Joined: Mon Oct 02, 2017 7:57 am
- Location: Moscow
- Contact:
Re: Kick menu->reason: other->text input
Checked new build. Now the message appears in popup window. Thank you!
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 44 guests