what is a EntityPostHook

General discussion for off-topic subjects.
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

what is a EntityPostHook

Postby D3CEPTION » Sat Feb 04, 2017 12:39 pm

what exactly can be done in a EntityPostHook/TempEntityPostHook?

because shouldnt the memory be locked at that point?
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: what is a EntityPostHook

Postby Ayuto » Sat Feb 04, 2017 1:37 pm

Post hooks are getting called after the hooked function has been executed, but before it returns to the caller. That allows for example reading and modifying the return value of the hooked function.

Entity<type>Hook is basically just a helper to hook functions on entities. TempEntity<type>Hook hooks the Create method of temporary entities (effect entities). Thus, it allows you to do stuff right before a temp entity has been created and right after it has been created.

What exactly do you mean with the memory being locked?
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: what is a EntityPostHook

Postby D3CEPTION » Sat Feb 04, 2017 5:19 pm

thanks. that underlines the temporal meaning of pre/post.

but where is the technical use of post hooking in tempentites.create()? and shouldnt the method here better be called .send() ? what can be done in or more specific WITH the posthook here, that cant be done in a prehook already or simply by adding custom code to the next line in the pythoncode?

i imagine the whole process for a tempentity sthn like this :
load te template ,create sendtable, create recipient object, PREHOOK send client netchannel POSTHOOK.

with memory locked i meant, that in my described scheme, there shouldnt be any more access in the posthook to modify the sendtable,template or recipiend object, after it has been sent. only the prehook can access these objects. at least thats what i would imagine. but when i try to test these assumptions i always get unicode decoding error when accessing the tempentity in a POSTHOOK. does it work for you?
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: what is a EntityPostHook

Postby Ayuto » Sat Feb 04, 2017 7:07 pm

D3CEPTION wrote:but where is the technical use of post hooking in tempentites.create()? and shouldnt the method here better be called .send() ? what can be done in or more specific WITH the posthook here, that cant be done in a prehook already or simply by adding custom code to the next line in the pythoncode?
I don't have a specific use case for you, because I never used it before. It's called "create", because it's leant on the engine's name.

D3CEPTION wrote:with memory locked i meant, that in my described scheme, there shouldnt be any more access in the posthook to modify the sendtable,template or recipiend object, after it has been sent. only the prehook can access these objects. at least thats what i would imagine. but when i try to test these assumptions i always get unicode decoding error when accessing the tempentity in a POSTHOOK. does it work for you?

Since a delay can be passed to the "Create" method, you might still be able to modify the temp entity in a post hook.

If you want me to test anything, please provide the output of "sp info" and copy and paste-able code that reproduces the error you are facing.

Return to “Whatever”

Who is online

Users browsing this forum: No registered users and 14 guests