Raised This Month: $ Target: $400
 0% 

Optimizing question.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-03-2010 , 13:06   Optimizing question.
Reply With Quote #1

I have to hook the use of a single func_button, depending on the targetname.
It is possible that the button doesn't exist though.
So i was wondering what's the best way to hook it.

1. Hook Ham_Use and check if it's the right button there.
2. Loop through all entities at plugin_init() and use RegisterHamFromEntity.


Ofcourse you can post another method if it's better then my 2 idea's.


EDIT: And if i hook the button in pre and return HAM_SUPERCEDE, will that block the button to activate the stuff that it's supposed to do ?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 12-03-2010 at 13:09.
drekes is offline
Send a message via MSN to drekes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-03-2010 , 13:13   Re: Optimizing question.
Reply With Quote #2

RegisterHamFromEntity registers the function for a class, so it will register for all fun_button.
So, loop through all func_button, if the button is found, cache its index in a global var and register Ham_Use, "func_button", and in the callback compare the entity index.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-03-2010 , 13:16   Re: Optimizing question.
Reply With Quote #3

Cool, thanks ConnorMcLeod.
What about SUPERCEDE, will it block the button from being used ?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
TheKidz
Senior Member
Join Date: May 2009
Old 12-03-2010 , 21:32   Re: Optimizing question.
Reply With Quote #4

returning HAM_SUPERCEDE here
PHP Code:
RegisterHamHam_Use"func_button""Button_Push_Pre" 
should be fine. i got a plugin doing this and no problem ;)
__________________
TheKidz is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-04-2010 , 14:58   Re: Optimizing question.
Reply With Quote #5

Okay, Thanks for your help.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
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 11:18.


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