Add bot with custom name
Add bot with custom name
Hi guys,
Is it possible add bot by command like bot_add_ct or bot_add_t and set it custom name?
Is it possible add bot by command like bot_add_ct or bot_add_t and set it custom name?
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Code: Select all
]help bot_add
"bot_add"
game
- bot_add <t|ct> <type> <difficulty> <name> - Adds a bot matching the given criteria.
You could also create a bot with these two commands. After that you can switch them to the team you want.
Syntax: Select all
from engines.server import engine_server
engine_server.create_fake_client(<name>)
Syntax: Select all
from players.bot import bot_manager
bot_manager.create_bot(<name>)
nullable wrote:Ok. How about bot prefix?
If you're using CS:S (does not work in CS:GO AFAIK):
Code: Select all
"bot_prefix" = "" game replicated
- This string is prefixed to the name of all bots that join the game.
<difficulty> will be replaced with the bot's difficulty.
<weaponclass> will be replaced with the bot's desired weapon class.
<skill> will be replaced with a 0-100 representation of the bot's skill.
bot_prefix is hidden in CS:GO, but you can still get/set it using the ConVar class. However, BOT is automatically added to the beginning of the name/prefix. I would imagine there is a way to change it (with dynamic/virtual function hooking), but I'm not sure exactly how to accomplish this right now.
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
There is no way to remove the BOT prefix from the server since this is formatted client-side.And in the translation files you can find:The only way I could see of, would be to tell the clients that bots are real players (which will probably trick the master server and can get your IP banned from the research) but I don't think it worth it.
Code: Select all
// client.dll @ sub_103AE6C0
.text:103AE9BE mov esi, offset aSfui_bot_decor ; "#SFUI_bot_decorated_name"
Code: Select all
"SFUI_bot_decorated_name" "BOT %s1"
Hmm. When I try to add bot it added without problem but when called event player_connect I have error when I want to get index of player:
The trace is:
Syntax: Select all
def load():
bot_manager.create_bot('Cliffe')
@Event
def player_connect(game_event):
userid = game_event.get_int('userid')
name = game_event.get_string('name')
print('PLAYER_NAME:%s' % name)
index = index_from_userid(userid)
The trace is:
Syntax: Select all
index = index_from_userid(userid)
ValueError: Conversion failed...
Not at home, currently, so I can't check, but 'index' should be an event variable in player_connect. At least, I know it is in CS:S.
http://wiki.sourcepython.com/pages/Event-cstrike:player_connect
http://wiki.sourcepython.com/pages/Event-cstrike:player_connect
My guess is that since player_connect fires very early on, index_from_userid can't run. In general I prefer using player_activate, which fires later, typically when the player sees your motd.
However if you really want to use this event, this is better practice and solves your issue:
Edit: Oops, didn't notice Satoon's post, but he's right I tested it (in CS:S).
However if you really want to use this event, this is better practice and solves your issue:
Syntax: Select all
def load():
bot_manager.create_bot('Cliffe')
@Event
def player_connect(game_event):
name = game_event.get_string('name')
print('PLAYER_NAME:%s' % name)
index = game_event.get_int('index')
Edit: Oops, didn't notice Satoon's post, but he's right I tested it (in CS:S).
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 76 guests