SetTransmit on entities

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

SetTransmit on entities

Postby velocity » Mon Nov 19, 2018 2:32 am

I'm using the code snippet from IPlayer, thanks btw, so I want to hide/unhide specific entities, such as func_wall_toggle and others, but set_transmit doesn't include these entities? I know from SourceMod that you can hook specific entities to transmit.

I only get classname outputs limited to - func_brush, player, func_breakable and some others.


Syntax: Select all

@EntityPreHook(EntityCondition.is_not_player, '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))
if entity.classname != "func_wall_toggle":
return


# 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
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: SetTransmit on entities

Postby L'In20Cible » Mon Nov 19, 2018 3:00 am

SetTransmit is virtual, meaning that every classes can implement their own. If you are using is_not_player as condition, the very first entity that match that criteria will see its function retrieved and hooked from its dispatch table. You most likely want to explicitly ask for that entity here, otherwise there is no guarantee which one you are hooking (or which entities use the very first match):

Syntax: Select all

@EntityPreHook(EntityCondition.equals_entity_classname('func_wall_toggle'), 'set_transmit')
def pre_set_transmit(args):
...
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Mon Nov 19, 2018 3:10 am

I tried that, it doesn't work.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: SetTransmit on entities

Postby Ayuto » Mon Nov 19, 2018 6:31 am

I guess it's the same reason why triggers aren't shown. This code allows to make triggers visible:


If you adapt it, you should also be able to make other entities visible.
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Mon Nov 19, 2018 2:05 pm

Yeah this works, but I'm not enable to collide with the entities that are being shown, which is important, except func_breakable.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: SetTransmit on entities

Postby Ayuto » Mon Nov 19, 2018 3:27 pm

I don't quite understand what you mean. Making entities visible/invisible has nothing to do with colliding.
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Mon Nov 19, 2018 11:46 pm

The solution was to change the solid flags, but I got another issue, Set_Transmit crashes the server on some maps? I've noticed that in some maps cannot convert Index(0) to BaseEntity

This code crashes on some maps:

Syntax: Select all

@PreHook(Entity(0).set_transmit)
def pre_set_transmit(args):
pass


Edit:
I have tested other entity conditions for the set_transmit they ALL appear to crash on some maps. If you want to test yourself trikz_advanced_csgo it crashes on.
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Tue Nov 20, 2018 8:59 pm

Okay I literally unloaded everything, made a new file called transmit.py with the only following code

Syntax: Select all

@EntityPreHook(EntityCondition.is_not_player, 'set_transmit')
def pre_set_transmit(args):
entity = make_object(BaseEntity, 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


It doesn't matter what EntityCondition is or if I use PreHook instead of EntityPreHook AND it does not matter what is inside the transmit function as long as transmit is hooked. This code crashes my server in many maps, a few maps do work, but I think there must be something wrong with PreHook.

Example map that crashes: trikz_advanced_csgo
Download: https://gamebanana.com/maps/170864

This is on Linux btw.

Edit:
I have opened a issue for this, I hope it doesn't feel like a "duplicate", since I already posted here:
https://github.com/Source-Python-Dev-Te ... issues/264
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: SetTransmit on entities

Postby satoon101 » Tue Nov 20, 2018 10:12 pm

velocity wrote:I hope it doesn't feel like a "duplicate", since I already posted here

We definitely prefer to track issues on GitHub, so thank you for opening it up there. It's fine that you happened upon this during a forum thread and it exists in both places. We'll handle the issue on GitHub and this thread can handle all other info related to its topic.
Image
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Wed Nov 21, 2018 11:59 pm

Is it possible to get the signature for set_transmit?
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Sun Jan 13, 2019 2:24 am

Any progress?
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Sun Jan 13, 2019 1:35 pm

What does entity.edict.clear_transmit_state() do?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: SetTransmit on entities

Postby Ayuto » Sun Jan 13, 2019 1:46 pm

No progress has been made. Sorry!

clear_transmit_state() removes some flags from the edict:
https://github.com/alliedmodders/hl2sdk ... ict.h#L353
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Sun Jan 13, 2019 4:50 pm

Do you think there is another way of finding the func_wall_toggle with set_transmit than setting transmit to the world_entity?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: SetTransmit on entities

Postby Ayuto » Sun Jan 13, 2019 5:46 pm

You could use the effects module to draw a box around its corners.
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Sun Jan 13, 2019 6:19 pm

I'm not sure what you mean, also I noticed that this code snippet makes server lag when there are too many people. I wonder if there is another way to get the entity besides baseentity_from_pointer (which is even worse).

Syntax: Select all

@EntityPreHook(EntityCondition.equals_entity_classname("worldspawn"), "set_transmit")
def pre_set_transmit(args):
entity = make_object(BaseEntity, args[0])



Edit (nothing related):
In CBaseEntity.ini (csgo) there is missing an argument and return_type:

# _ZN11CBaseEntity11SetTransmitEP18CCheckTransmitInfob
[[set_transmit]]
offset_linux = 24
offset_windows = 23
arguments = POINTER, POINTER, BOOL
return_type = BOOL
Last edited by velocity on Wed Jan 16, 2019 2:05 am, edited 2 times in total.
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Wed Jan 16, 2019 2:02 am

Is it possible that make_object can be optimized because I'm getting lag issues with it when too many people in set_transmit. And yes, I have double checked that it is exactly that that causes it. Please help.

User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: SetTransmit on entities

Postby L'In20Cible » Wed Jan 16, 2019 4:49 am

velocity wrote:Edit (nothing related):
In CBaseEntity.ini (csgo) there is missing an argument and return_type:

# _ZN11CBaseEntity11SetTransmitEP18CCheckTransmitInfob
[[set_transmit]]
offset_linux = 24
offset_windows = 23
arguments = POINTER, POINTER, BOOL
return_type = BOOL

No, the data is correct. The TypeManager class handle the this pointer behind the scenes for virtual methods and that particular method doesn't return anything. If you edited your data to add an extra parameter and a return value, this can certainly be the cause of the crashes your are encountering.
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: SetTransmit on entities

Postby velocity » Wed Jan 16, 2019 12:32 pm

Alright, I didn't know. (I did not edit it before confirmation from you guys), but I still have a lag issue :/
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: SetTransmit on entities

Postby L'In20Cible » Wed Jan 16, 2019 1:55 pm

velocity wrote:Alright, I didn't know. (I did not edit it before confirmation from you guys), but I still have a lag issue :/

I've made some tests and while acceptable, make_object is indeed a bit slow. For 1 million iterations:

Code: Select all

1.4670946598052979

I suspect this is caused by MakeObject and then ExtractPointer both iterating through the entire tp_dict via PyObject_HasAttrString. I believe using a try/except in both cases could potentially speed things up a little bit since this means we do the check and the retrieval at the same time instead of doing so separately but I have yet to test further. That being said, since you already know you have a Pointer instance, you could use the following instead:

Syntax: Select all

entity = BaseEntity._obj(args[0])

Which would removes all the extra sanity checks done by make_object. For 1 million iterations:

Code: Select all

0.32916712760925293

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 25 guests