about hooking speed..
#1

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.
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)