SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 06/03/2016, 01:52 PM   #1
iLuXing
Big Clucker
 
Join Date: Oct 2014
Posts: 56
Reputation: 5
Exclamation about hooking speed..

as a modular programmer, I use hook erverywhere, but something still confused me. speed.
before use a hook, my callback just like this:

Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
	switch(dialogid) {
		case DIALOG_ID_A : return RE_DIALOG_A(playerid, response, listitem, inputtext);
		case DIALOG_ID_B : return RE_DIALOG_B(playerid, response, listitem, inputtext);
		case DIALOG_ID_C : return RE_DIALOG_C(playerid, response, listitem, inputtext);
		case DIALOG_ID_D : return RE_DIALOG_D(playerid, response, listitem, inputtext);
		case DIALOG_ID_E : return RE_DIALOG_E(playerid, response, listitem, inputtext);
		case DIALOG_ID_F : return RE_DIALOG_F(playerid, response, listitem, inputtext);
	}
	return 1;
}
if player response a dialog, the callback match one condition and return.
now, we use hook and it will run every hook callback.
if I hooked 100 times of this callback, it will just loop 100 times.

so, I cant think a method to resolve this problem.
how you guys code with hook?
plz tell me a proper way.
iLuXing is offline   Reply With Quote
Old 17/03/2016, 05:27 PM   #2
Hiddos
High-roller
 
Hiddos's Avatar
 
Join Date: Sep 2008
Posts: 3,306
Reputation: 2184
Default Re: about hooking speed..

I don't entirely get what you mean. Hooks are used so that an include file can access a callback without interfering with the rest of the script. If you hook a callback one hundred times, it will execute every single hook once and move on to the next one. Your code will not loop, it will execute every hook once. If your concern having to call a lot of hooks/functions for just one callback; I don't expect that specifically to increase execution time. What you do inside your code is way more important.
__________________
Quote:
Originally Posted by DeWolf View Post
For fuck's sake people, this whole thread is fucked up now.
Hiddos is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hooking OnPlayerConnect dominik523 Scripting Help 0 24/02/2014 11:35 AM
Hooking (ALS) CreativityLacker Scripting Help 9 02/06/2013 05:49 PM
Hooking! gert232 Scripting Help 4 22/08/2012 09:07 PM
Hooking OnPlayerClickPlayerTextDraw SuperViper Scripting Help 1 05/05/2012 07:08 PM


All times are GMT. The time now is 07:31 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.