Thy a lot for the explanation. and thy for linking the command module. It helped me a lot. :). Hope I bother you too much but could give any advice on how I can make a Player(Bot) throw a grenade. So far I can create a Player(Bot) and give it a Smoke and set it as the current weapon. The problem is now how the Player(Bot) can throw it. Here is the code that I have so far.
Code: Select all
@Event('player_say')
def on_player_say(event):
try:
for index in range(3, 25): # Start at 3 so that myself does get affected
player = Player.from_userid(index) # create player
player.set_team(2) # move player to terrorist team
player.client_command("give weapon_smokegrenade", True) # give the player a smoke grenade
player.client_command("use weapon_smokegrenade", True)
except Execption as e :
pass
I know this is bad coding practice to try and except all Exceptions but I don't know a way to get the current number of players on the server. So I simply iterate over it to a high amount where I am sure that it could access all Players(Bots).
I have tried 2 other Methods so far to control them. 1. use the bot manager and BotCmd. Using this method I can create a bot but nothing more I can create it but I can't do anything with it I always need to access it over the player "API" is another way to set the team and current weapon of a but then going the player rout? 2nd Method I could create a UserCmd object and set the "buttons" to "PlayerButtons.ATTACK" but I could not find a way to execute it as you do with the Botmanager.
The code for Method1:
Code: Select all
@Event('player_say')
def on_player_say(event):
edict = bot_manager.create_bot('Foo')
bcmd = BotCmd()
bcmd.buttons |= PlayerButtons.ATTACK
controller = bot_manager.get_bot_controller(edict)
controller.run_player_move(bcmd)
The code for Method2:
Code: Select all
@Event('player_say')
def on_player_say(event):
usercmd = UserCmd()
usercmd.buttons = PlayerButtons.ATTACK