Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from listeners import OnEntitySpawned
- from filters.entities import EntityIter
- from entities.entity import Entity
- from entities.constants import EntityEffects
- from entities import CheckTransmitInfo
- from entities.entity import BaseEntity
- from memory import make_object
- from memory.hooks import PreHook
- from entities.helpers import index_from_edict
- TRIGGER_START = 'trigger_'
- def on_trigger_transmit(trigger, classname, index):
- """Called when a trigger should be transmitted.
- :param BaseEntity trigger:
- The trigger that should be transmitted to the client.
- :param str classname:
- The classname of the trigger to transmit (e.g. ``trigger_multiple``).
- The value equals ``trigger.classname``.
- :param int index:
- The index of the player who should receive the data of the trigger.
- :return:
- Return ``True`` if the trigger should be transmitted. Return ``False``
- if it shouldn't be transmitted (it will be invisible to the client).
- :rtype: bool
- """
- return True
- def show_entity(entity):
- entity.edict.clear_transmit_state()
- entity.effects &= ~EntityEffects.NODRAW
- # We can use the worldspawn entity, because it's using
- # CBaseEntity::SetTransmit just like all triggers
- @PreHook(Entity(0).set_transmit)
- def pre_set_transmit(args):
- entity = make_object(BaseEntity, args[0])
- classname = entity.classname
- if not classname.startswith(TRIGGER_START):
- return
- info = make_object(CheckTransmitInfo, args[1])
- index = index_from_edict(info.client)
- if not on_trigger_transmit(entity, classname, index):
- return False
- @OnEntitySpawned
- def on_entity_spawned(base_entity):
- if base_entity.classname.startswith(TRIGGER_START):
- show_entity(Entity(base_entity.index))
- for trigger in EntityIter(TRIGGER_START, False):
- show_entity(trigger)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement