![Smile :smile:](./images/smilies/smile.png)
![Embarrassment :embarrassed:](./images/smilies/redface.png)
cssbestrpg wrote:Hi, do you mean that bots would spawn with the random custom weapons?
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}')
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.daren adler wrote: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
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}')
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}')
Users browsing this forum: No registered users and 46 guests