Page 1 of 1

Giving player a weapon in cs:go

Posted: Sat Sep 08, 2018 12:40 pm
by velocity
How do I spawn a weapon and give it to a player in CS:GO, since Player.give_named_item('weapon_ak47') doesn't work. Should I be looking at Entity.create?

Re: Giving player a weapon in cs:go

Posted: Sat Sep 08, 2018 1:10 pm
by Kami
Hey, I'm not sure why give_named_item does not work for you but this worked for me:

Syntax: Select all

from players.entity import Player
from events import Event

@Event('player_say')
def _player_say(ev):
player = Player.from_userid(ev['userid'])
player.give_named_item("weapon_ak47")


Alternatively as you said Entity.create will do the trick too:

Syntax: Select all

from players.entity import Player
from events import Event
from entities.entity import Entity

@Event('player_say')
def _player_say(ev):
player = Player.from_userid(ev['userid'])
weapon = Entity.create("weapon_ak47")
weapon.spawn()
weapon.origin = player.origin


I'm testing on windows though, maybe the offsets for give_named_item are outdated on Linux (if you are on Linux)?

Re: Giving player a weapon in cs:go

Posted: Sat Sep 08, 2018 1:21 pm
by velocity
Okay it works now for some reason :/ meh, keep the thread open, so other people can see how to give a weapon anyways.