Hey, guys.
I'm wondering if they is a possibility with source python to spawn a player model (not bot or player themselves) that:
1. has a specific amount of transparency
2. has an action activated on "e"
[CSGO] Transparent character with action on "e"
Re: [CSGO] Transparent character with action on "e"
Give this a shot: There seems to be an issue with getting the correct activator (the player that pressed +USE on the model). Both the activator and the caller appear to be the same entity, the prop_physics_override in this case. Feels like a bug in the engine rather than SP.
Syntax: Select all
# ../transparent_model/transparent_model.py
# Source.Python
from colors import Color
from commands import CommandReturn
from commands.client import ClientCommand
from entities.constants import RenderMode, SolidType
from entities.entity import Entity
from listeners import OnEntityOutput, OnEntityDeleted
from players.dictionary import PlayerDictionary
model_instances = {}
player_instances = PlayerDictionary()
@OnEntityOutput
def on_entity_output(output_name, activator, caller, value, delay):
if 'OnPlayerUse' != output_name:
return
# Don't go further if this isn't one of our models.
if caller.index not in model_instances:
return
print(f'Someone touched the model! [index: {caller.index}]')
def create_model(origin, model, alpha=255):
# We need to use a 'prop_physics_override' to be able to hook when someone
# presses +USE on the prop/model.
prop = Entity.create('prop_physics_override')
prop.model = model
# Set certain spawn flags for the entity.
# 8: Freeze the entity in place.
# 256: Generate output on +USE.
prop.spawn_flags = 8 + 256
# Enable transparency of the model.
prop.render_mode = RenderMode.TRANS_ALPHA
# Change the transparency.
prop.render_color = Color(255, 255, 255, alpha)
prop.spawn()
# Make sure the 'prop_physics_override' uses its bounding box for collision.
# This is a fix for player models. Without this you'd have to aim at the
# model's feet to trigger the output.
prop.solid_type = SolidType.BBOX
prop.teleport(origin, None, None)
# Add the 'prop_physics_override' instance to a dictionary.
model_instances[prop.index] = prop
return prop
@ClientCommand('create_transparent_model')
def create_transparent_model_command(command, index):
player = player_instances[index]
create_model(origin=player.view_coordinates, model=player.model, alpha=190)
return CommandReturn.BLOCK
@OnEntityDeleted
def on_entity_deleted(base_entity):
try:
index = base_entity.index
except ValueError:
return
if index in model_instances:
del model_instances[index]
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 123 guests