Raised This Month: $51 Target: $400
 12% 

How to hook on late load? [Solved]


Post New Thread Reply   
 
Thread Tools Display Modes
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 01-26-2015 , 03:36   Re: How to hook on late load? [Solved]
Reply With Quote #11

Oh yeah... I guess since many plugins also hook players when they connect, it seems like you can't "stack hooks".

In which case... perhaps stuff like OnTakeDamage can just be hooked for all clients during OnMapStart?
__________________
Chdata is offline
psychonic

BAFFLED
Join Date: May 2008
Old 01-26-2015 , 07:31   Re: How to hook on late load? [Solved]
Reply With Quote #12

Quote:
Originally Posted by Chdata View Post
That's correct for a different reason. You don't need to unhook when a client disconnects from the server.

I'm not sure exactly why though. It's either because you can't hook something twice (which I doubt, you probably actually can and have double repeating code), or because client entities don't actually get "killed" or "removed" - at least that's my theory as I don't know - that when someone connects his control is exerted on an existing player entity that's being unused.


Or maybe SM does unhook clients on disconnect, who knows.
Quote:
Originally Posted by Dr. Greg House View Post
I have seen many plugins hook stuff on player spawn. Now I'm wondering how long these hooks stay active. And if hooktype + entindex + callback-address is unique so that it wouldn't be hooked or called multiple times.
Quote:
Originally Posted by Chdata View Post
Oh yeah... I guess since many plugins also hook players when they connect, it seems like you can't "stack hooks".

In which case... perhaps stuff like OnTakeDamage can just be hooked for all clients during OnMapStart?
I'm not sure where the confusion is coming from. Hooks are automatically removed upon entity removal or client disconnect, and have been that way since long before SDKHooks was shipped with SM. Hooks are active until this point or until manually removed.

You can add multiple hooks of the same type to an entity, to different callbacks or to the same callback. There are no restrictions at all on that.
psychonic is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 01-26-2015 , 12:43   Re: How to hook on late load? [Solved]
Reply With Quote #13

Quote:
Originally Posted by psychonic View Post
I'm not sure where the confusion is coming from. Hooks are automatically removed upon entity removal or client disconnect, and have been that way since long before SDKHooks was shipped with SM. Hooks are active until this point or until manually removed.

You can add multiple hooks of the same type to an entity, to different callbacks or to the same callback. There are no restrictions at all on that.
Might seem ignorant to ask this but what's the point of the unhook function if that's the case? Is it so you can create new hooks with the same entities?
Drixevel is offline
psychonic

BAFFLED
Join Date: May 2008
Old 01-26-2015 , 12:49   Re: How to hook on late load? [Solved]
Reply With Quote #14

Quote:
Originally Posted by r3dw3r3w0lf View Post
Might seem ignorant to ask this but what's the point of the unhook function if that's the case? Is it so you can create new hooks with the same entities?
It exists for the same reason that UnhookEvent, UnhookUserMessage, and UnhookConVarChange exist - to easily disable certain functionality when it is no longer needed. Granted, those would be things that normally unhook on plugin unload rather than entity destruction, but it's the same premise.
psychonic is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 01-26-2015 , 14:40   Re: How to hook on late load? [Solved]
Reply With Quote #15

Quote:
Originally Posted by psychonic View Post
I'm not sure where the confusion is coming from. Hooks are automatically removed upon entity removal or client disconnect, and have been that way since long before SDKHooks was shipped with SM. Hooks are active until this point or until manually removed.

You can add multiple hooks of the same type to an entity, to different callbacks or to the same callback. There are no restrictions at all on that.
It's because where the heck is there any documentation on this.

sdkhooks.inc isn't very descriptive, and the API doesn't say that
__________________

Last edited by Chdata; 01-26-2015 at 14:45.
Chdata is offline
psychonic

BAFFLED
Join Date: May 2008
Old 01-26-2015 , 14:50   Re: How to hook on late load? [Solved]
Reply With Quote #16

Quote:
Originally Posted by Chdata View Post
It's because where the heck is there any documentation on this.

sdkhooks.inc isn't very descriptive, and the API doesn't say that
There is definitely room for improvement with the documentation.

Wiki contributions and pull requests for the includes are welcome.
psychonic is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-26-2015 , 14:52   Re: How to hook on late load? [Solved]
Reply With Quote #17

Quote:
Originally Posted by r3dw3r3w0lf View Post
Might seem ignorant to ask this but what's the point of the unhook function if that's the case? Is it so you can create new hooks with the same entities?
Just for an example if you have a cvar that enable and disable the plugin dynamically, you can had a cvar hook change and unhook your sdkhooks or hook depending on the toggle without having the plugin unload. In some cases you would just want to hook a player for a round or something.
Mathias. is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 01-26-2015 , 14:57   Re: How to hook on late load? [Solved]
Reply With Quote #18

I'd probably contribute if I didn't feel like a noooooooooooooooooooooooob

I also still have no clue how KillTimer and CloseHandle are functionally different.
__________________

Last edited by Chdata; 01-26-2015 at 14:58.
Chdata is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-26-2015 , 14:59   Re: How to hook on late load? [Solved]
Reply With Quote #19

Quote:
Originally Posted by Chdata View Post
I'd probably contribute if I didn't feel like a noooooooooooooooooooooooob

I also still have no clue how KillTimer and CloseHandle are functionally different.
What do you mean? Your 2 OP with those mario world assembly modifications you are doing!

Last edited by Mathias.; 01-26-2015 at 14:59.
Mathias. is offline
psychonic

BAFFLED
Join Date: May 2008
Old 01-26-2015 , 15:08   Re: How to hook on late load? [Solved]
Reply With Quote #20

Quote:
Originally Posted by Chdata View Post
I also still have no clue how KillTimer and CloseHandle are functionally different.
There is no functional difference.
psychonic is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode