Page 1 of 1

HL2DM Changing weapon model not working

Posted: Fri Feb 10, 2017 9:15 pm
by Kami
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 :)

Re: HL2DM Changing weapon model not working

Posted: Sat Feb 11, 2017 7:19 am
by L'In20Cible
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)

Re: HL2DM Changing weapon model not working

Posted: Sat Feb 11, 2017 9:20 am
by Kami
And it it's working :D Thank you very much!