Page 1 of 1

Spawned weapons do not function correctly.

Posted: Tue May 16, 2017 2:27 pm
by Predz
I have noticed in the recent update that spawning a weapon into the world will cause some crazy behaviour... All weapons sound like deagle shots, and they always have max ammo and no extended clips. They also are classed as knives according to the overlays :confused:

This has confused me to every extent xD

Test code below:

Syntax: Select all

from commands.say import SayCommand
from entities.entity import Entity
from players.entity import Player

@SayCommand('test')
def _on_say(command, index, team):
player = Player(index)

weapon = Entity.create('weapon_ak47')
weapon.origin = player.view_coordinates
weapon.spawn()


Picture from the retarded "Knife"
Image

Re: Spawned weapons do not function correctly.

Posted: Tue May 16, 2017 3:44 pm
by L'In20Cible
It probably requires more work than just setting the origin of the weapon entity. Try to use Player.give_named_item or looking into CreateEntityByName into IDA to see what else you need to do to create a weapon from scratch.

Re: Spawned weapons do not function correctly.

Posted: Tue May 16, 2017 3:51 pm
by Ayuto
Just a blind guess, but in CS:GO you might have to set item_definition_index to make the weapons work correctly.

Re: Spawned weapons do not function correctly.

Posted: Tue May 16, 2017 4:11 pm
by Predz
Ayuto wrote:Just a blind guess, but in CS:GO you might have to set item_definition_index to make the weapons work correctly.


Yep, indeed that fixes it! For some reason they use this index to handle weapon sounds, and recoil patterns. It is quite funny to see a AK47 with an AWPs recoil tho xD

Here are all the definition indexes: https://github.com/Andersso/SM-WeaponModels
I am not to sure if these are all up to date though. Do you think we should include this information in SP?

Re: Spawned weapons do not function correctly.

Posted: Tue May 16, 2017 4:33 pm
by satoon101
We already do. I'm not sure why it isn't already working for you:
https://github.com/Source-Python-Dev-Te ... sgo.py#L37

Re: Spawned weapons do not function correctly.

Posted: Wed May 17, 2017 1:13 am
by satoon101
Oh, I see what happened, that's a bug. That will be fixed in the next build.