Spawned weapons do not function correctly.

All other Source.Python topics and issues.
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Spawned weapons do not function correctly.

Postby Predz » Tue May 16, 2017 2:27 pm

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
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Spawned weapons do not function correctly.

Postby L'In20Cible » Tue May 16, 2017 3:44 pm

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.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Spawned weapons do not function correctly.

Postby Ayuto » Tue May 16, 2017 3:51 pm

Just a blind guess, but in CS:GO you might have to set item_definition_index to make the weapons work correctly.
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Re: Spawned weapons do not function correctly.

Postby Predz » Tue May 16, 2017 4:11 pm

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?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Spawned weapons do not function correctly.

Postby satoon101 » Tue May 16, 2017 4:33 pm

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
Image
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Spawned weapons do not function correctly.

Postby satoon101 » Wed May 17, 2017 1:13 am

Oh, I see what happened, that's a bug. That will be fixed in the next build.
Image

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 40 guests