Page 1 of 1
HL2DM custom bot weapons
Posted: Thu Apr 20, 2023 5:02 pm
by daren adler
Hello script writers

I am using HRC (hurricane bots) and would like a script that would let the bots use custom weapons. The weapons are weapon_ak47, weapon_alyxgun, weapon_mp5, weapon_oicw, weapon_sniper. The bots only seem right now able to use just the normal (stock) weapons, Could someone on here help me out on this, thank you.

Re: HL2DM custom bot weapons
Posted: Thu Apr 20, 2023 5:21 pm
by cssbestrpg
Hi, do you mean that bots would spawn with the random custom weapons?
Re: HL2DM custom bot weapons
Posted: Thu Apr 20, 2023 5:25 pm
by daren adler
cssbestrpg wrote:Hi, do you mean that bots would spawn with the random custom weapons?
Yes, i use sourcemod hl2dm customguns script. The bots will only spawn with the normal weapons.
Re: HL2DM custom bot weapons
Posted: Thu Apr 20, 2023 5:26 pm
by cssbestrpg
try this code(Untested) then:
Syntax: Select all
import random
from events import Event
from players.entity import Player
custom_weapons = ['weapon_ak47', 'weapon_alyxgun', 'weapon_mp5', 'weapon_oicw', 'weapon_sniper']
@Event('player_spawn')
def player_spawn(args):
player = Player.from_userid(args['userid'])
if not player.is_bot():
return
primary = player.primary
if not primary is None:
primary.remove()
weapon_to_give = random.choice(custom_weapons)
player.give_named_item(f'{weapon_to_give}')
Re: HL2DM custom bot weapons
Posted: Thu Apr 20, 2023 5:29 pm
by daren adler
Ok will do,, here is where i had a scripter write one for me but without custom weapons
https://forums.sourcepython.com/viewtopic.php?f=37&t=2521
Re: HL2DM custom bot weapons
Posted: Thu Apr 20, 2023 5:58 pm
by daren adler
Update,,,,,Nope does not seem to work,,does not give any errors in log,,,says it loaded, but does nothing, thank you for trying, thses bots do not like custom made weapons i guess lol, ty.
Re: HL2DM custom bot weapons
Posted: Thu Apr 20, 2023 6:01 pm
by cssbestrpg
I guess i need to use different method like the other tread where Kami made a code for random weapons for bots
Edit:
Here is code for other method to give the weapons:
Syntax: Select all
import random
from events import Event
from engines.server import queue_command_string
custom_weapons = ['ak47', 'alyxgun', 'mp5', 'oicw', 'sniper']
@Event('player_spawn')
def player_spawn(args):
player = Player.from_userid(args['userid'])
primary = player.primary
if not primary is None:
primary.remove()
weapon_to_give = random.choice(custom_weapons)
queue_command_string(f'hrcbot_player_spawnweapon {weapon_to_give}')
Re: HL2DM custom bot weapons
Posted: Thu Apr 20, 2023 7:18 pm
by daren adler
cssbestrpg wrote:I guess i need to use different method like the other tread where Kami made a code for random weapons for bots
Edit:
Here is code for other method to give the weapons:
Syntax: Select all
import random
from events import Event
from engines.server import queue_command_string
custom_weapons = ['ak47', 'alyxgun', 'mp5', 'oicw', 'sniper']
@Event('player_spawn')
def player_spawn(args):
player = Player.from_userid(args['userid'])
primary = player.primary
if not primary is None:
primary.remove()
weapon_to_give = random.choice(custom_weapons)
queue_command_string(f'hrcbot_player_spawnweapon {weapon_to_give}')
Nope same as before. i think its the bots, not your fault, thanks for trying tho, I did see i am not updated with the sourcepython,,so before i can say it all does not work,,let me update and get back to ya.