HL2DM Changing weapon model not working

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

HL2DM Changing weapon model not working

Postby Kami » Fri Feb 10, 2017 9:15 pm

Hey guys,

it seems that in HL2DM I am not able to change the model of a weapon I just spawned. I've tried it with this code:

Syntax: Select all

from players.entity import Player
from events import Event
from engines.precache import Model
from entities.entity import Entity


@Event('player_say')
def say(ev):
player = Player.from_userid(ev['userid'])
ent = Entity.create("weapon_crossbow")
ent.model = Model("models/crow.mdl")
ent.origin = player.view_coordinates
ent.spawn()



I also tried to first spawn it and then set the model which had the same result.

I'd be happy about any ideas :)
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: HL2DM Changing weapon model not working

Postby L'In20Cible » Sat Feb 11, 2017 7:19 am

If I remember right, you cannot set the model prior the weapon being physically spawned (the engine lookup the model from the scripts) and that changing m_szModelName/m_nModelIndex (properties wrapped by Entity.model) won't affect its rendering once spawned. I think the following should works:

Syntax: Select all

ent.spawn()
ent.set_property_int('m_iWorldModelIndex', Model('models/crow.mdl').index)
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: HL2DM Changing weapon model not working

Postby Kami » Sat Feb 11, 2017 9:20 am

And it it's working :D Thank you very much!

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 43 guests