Blinding players and changing models

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Oct 07, 2014 11:13 pm

Notice on that same page that Edict.get_server_entity returns the entity's ServerEntity instance:
http://wiki.sourcepython.com/index.php/entities#get_server_entity

Also, you might try using the example I just posted in the News forums. However, once the entities_changes updates are finalized, you will also be able to use:

Syntax: Select all

from engines.precache import Model
from events import Event
from filters.players import PlayerIter

my_model = Model('models/characters/hostage_02.mdl')

@Event
def player_say(game_event):
for player in PlayerIter(return_types='player'):
start_color = player.color
player.set_model(my_model)
player.color = start_color

set_model will likely be added to the virtual_functions for CBaseEntity:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/entities_changes/addons/source-python/data/source-python/virtuals/cstrike/CBaseEntity.ini#L126

That offset will likely be used in this file:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/entities_changes/addons/source-python/data/source-python/entities/managers/engines/orangebox/CBaseEntity.ini
Image
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Wed Oct 08, 2014 1:35 am

Just a few hints about setting player's model. In your example, storing then reseting the color is useless. ServerEntity.set_model_index won't mess with the color. From what I remember, the following won't mess the color:

Syntax: Select all

ServerEntity.set_model_index(modelindex)
Edict.set_key_value_int('modelindex', modelindex)
While the following will:

Syntax: Select all

Edict.set_prop_int('m_nModelIndex', modelindex)
From what I know, this is caused by forcing the value then calling Edict.state_changed and ignoring that call, won't update the player's model. However, you also need to set m_ModelName otherwise the model's path of the player will stay the old one.

Syntax: Select all

Edict.set_key_value_string('model', model)
The best way to achieve that is surely to call CBaseEntity::SetModel since this will internally call UTIL_SetModel which will take care to, set m_nModelIndex, set m_ModelName and also update m_vecMins/Maxs based on the given model size.
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Oct 08, 2014 1:51 am

Yeah, I was going off of playerlib's setModel function as to setting the player's color. It sets the m_nModelIndex property. One issue I notice with using the string path is that it never calls the index property to precache the model. We will need to work on setting up a system that allows passing the path instead of the index that also takes care of precaching.
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 129 guests