y_hooks explanation
#1

May I ask for an explanation? What does it do? What can it help me with?
Reply
#2

........ from https://sampforum.blast.hk/showthread.php?tid=392061
Quote:

Hooking means to add something on a particular thing. Here, we refer it to adding something too on a callback or function. For example, function 'SetPlayerScore' sets the player's score. But if we are using a server sided score system, the 'SetPlayerScore' won't set it. So, we've gotta set that server sided score too by setting variables.

Reply
#3

If you want to actually learn what hooks are and how to use them, read the replies in a topic I made earlier: https://sampforum.blast.hk/showthread.php?tid=531197

y_hooks simplifies hooking, only needing you to do this:
pawn Код:
hook function(playerid)
{
// something
}
A normal hook (ALS method 7) would look like this:

pawn Код:
public function(playerid)
{
    #if defined something_function
        return something_function(playerid);
    #else
        return true;
    #endif
}

#if defined _ALS_function
    #undef function
#else
    #define _ALS_function
#endif
#define function something_function
#if defined something_function
    forward something_function(playerid);
#endif
The only requirement is that you include y_hooks in every file you use hooks in, because y_hooks generates unique function names.

Source: http://ysi.wikia.com/wiki/Library:YSI%5Cy_hooks

It may not be up for long though as ****** left SA-MP today and binned all of his content.

EDIT: Please read what Southclaw wrote, as it covers a lot I didn't. I personally never used y_hooks so I can't give a lot of info.

Quote:
Originally Posted by Southclaw
Public functions and regular functions can be hooked and they require different methods. The two primary methods of hooking are: ALS and y_hooks (only works on publics).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)