Syntax: Select all
from entities import CheckTransmitInfo
from entities.entity import Entity
from entities.helpers import index_from_edict
from entities.hooks import EntityCondition, EntityPreHook
from memory import make_object
from players.entity import Player
def transmit_filter(entity, player):
if player.name != "iPlayer":
return True
if entity.classname != "prop_physics_multiplayer":
return True
return False
# You can define your own entity_condition function that should return
# True for entities whose SetTransmit method we want to hook
entity_condition = EntityCondition.equals_entity_classname(
"prop_physics_multiplayer")
@EntityPreHook(entity_condition, 'set_transmit')
def pre_set_transmit(args):
entity = make_object(Entity, args[0])
edict = make_object(CheckTransmitInfo, args[1]).client
player = Player(index_from_edict(edict))
# We always transmit the player to himself. If we don't, bad things happen.
if player.index == entity.index:
return None
return None if transmit_filter(entity, player) else False
Things to change:
Syntax: Select all
def transmit_filter(entity, player):
if player.name != "iPlayer":
return True
if entity.classname != "prop_physics_multiplayer":
return True
return False
This filter receives two arguments: entity for transmission and the player to transmit this entity to. If transmission should happen, filter must return True, otherwise False.
Syntax: Select all
entity_condition = EntityCondition.equals_entity_classname(
"prop_physics_multiplayer")
Basically, entity_condition is a function that receives an Entity instance and returns True if that's the entity we want to set the hook on. Different entity classes have different SetTransmit methods, so if we set the hook on CBaseCombatCharacter::SetTransmit, transmitting of the CSprite won't get hooked.
If you want to hook player transmission (e.g. make certain players invisible to some other players), you can go with
Syntax: Select all
entity_condition = EntityCondition.is_player
Reference for the first argument SetTransmit receives:
https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/public/iservernetworkable.h#L37
This example has been written after I found the snippet of SM code provided by Bristwex
Syntax: Select all
SDKHook(entity, SDKHook_SetTransmit, Hook_SetTransmit);
public Action:Hook_SetTransmit(entity, client)
{
if (<entity and client checks>)
{
return Plugin_Continue;
}
return Plugin_Handled;
}