mHooks - Esay hooking callback and public functions! -
RCON1 - 11.01.2015
mHooks - Esay hooking callback and public functions!
mHooks simple system hooks do not have to use a dozen lines of code to do the Hook of one LINIK now!
How does it look? very simple
Код:
public OnFilterScriptInit()
{
printf("OnFilterScriptInit");
return 1;
}
HOOK:test.OnFilterScriptInit()
{
printf("test hook OnFilterScriptInit");
return 1;
}
I already have the OnFilterScriptInit Hook
Код:
needless
public OnFilterScriptInit()
You wonder why hooks with * are HOOKS_CallHook in inc? so it would be easier for me when you update the plugin but I would have to update the plugin every edition - and so is every man for himself can add new callbacks, edit the parameters.
There is one thing we can easily add your own hooks public functions here's a small example:
Код:
forward OnPlayerLogin(playerid, bool:success);
public OnPlayerLogin(playerid, bool:success) HOOKS_CallHook("OnPlayerLogin", H_INT, playerid, H_BOOL, success);
#if defined _ALS_OnPlayerLogin
#undef OnPlayerLogin
#else
#define _ALS_OnPlayerLogin
#endif
#define OnPlayerLogin @@HOnPlayerLogin
forward @@HOnPlayerLogin(playerid);
Now we can use
Код:
public OnPlayerLogin(playerid, bool:success)
{
return 1;
}
HOOK:CHouses.OnPlayerLogin(playerid, bool:success)
{
return 1;
}
Source:
https://github.com/piatus/samp-hooks
Release:
https://github.com/piatus/samp-hooks/releases
Sorry for my English.
Re: mHooks - Esay hooking callback and public functions! -
kadaradam - 11.01.2015
Awesome, but how fast is this?
I just want to change y_hooks 4.0, because it sometimes causes pawno crash for me.
Re: mHooks - Esay hooking callback and public functions! -
RCON1 - 11.01.2015
kadaradam, it seems to be a quick but thorough tests makings of tomorrow.
I noticed a problem with the strings, tomorrow is improved.
Re: mHooks - Esay hooking callback and public functions! -
nGen.SoNNy - 11.01.2015
I'll give it a try
Re: mHooks - Esay hooking callback and public functions! -
Abagail - 11.01.2015
This doesn't really seem that scripter-friendly, especially for it being a plug-in. Whats the advantage of using this, instead of say y_hooks?
Re: mHooks - Esay hooking callback and public functions! -
zT KiNgKoNg - 11.01.2015
Quote:
Originally Posted by Abagail
This doesn't really seem that scripter-friendly, especially for it being a plug-in. Whats the advantage of using this, instead of say y_hooks?
|
Along with what Abagail said, it's also pretty useless compared to y_hooks mainly because in my eyes it isn't "Scripter-Friendly", but if you improve on it..... Then it might be better.
Re: mHooks - Esay hooking callback and public functions! -
RCON1 - 15.01.2015
New release:
Fixed to crash during the dialog response.
Fixed a crash related to the empty string.
Added HOOKS_GetVersion and optimize code.
https://github.com/piatus/samp-hooks/releases/tag/1.2.3
Quote:
Originally Posted by zT KiNgKoNg
Along with what Abagail said, it's also pretty useless compared to y_hooks mainly because in my eyes it isn't "Scripter-Friendly", but if you improve on it..... Then it might be better.
|
In y_hooks for example, not hooking up your own callbacks / public functions.
mhooks can be nicely used, for example timers with hooks.
Код:
#define htask:%0[%1](%2) %0HOnScrInit(); public %0HOnScrInit() return SetTimer(#%0,%1,true); %0();public %0() return @HOOKS_CallHook(#%0); zdH%0(); public zdH%0()
Use on
Код:
HOOK:CTest.OnlyTesting()
{
printf("OnlyTesting class CTest hooked");
return 1;
}
htask:OnlyTesting[1000]()
{
printf("OnlyTesting called");
return 1;
}
The possibilities are many more.
Re: mHooks - Esay hooking callback and public functions! -
Abagail - 15.01.2015
Thats not nice at all. You have to define something, whereas y_hooks takes care of everything. All you have to do is replace the word "public" with "hook". And, also, YSI 4.0 supports custom callback hooking, so I guess then this plug-in is useless?
Plus, this is a plug-in whereas y_hooks is a simple, (basically) plug-in and play include.
Re: mHooks - Esay hooking callback and public functions! -
Crayder - 16.01.2015
Quote:
Originally Posted by kadaradam
Awesome, but how fast is this?
I just want to change y_hooks 4.0, because it sometimes causes pawno crash for me.
|
No, you cause the pawno crash.
I was about to mention that then I saw your post while doing a quick-reply :P