is it possible to tell a client to render a model on a networked entity after precaching the path by the index only?
"ent.model_index" -> doesnt work
"ent.model_path" -> does work
spawn entity with index only
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: spawn entity with index only
I'm not sure to understand your question. You want to set the model of an entity from an index?
Re: spawn entity with index only
i am wondering why it isnt possible to set a model by ent.modelindex only in my posted situation. while ent.modelpath works. but my fear is that setting the path makes sp send the client the whole string via network? shouldnt setting .modelindex suffice in my case? its actually a question if sp is able to handle it..
Re: spawn entity with index only
but it might just be that the server always uses sendtables to handle edict traffic...which would leave no option for sp to make it more efficient... but maybe sp could make it easier on the script-end by letting users set the model_index only and then internally create the sendtable from looking up the path in preache... but i havent looked into it really
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: spawn entity with index only
That is not how it works. The entity itself doesn't network the model name to clients (m_szModelName is not networkable while m_nModelIndex is). But the entity creation needs the model name to instantiate the entity (for debugging if you try to set a static model to a physic entity, etc.) and is responsible to internally set the model index. The indexes are only the slot of the strings in the precache tables. If you only have an index, you can retrieve the name. For example:
In short, this is not related to "can SP handle it", this is how the engine works; you need a model name to create an entity.
Syntax: Select all
from engines.precache import Model
from stringtables import string_tables
ent.model = Model(string_tables[Model.precache_table][index])
In short, this is not related to "can SP handle it", this is how the engine works; you need a model name to create an entity.
Re: spawn entity with index only
i dont really get what you are trying to say... my question is if/why sp cant handle setting ent.model_index only.. i only explained it to hlep you understand my question better. sp could easily retrieve the modelpath from the preache table by index only and then send a working sendtable at ent.spawn()
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: spawn entity with index only
Entity.model_name and Entity.model_index are wrapping existing properties/keyvalues of the entity itself and I don't believe it to be our role to override them to allow different types (would add unnecessary isinstance checkings). We already added an Entity.model property to make it easier to set a model (it internally set the model_name and the model_index based on the given Model instance). Though, we could certainly allow the Model class to accept either a path or an index, but I'm really unsure if it worth it. Majority of cases, users have a model path, and if they want to set a model by its index, they already have the possibility to extract the path themselve.
Return to “Plugin Development Support”
Who is online
Users browsing this forum: Bing [Bot] and 78 guests